[Android] Fix the mini player position on tablet running Android 12L

Nicolas Pomepuy git at videolan.org
Tue Mar 15 10:56:57 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Mar 15 09:44:21 2022 +0100| [c1c9e2d2ccd1e679dd0d1fb7caed70abc4b92821] | committer: Duncan McNamara

Fix the mini player position on tablet running Android 12L

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

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt   | 10 +++++-----
 .../vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt       |  2 +-
 .../vlc-android/src/org/videolan/vlc/gui/MainActivity.kt       |  1 +
 .../vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt   |  2 +-
 .../vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt  |  2 +-
 .../vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt  |  2 +-
 6 files changed, 10 insertions(+), 9 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 ffca19e5d..a8f8e6ef6 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -107,7 +107,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
 
     val menu: Menu
         get() = toolbar.menu
-    open val needsTopInset: Boolean = true
+    open fun needsTopInset(): Boolean = true
 
     var bottomInset = 0
 
@@ -147,8 +147,8 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
             view.updateLayoutParams<ViewGroup.MarginLayoutParams>{
                 leftMargin = insets.left
                 rightMargin = insets.right
-                if (!needsTopInset) bottomMargin = insets.bottom
-                if (needsTopInset) topMargin = insets.top else {
+                if (!needsTopInset()) bottomMargin = insets.bottom
+                if (needsTopInset()) topMargin = insets.top else {
                     val toolbarLayoutParams = findViewById<Toolbar>(R.id.main_toolbar).layoutParams as ViewGroup.MarginLayoutParams
                     toolbarLayoutParams.topMargin = insets.top
                 }
@@ -213,7 +213,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
                 val translationpercent = min(1f, max(0f, slideOffset))
                 bottomBehavior?.let { bottomBehavior ->
                     bottomBar?.let { bottomBar ->
-                        val translation = min((translationpercent * audioPlayerContainer.height / 2), bottomBar.height.toFloat()) - if (!needsTopInset) topInset else 0
+                        val translation = min((translationpercent * audioPlayerContainer.height / 2), bottomBar.height.toFloat()) - if (!needsTopInset()) topInset else 0
                         bottomBehavior.translate(bottomBar, translation)
                     }
                 }
@@ -221,7 +221,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
 
             override fun onStateChanged(bottomSheet: View, newState: Int) {
                 onPlayerStateChanged(bottomSheet, newState)
-                if (!needsTopInset) {
+                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())
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt
index 30d0d8323..70b7b3e44 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt
@@ -63,7 +63,7 @@ class InfoActivity : AudioPlayerContainerActivity(), View.OnClickListener, PathA
     private lateinit var model: InfoModel
 
     internal lateinit var binding: InfoActivityBinding
-    override val needsTopInset = false
+    override fun needsTopInset() = false
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
index d56615e5e..7d756c43d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -77,6 +77,7 @@ class MainActivity : ContentActivity(),
         }
     private lateinit var mediaLibrary: Medialibrary
     private var scanNeeded = false
+    override fun needsTopInset() = !isTablet()
 
     override fun getSnackAnchorView(overAudioPlayer:Boolean): View? {
         val view = super.getSnackAnchorView(overAudioPlayer)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
index 2c4c089fa..fd8100e1f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
@@ -86,7 +86,7 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler<Med
     private var isPlaylist: Boolean = false
     private lateinit var viewModel: PlaylistViewModel
     private var itemTouchHelper: ItemTouchHelper? = null
-    override val needsTopInset: Boolean = false
+    override fun needsTopInset(): Boolean = false
 
     public override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
index 03e5458a0..d5cbd8370 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
@@ -72,7 +72,7 @@ class SecondaryActivity : ContentActivity(), IDialogManager {
         return intent.getStringExtra(KEY_FRAGMENT) == STORAGE_BROWSER_ONBOARDING
     }
 
-    override val needsTopInset = false
+    override fun needsTopInset() = false
 
     override fun forcedTheme() =
         if (intent.getStringExtra(KEY_FRAGMENT) == STORAGE_BROWSER_ONBOARDING) R.style.Theme_VLC_Black
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 7f6ddddfa..895a719bd 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -240,7 +240,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
     fun setBottomMargin() {
         (binding.playPause.layoutParams as? ConstraintLayout.LayoutParams)?.let {
             val audioPlayerContainerActivity = (requireActivity() as AudioPlayerContainerActivity)
-            if (audioPlayerContainerActivity.needsTopInset) it.bottomMargin = it.bottomMargin + audioPlayerContainerActivity.bottomInset
+            if (audioPlayerContainerActivity.needsTopInset()) it.bottomMargin = it.bottomMargin + audioPlayerContainerActivity.bottomInset
         }
     }
 



More information about the Android mailing list