Merge pull request #2776 from Bnyro/master

Keep space for the status bar in player
This commit is contained in:
Bnyro 2023-01-20 18:50:03 +01:00 committed by GitHub
commit 579e8f167e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 10 deletions

View File

@ -202,13 +202,10 @@ internal class CustomExoPlayerView(
}
override fun hideController() {
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
// hide all the navigation bars that potentially could have been reopened manually by the user
(context as? MainActivity)?.windowHelper?.setFullscreen()
}
// remove the callback to hide the controller
handler.removeCallbacks(hideControllerRunnable)
super.hideController()
(context as? MainActivity)?.windowHelper?.hideStatusBar()
}
override fun showController() {
@ -578,10 +575,10 @@ internal class CustomExoPlayerView(
}
listOf(binding.topBar, binding.bottomBar).forEach {
val params = it.layoutParams as MarginLayoutParams
params.marginStart = newMargin
params.marginEnd = newMargin
it.layoutParams = params
it.layoutParams = (it.layoutParams as MarginLayoutParams).apply {
marginStart = newMargin
marginEnd = newMargin
}
}
}
@ -676,6 +673,6 @@ internal class CustomExoPlayerView(
companion object {
private const val SUBTITLE_BOTTOM_PADDING_FRACTION = 0.158f
private const val ANIMATION_DURATION = 100L
private val LANDSCAPE_MARGIN_HORIZONTAL = (30).toPixel().toInt()
private val LANDSCAPE_MARGIN_HORIZONTAL = (20).toPixel().toInt()
}
}

View File

@ -46,4 +46,12 @@ class WindowHelper(private val activity: BaseActivity) {
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
}
fun hideStatusBar() = activity.apply {
WindowInsetsControllerCompat(window, window.decorView).hide(WindowInsetsCompat.Type.statusBars())
}
fun showStatusBar() = activity.apply {
WindowInsetsControllerCompat(window, window.decorView).show(WindowInsetsCompat.Type.statusBars())
}
}

View File

@ -17,7 +17,7 @@
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingHorizontal="5dp"
android:paddingTop="5dp" >
android:paddingTop="25dp" >
<LinearLayout
android:layout_width="match_parent"