Re-added stuff which I removed accidentally

main
Prathamesh More 2021-10-25 19:23:46 +05:30
parent 3851923a98
commit ef903bdf42
2 changed files with 49 additions and 12 deletions

View File

@ -68,6 +68,8 @@
<h3>What's New</h3> <h3>What's New</h3>
<ul> <ul>
<li><b>Material You</b></li> <li><b>Material You</b></li>
<li>Going Edge-to-Edge</li>
<li>Added Backup & restore</li>
</ul> </ul>
<h3>Improved</h3> <h3>Improved</h3>
<ul> <ul>

View File

@ -15,6 +15,7 @@
package code.name.monkey.retromusic.activities.base package code.name.monkey.retromusic.activities.base
import android.animation.Animator import android.animation.Animator
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -26,6 +27,8 @@ import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.commit import androidx.fragment.app.commit
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.RetroBottomSheetBehavior import code.name.monkey.retromusic.RetroBottomSheetBehavior
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
@ -75,7 +78,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
private var miniPlayerFragment: MiniPlayerFragment? = null private var miniPlayerFragment: MiniPlayerFragment? = null
private var nowPlayingScreen: NowPlayingScreen? = null private var nowPlayingScreen: NowPlayingScreen? = null
private var taskColor: Int = 0 private var taskColor: Int = 0
private var lightStatusBar: Boolean = false private var paletteColor: Int = Color.WHITE
protected abstract fun createContentView(): SlidingMusicPanelLayoutBinding protected abstract fun createContentView(): SlidingMusicPanelLayoutBinding
private val panelState: Int private val panelState: Int
get() = bottomSheetBehavior.state get() = bottomSheetBehavior.state
@ -107,7 +110,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
println("Do something") println("Do something")
} }
} }
println(bottomSheetBehavior.peekHeight)
} }
} }
@ -131,6 +133,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
chooseFragmentForTheme() chooseFragmentForTheme()
setupSlidingUpPanel() setupSlidingUpPanel()
setupBottomSheet() setupBottomSheet()
updateColor()
} }
private fun setupBottomSheet() { private fun setupBottomSheet() {
@ -161,11 +164,12 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
fun collapsePanel() { fun collapsePanel() {
bottomSheetBehavior.state = STATE_COLLAPSED bottomSheetBehavior.state = STATE_COLLAPSED
setMiniPlayerAlphaProgress(0f)
} }
fun expandPanel() { fun expandPanel() {
setMiniPlayerAlphaProgress(1.0f)
bottomSheetBehavior.state = STATE_EXPANDED bottomSheetBehavior.state = STATE_EXPANDED
setMiniPlayerAlphaProgress(1f)
} }
private fun setMiniPlayerAlphaProgress(progress: Float) { private fun setMiniPlayerAlphaProgress(progress: Float) {
@ -181,15 +185,12 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
open fun onPanelCollapsed() { open fun onPanelCollapsed() {
// restore values // restore values
super.setLightStatusbarAuto(surfaceColor()) super.setLightStatusbarAuto(surfaceColor())
super.setLightNavigationAuto()
super.setTaskDescriptionColor(taskColor) super.setTaskDescriptionColor(taskColor)
} }
open fun onPanelExpanded() { open fun onPanelExpanded() {
if (nowPlayingScreen == Blur) { onPaletteColorChanged()
super.setLightStatusbar(false)
} else {
super.setLightStatusbarAuto(surfaceColor())
}
} }
private fun setupSlidingUpPanel() { private fun setupSlidingUpPanel() {
@ -253,10 +254,37 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
return false return false
} }
override fun setLightStatusbar(enabled: Boolean) { private fun onPaletteColorChanged() {
lightStatusBar = enabled if (panelState == STATE_EXPANDED) {
if (panelState == STATE_COLLAPSED) { super.setTaskDescriptionColor(paletteColor)
super.setLightStatusbar(enabled) val isColorLight = ColorUtil.isColorLight(paletteColor)
if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat)) {
super.setLightNavigationBar(true)
super.setLightStatusbar(isColorLight)
} else if (nowPlayingScreen == Card || nowPlayingScreen == Blur || nowPlayingScreen == BlurCard) {
super.setLightStatusbar(false)
super.setLightNavigationBar(true)
} else if (nowPlayingScreen == Color || nowPlayingScreen == Tiny || nowPlayingScreen == Gradient) {
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(isColorLight)
} else if (nowPlayingScreen == Full) {
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(false)
} else if (nowPlayingScreen == Classic) {
super.setLightStatusbar(false)
} else if (nowPlayingScreen == Fit) {
super.setLightStatusbar(false)
} else {
super.setLightStatusbar(
ColorUtil.isColorLight(
ATHUtil.resolveColor(
this,
android.R.attr.windowBackground
)
)
)
super.setLightNavigationBar(true)
}
} }
} }
@ -282,6 +310,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
} }
} }
private fun updateColor() {
libraryViewModel.paletteColor.observe(this, { color ->
this.paletteColor = color
onPaletteColorChanged()
})
}
fun setBottomNavVisibility(visible: Boolean, animate: Boolean = false) { fun setBottomNavVisibility(visible: Boolean, animate: Boolean = false) {
binding.bottomNavigationView.isVisible = visible binding.bottomNavigationView.isVisible = visible
hideBottomSheet(MusicPlayerRemote.playingQueue.isEmpty(), animate) hideBottomSheet(MusicPlayerRemote.playingQueue.isEmpty(), animate)