Fixed peak theme
This commit is contained in:
parent
3f368e186b
commit
caefbbbbad
3 changed files with 30 additions and 32 deletions
|
@ -16,6 +16,7 @@ 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.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.extensions.whichFragment
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
||||||
|
@ -34,6 +35,7 @@ import code.name.monkey.retromusic.fragments.player.full.FullPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.gradient.GradientPlayerFragment
|
import code.name.monkey.retromusic.fragments.player.gradient.GradientPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.material.MaterialFragment
|
import code.name.monkey.retromusic.fragments.player.material.MaterialFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.player.peak.PeakPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.plain.PlainPlayerFragment
|
import code.name.monkey.retromusic.fragments.player.plain.PlainPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.simple.SimplePlayerFragment
|
import code.name.monkey.retromusic.fragments.player.simple.SimplePlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
||||||
|
@ -68,6 +70,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
|
|
||||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||||
setMiniPlayerAlphaProgress(slideOffset)
|
setMiniPlayerAlphaProgress(slideOffset)
|
||||||
|
dimBackground.show()
|
||||||
|
dimBackground.alpha = slideOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||||
|
@ -77,6 +81,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
STATE_COLLAPSED -> {
|
STATE_COLLAPSED -> {
|
||||||
onPanelCollapsed()
|
onPanelCollapsed()
|
||||||
|
dimBackground.hide()
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
println("Do something")
|
println("Do something")
|
||||||
|
@ -85,6 +90,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getBottomSheetBehavior() = bottomSheetBehavior
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -94,11 +100,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
setupBottomSheet()
|
setupBottomSheet()
|
||||||
updatePanelState()
|
updatePanelState()
|
||||||
updateColor()
|
updateColor()
|
||||||
|
|
||||||
|
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
||||||
|
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||||
|
dimBackground.setOnClickListener {
|
||||||
|
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getBottomSheetBehavior() = bottomSheetBehavior
|
|
||||||
|
|
||||||
private fun setupBottomSheet() {
|
private fun setupBottomSheet() {
|
||||||
bottomSheetBehavior = from(slidingPanel) as RetroBottomSheetBehavior
|
bottomSheetBehavior = from(slidingPanel) as RetroBottomSheetBehavior
|
||||||
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
|
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||||
|
@ -158,6 +167,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
ViewTreeObserver.OnGlobalLayoutListener {
|
ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
|
if (nowPlayingScreen != Peak) {
|
||||||
|
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
|
||||||
|
params.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
slidingPanel.layoutParams = params
|
||||||
|
}
|
||||||
when (panelState) {
|
when (panelState) {
|
||||||
STATE_EXPANDED -> onPanelExpanded()
|
STATE_EXPANDED -> onPanelExpanded()
|
||||||
STATE_COLLAPSED -> onPanelCollapsed()
|
STATE_COLLAPSED -> onPanelCollapsed()
|
||||||
|
@ -173,31 +187,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
return bottomNavigationView
|
return bottomNavigationView
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hideBottomBarVisibility(visible: Boolean) {
|
|
||||||
bottomNavigationView.isVisible = visible
|
|
||||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun hideBottomBar(hide: Boolean) {
|
|
||||||
val heightOfBar = bottomNavigationView.height
|
|
||||||
val isBottomBarVisible = bottomNavigationView.isVisible
|
|
||||||
|
|
||||||
if (hide) {
|
|
||||||
bottomSheetBehavior.isHideable = true
|
|
||||||
bottomSheetBehavior.peekHeight = 0
|
|
||||||
collapsePanel()
|
|
||||||
ViewCompat.setElevation(slidingPanel, 0f)
|
|
||||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
|
||||||
} else {
|
|
||||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
|
||||||
ViewCompat.setElevation(slidingPanel, 10f)
|
|
||||||
bottomSheetBehavior.isHideable = false
|
|
||||||
bottomSheetBehavior.peekHeight =
|
|
||||||
(if (isBottomBarVisible) heightOfBar * 2 else heightOfBar) - 24
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun onServiceConnected() {
|
override fun onServiceConnected() {
|
||||||
super.onServiceConnected()
|
super.onServiceConnected()
|
||||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||||
|
@ -379,6 +368,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private var playerFragment: AbsPlayerFragment? = null
|
private var playerFragment: AbsPlayerFragment? = null
|
||||||
private fun chooseFragmentForTheme() {
|
private fun chooseFragmentForTheme() {
|
||||||
nowPlayingScreen = PreferenceUtil.nowPlayingScreen
|
nowPlayingScreen = PreferenceUtil.nowPlayingScreen
|
||||||
|
@ -398,7 +388,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
Color -> ColorFragment()
|
Color -> ColorFragment()
|
||||||
Gradient -> GradientPlayerFragment()
|
Gradient -> GradientPlayerFragment()
|
||||||
Tiny -> TinyPlayerFragment()
|
Tiny -> TinyPlayerFragment()
|
||||||
//PEAK -> PeakPlayerFragment()
|
Peak -> PeakPlayerFragment()
|
||||||
Circle -> CirclePlayerFragment()
|
Circle -> CirclePlayerFragment()
|
||||||
else -> PlayerFragment()
|
else -> PlayerFragment()
|
||||||
} // must implement AbsPlayerFragment
|
} // must implement AbsPlayerFragment
|
||||||
|
@ -406,7 +396,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
.commit()
|
.commit()
|
||||||
supportFragmentManager.executePendingTransactions()
|
supportFragmentManager.executePendingTransactions()
|
||||||
|
|
||||||
playerFragment = supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
|
playerFragment =
|
||||||
|
supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
|
||||||
miniPlayerFragment = whichFragment<MiniPlayerFragment>(R.id.miniPlayerFragment)
|
miniPlayerFragment = whichFragment<MiniPlayerFragment>(R.id.miniPlayerFragment)
|
||||||
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ enum class NowPlayingScreen constructor(
|
||||||
Gradient(R.string.gradient, R.drawable.np_gradient, 17),
|
Gradient(R.string.gradient, R.drawable.np_gradient, 17),
|
||||||
Material(R.string.material, R.drawable.np_material, 11),
|
Material(R.string.material, R.drawable.np_material, 11),
|
||||||
Normal(R.string.normal, R.drawable.np_normal, 0),
|
Normal(R.string.normal, R.drawable.np_normal, 0),
|
||||||
//Peak(R.string.peak, R.drawable.np_peak, 14),
|
Peak(R.string.peak, R.drawable.np_peak, 14),
|
||||||
Plain(R.string.plain, R.drawable.np_plain, 3),
|
Plain(R.string.plain, R.drawable.np_plain, 3),
|
||||||
Simple(R.string.simple, R.drawable.np_simple, 8),
|
Simple(R.string.simple, R.drawable.np_simple, 8),
|
||||||
Tiny(R.string.tiny, R.drawable.np_tiny, 7),
|
Tiny(R.string.tiny, R.drawable.np_tiny, 7),
|
||||||
|
|
|
@ -11,12 +11,19 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/dimBackground"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/slidingPanel"
|
android:id="@+id/slidingPanel"
|
||||||
style="@style/Widget.BottomSheet"
|
style="@style/Widget.BottomSheet"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
app:behavior_hideable="true"
|
app:behavior_hideable="true"
|
||||||
app:behavior_peekHeight="0dp"
|
app:behavior_peekHeight="0dp"
|
||||||
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior">
|
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior">
|
||||||
|
|
Loading…
Reference in a new issue