Commit bffe558e authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix audio player safe padding for all fragments

Fixes #1485
parent 7897fea4
Pipeline #44551 passed with stage
in 3 minutes and 26 seconds
......@@ -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
......@@ -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
......
......@@ -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"
......
......@@ -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"
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment