[Android] Fix the mini player position upon rotation changes

Nicolas Pomepuy git at videolan.org
Thu Mar 4 06:38:14 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Mar  2 08:41:52 2021 +0100| [f49a0bcb551e6d920838a893bc0c9c915681f831] | committer: Nicolas Pomepuy

Fix the mini player position upon rotation changes

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

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt         | 5 ++++-
 .../src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt     | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

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 294f600d9..f4a824670 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -109,6 +109,8 @@ open class AudioPlayerContainerActivity : BaseActivity() {
     val isAudioPlayerExpanded: Boolean
         get() = isAudioPlayerReady && playerBehavior.state == STATE_EXPANDED
 
+    var bottomIsHiddden: Boolean = false
+
     override fun getSnackAnchorView(): View? {
       return  if (::audioPlayerContainer.isInitialized && audioPlayerContainer.visibility != View.GONE && ::playerBehavior.isInitialized && playerBehavior.state == STATE_COLLAPSED)
           audioPlayerContainer else if (::playerBehavior.isInitialized && playerBehavior.state == STATE_EXPANDED) findViewById(android.R.id.content) else if (::playerBehavior.isInitialized) findViewById(R.id.coordinator) else findViewById(android.R.id.content)
@@ -117,8 +119,8 @@ open class AudioPlayerContainerActivity : BaseActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
         //Init Medialibrary if KO
         if (savedInstanceState != null) {
-
             this.startMedialibrary(firstRun = false, upgrade = false, parse = true)
+            bottomIsHiddden = savedInstanceState.getBoolean(BOTTOM_IS_HIDDEN, false)
         }
         super.onCreate(savedInstanceState)
         volumeControlStream = AudioManager.STREAM_MUSIC
@@ -153,6 +155,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
         playerBehavior = from(audioPlayerContainer) as PlayerBehavior<*>
         val bottomBehavior = bottomBar?.let { BottomNavigationBehavior.from(it) as BottomNavigationBehavior<View> }
                 ?: null
+        if (bottomIsHiddden)  bottomBehavior?.setCollapsed()
         playerBehavior.peekHeight = resources.getDimensionPixelSize(R.dimen.player_peek_height)
         updateFragmentMargins()
         playerBehavior.addBottomSheetCallback(object : BottomSheetCallback() {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt
index d0fe4ff6a..6738c642d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt
@@ -209,6 +209,10 @@ class BottomNavigationBehavior<V : View>(context: Context, attrs: AttributeSet)
         updatePlayer(child)
     }
 
+    fun setCollapsed() {
+        currentState = STATE_SCROLLED_DOWN
+    }
+
     companion object {
         fun <V : View> from(view: V): BottomNavigationBehavior<V>? {
             val params = view.layoutParams



More information about the Android mailing list