[Android] Fix bottom paddings for all fragments
Nicolas Pomepuy
git at videolan.org
Wed May 18 09:11:09 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon May 16 14:25:54 2022 +0200| [5c4a684461e2b9da2edf4760e6724d7e4b2de0f7] | committer: Duncan McNamara
Fix bottom paddings for all fragments
> https://code.videolan.org/videolan/vlc-android/commit/5c4a684461e2b9da2edf4760e6724d7e4b2de0f7
---
.../vlc-android/res/layout/directory_browser.xml | 8 +++-----
.../videolan/vlc/gui/AudioPlayerContainerActivity.kt | 16 ++++++++++------
.../src/org/videolan/vlc/gui/BaseFragment.kt | 17 -----------------
3 files changed, 13 insertions(+), 28 deletions(-)
diff --git a/application/vlc-android/res/layout/directory_browser.xml b/application/vlc-android/res/layout/directory_browser.xml
index 3cbff097d..7af6689c6 100644
--- a/application/vlc-android/res/layout/directory_browser.xml
+++ b/application/vlc-android/res/layout/directory_browser.xml
@@ -14,7 +14,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:clipToPadding="false">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ariane"
@@ -42,7 +43,6 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintHeight_default="spread"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ariane">
@@ -51,9 +51,7 @@
android:id="@+id/network_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone"
- android:clipToPadding="false"
- android:paddingBottom="64dp"/>
+ android:visibility="gone"/>
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
<org.videolan.vlc.gui.view.EmptyLoadingStateView
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 d6ab31b1c..16ab01902 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -157,10 +157,10 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
val bottomNavigationView = findViewById<BottomNavigationView?>(R.id.navigation)
bottomNavigationView?.setPadding(bottomNavigationView.paddingLeft, bottomNavigationView.paddingTop, bottomNavigationView.paddingRight, insets.bottom)
bottomInset = insets.bottom
- setContentBottomPadding()
insetListener.invoke(insets)
if (::audioPlayer.isInitialized) audioPlayer.setBottomMargin()
}
+ setContentBottomPadding()
}
WindowInsetsCompat.CONSUMED
@@ -172,7 +172,12 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
* and the presence of the bottom navigation and mini player
*/
private fun setContentBottomPadding() {
- val bottomMargin = if (this is MainActivity && isTablet()) 0 else bottomInset + if (this is MainActivity && !isTablet()) 58.dp else 0 + if (::playerBehavior.isInitialized && playerBehavior.state != STATE_COLLAPSED) 72.dp else 0 + 4.dp
+ // insets from soft nav buttons
+ var bottomMargin = if (this is MainActivity && isTablet()) 0 else bottomInset
+ // Bottom bar navigation
+ bottomMargin += if (this is MainActivity && !isTablet()) 58.dp else 0
+ //mini player
+ bottomMargin += if (::playerBehavior.isInitialized && playerBehavior.state != STATE_HIDDEN) 72.dp else 0 + 4.dp
fragmentContainer.setPadding(fragmentContainer.paddingLeft, fragmentContainer.paddingTop, fragmentContainer.paddingRight, bottomMargin)
}
@@ -315,12 +320,10 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
fun updateFragmentMargins(state: Int = STATE_COLLAPSED) {
playerShown = state != STATE_HIDDEN
- supportFragmentManager.fragments.forEach { fragment ->
- if (fragment is BaseFragment) fragment.updateAudioPlayerMargin()
- }
+ setContentBottomPadding()
}
- fun getAudioMargin() = if (playerShown) resources.getDimensionPixelSize(R.dimen.player_peek_height) else 0
+// fun getAudioMargin() = if (playerShown) resources.getDimensionPixelSize(R.dimen.player_peek_height) else 0
override fun onSaveInstanceState(outState: Bundle) {
outState.putBoolean(BOTTOM_IS_HIDDEN, bottomBar?.let { it.translationY != 0F }
@@ -359,6 +362,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
applyMarginToProgressBar(playerBehavior.peekHeight)
else
applyMarginToProgressBar(0)
+ setContentBottomPadding()
super.onResume()
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
index e4cfb59c4..97adfdf5a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
@@ -1,10 +1,8 @@
package org.videolan.vlc.gui
import android.content.Intent
-import android.content.res.Configuration
import android.content.res.TypedArray
import android.os.Bundle
-import android.util.Log
import android.util.TypedValue
import android.view.Menu
import android.view.View
@@ -21,17 +19,14 @@ import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.resources.TAG_ITEM
-import org.videolan.tools.dp
import org.videolan.tools.retrieveParent
import org.videolan.tools.setGone
-import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.gui.browser.KEY_IN_MEDIALIB
import org.videolan.vlc.gui.browser.KEY_MEDIA
import org.videolan.vlc.gui.helpers.FloatingActionButtonBehavior
import org.videolan.vlc.gui.helpers.UiTools.isTablet
import org.videolan.vlc.gui.view.SwipeRefreshLayout
-import org.videolan.vlc.util.getScreenWidth
abstract class BaseFragment : Fragment(), ActionMode.Callback {
var actionMode: ActionMode? = null
@@ -94,18 +89,6 @@ abstract class BaseFragment : Fragment(), ActionMode.Callback {
setFabPlayVisibility(false)
}
- override fun onResume() {
- updateAudioPlayerMargin()
- super.onResume()
- }
-
- fun updateAudioPlayerMargin() {
- val activity = activity as? AudioPlayerContainerActivity? ?: return
- view?.let {
- it.setPadding(0,0,0,activity.getAudioMargin())
- }
- }
-
fun startActionMode() {
val activity = activity as AppCompatActivity? ?: return
actionMode = activity.startSupportActionMode(this)
More information about the Android
mailing list