[Android] Fix bottom bar behavior after a rotation when player is opened

Nicolas Pomepuy git at videolan.org
Thu Aug 5 05:25:53 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Aug  4 08:04:58 2021 +0200| [2b1272c73ab7c34c23f3a6627fd08e62476dac74] | committer: Nicolas Pomepuy

Fix bottom bar behavior after a rotation when player is opened

Fixes #2120

> https://code.videolan.org/videolan/vlc-android/commit/2b1272c73ab7c34c23f3a6627fd08e62476dac74
---

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt        | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
index 4a8ef65ab..2fe9d6515 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -75,6 +75,7 @@ private const val ACTION_DISPLAY_PROGRESSBAR = 1339
 private const val ACTION_SHOW_PLAYER = 1340
 private const val ACTION_HIDE_PLAYER = 1341
 private const val BOTTOM_IS_HIDDEN = "bottom_is_hidden"
+private const val PLAYER_OPENED = "player_opened"
 private const val SHOWN_TIPS = "shown_tips"
 
 @SuppressLint("Registered")
@@ -128,7 +129,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
         //Init Medialibrary if KO
         if (savedInstanceState != null) {
             this.startMedialibrary(firstRun = false, upgrade = false, parse = true)
-            bottomIsHiddden = savedInstanceState.getBoolean(BOTTOM_IS_HIDDEN, false)
+            bottomIsHiddden = savedInstanceState.getBoolean(BOTTOM_IS_HIDDEN, false) && !savedInstanceState.getBoolean(PLAYER_OPENED, false)
             savedInstanceState.getIntegerArrayList(SHOWN_TIPS)?.let { shownTips.addAll(it) }
         }
         super.onCreate(savedInstanceState)
@@ -166,7 +167,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
         audioPlayer = supportFragmentManager.findFragmentById(R.id.audio_player) as AudioPlayer
         playerBehavior = from(audioPlayerContainer) as PlayerBehavior<*>
         val bottomBehavior = bottomBar?.let { BottomNavigationBehavior.from(it) as BottomNavigationBehavior<View> }
-                ?: null
+            ?: null
         if (bottomIsHiddden)  bottomBehavior?.setCollapsed()
         playerBehavior.peekHeight = resources.getDimensionPixelSize(R.dimen.player_peek_height)
         updateFragmentMargins()
@@ -205,6 +206,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
     override fun onSaveInstanceState(outState: Bundle) {
         outState.putBoolean(BOTTOM_IS_HIDDEN, bottomBar?.let { it.translationY != 0F }
                 ?: false)
+        outState.putBoolean(PLAYER_OPENED,  if (::playerBehavior.isInitialized) playerBehavior.state == STATE_EXPANDED else false)
         outState.putIntegerArrayList(SHOWN_TIPS, shownTips)
         super.onSaveInstanceState(outState)
     }



More information about the Android mailing list