Skip to content
Snippets Groups Projects
Commit 4043d612 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

Fix status bar not hidden in sub activities on orientation change

Fixes #2454
parent 6c4fbd79
No related branches found
No related tags found
1 merge request!1315Fix status bar not hidden in sub activities on orientation change
Pipeline #204926 passed with stage
in 6 minutes and 14 seconds
......@@ -209,7 +209,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
playerBehavior = from(audioPlayerContainer) as PlayerBehavior<*>
val bottomBehavior = bottomBar?.let { BottomNavigationBehavior.from(it) as BottomNavigationBehavior<View> }
?: null
if (bottomIsHiddden) bottomBehavior?.setCollapsed()
if (bottomIsHiddden) bottomBehavior?.setCollapsed() else hideStatusIfNeeded(playerBehavior.state)
playerBehavior.peekHeight = resources.getDimensionPixelSize(R.dimen.player_peek_height)
updateFragmentMargins()
playerBehavior.setPeekHeightListener {
......@@ -236,12 +236,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
override fun onStateChanged(bottomSheet: View, newState: Int) {
onPlayerStateChanged(bottomSheet, newState)
if (!needsTopInset()) {
WindowInsetsControllerCompat(window, window.decorView).apply {
systemBarsBehavior = if (newState == STATE_EXPANDED) WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE else WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH
if (newState == STATE_EXPANDED) hide(WindowInsetsCompat.Type.statusBars()) else show(WindowInsetsCompat.Type.statusBars())
}
}
hideStatusIfNeeded(newState)
audioPlayer.onStateChanged(newState)
if (newState == STATE_COLLAPSED || newState == STATE_HIDDEN) removeTipViewIfDisplayed()
updateFragmentMargins(newState)
......@@ -253,6 +248,15 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
if (playlistTipsDelegate.currentTip != null) lockPlayer(true)
}
private fun hideStatusIfNeeded(newState: Int) {
if (!needsTopInset()) {
WindowInsetsControllerCompat(window, window.decorView).apply {
systemBarsBehavior = if (newState == STATE_EXPANDED) WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE else WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH
if (newState == STATE_EXPANDED) hide(WindowInsetsCompat.Type.statusBars()) else show(WindowInsetsCompat.Type.statusBars())
}
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (playerKeyListenerDelegate.onKeyDown(keyCode, event)) return true
return super.onKeyDown(keyCode, event)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment