[Android] Fix audio player safe padding for all fragments
Nicolas Pomepuy
git at videolan.org
Fri Dec 4 07:56:43 CET 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Dec 2 08:09:43 2020 +0100| [bffe558ebbd8c6db1daa6cfa4164e3f86ff948f7] | committer: Nicolas Pomepuy
Fix audio player safe padding for all fragments
Fixes #1485
> https://code.videolan.org/videolan/vlc-android/commit/bffe558ebbd8c6db1daa6cfa4164e3f86ff948f7
---
application/vlc-android/res/layout/audio_recyclerview.xml | 3 +--
application/vlc-android/res/layout/main_browser_fragment.xml | 3 +--
application/vlc-android/res/layout/more_fragment.xml | 3 +--
application/vlc-android/res/layout/video_grid.xml | 3 +--
.../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt | 12 ++++++++++++
.../vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt | 12 ++++++++++++
6 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/application/vlc-android/res/layout/audio_recyclerview.xml b/application/vlc-android/res/layout/audio_recyclerview.xml
index 79a1ff06d..ae0497087 100644
--- a/application/vlc-android/res/layout/audio_recyclerview.xml
+++ b/application/vlc-android/res/layout/audio_recyclerview.xml
@@ -8,7 +8,6 @@
android:layout_width="@dimen/default_content_width"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
- android:clipToPadding="false"
- android:paddingBottom="64dp"/>
+ android:clipToPadding="false"/>
</FrameLayout>
\ No newline at end of file
diff --git a/application/vlc-android/res/layout/main_browser_fragment.xml b/application/vlc-android/res/layout/main_browser_fragment.xml
index 527cec203..aa620a0a4 100644
--- a/application/vlc-android/res/layout/main_browser_fragment.xml
+++ b/application/vlc-android/res/layout/main_browser_fragment.xml
@@ -28,8 +28,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="64dp">
+ android:layout_height="match_parent">
<org.videolan.vlc.gui.view.TitleListView
diff --git a/application/vlc-android/res/layout/more_fragment.xml b/application/vlc-android/res/layout/more_fragment.xml
index 939634a1e..aa9001838 100644
--- a/application/vlc-android/res/layout/more_fragment.xml
+++ b/application/vlc-android/res/layout/more_fragment.xml
@@ -30,8 +30,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="64dp">
+ android:layout_height="match_parent">
<org.videolan.vlc.gui.view.AutofitButton
android:id="@+id/settingsButton"
diff --git a/application/vlc-android/res/layout/video_grid.xml b/application/vlc-android/res/layout/video_grid.xml
index 950fbbe14..8c8fa7ef7 100644
--- a/application/vlc-android/res/layout/video_grid.xml
+++ b/application/vlc-android/res/layout/video_grid.xml
@@ -14,8 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="64dp">
+ android:layout_height="match_parent">
<include
layout="@layout/button_search"
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 fdbad6b7d..c2f6ae53a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -92,6 +92,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
private lateinit var resumeCard: Snackbar
private var preventRescan = false
+ private var playerShown = false
protected val currentFragment: Fragment?
get() = supportFragmentManager.findFragmentById(R.id.fragment_placeholder)
@@ -153,6 +154,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
val bottomBehavior = bottomBar?.let { BottomNavigationBehavior.from(it) as BottomNavigationBehavior<View> }
?: null
playerBehavior.peekHeight = resources.getDimensionPixelSize(R.dimen.player_peek_height)
+ updateFragmentMargins()
playerBehavior.addBottomSheetCallback(object : BottomSheetCallback() {
override fun onSlide(bottomSheet: View, slideOffset: Float) {
audioPlayer.onSlide(slideOffset)
@@ -169,11 +171,21 @@ open class AudioPlayerContainerActivity : BaseActivity() {
onPlayerStateChanged(bottomSheet, newState)
audioPlayer.onStateChanged(newState)
if (newState == STATE_COLLAPSED || newState == STATE_HIDDEN) removeTipViewIfDisplayed()
+ updateFragmentMargins(newState)
}
})
showTipViewIfNeeded(R.id.audio_player_tips, PREF_AUDIOPLAYER_TIPS_SHOWN)
}
+ fun updateFragmentMargins(state: Int = STATE_COLLAPSED) {
+ playerShown = state != STATE_HIDDEN
+ supportFragmentManager.fragments.forEach { fragment ->
+ if (fragment is BaseFragment) fragment.updateAudioPlayerMargin()
+ }
+ }
+
+ 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 }
?: false)
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 1214d3c30..900d9aec1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
@@ -67,6 +67,18 @@ 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