From 3da6b0678ac219bc448febb1e0921feb1171f7aa Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 20 Jan 2023 18:48:29 +0100 Subject: [PATCH 1/2] Keep space for the status bar in player --- .../libretube/ui/views/CustomExoPlayerView.kt | 14 +++++--------- .../res/layout/exo_styled_player_control_view.xml | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 36e1aad9c..2717298b7 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -202,10 +202,6 @@ 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() @@ -578,10 +574,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 +672,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() } } diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index a4fb1cced..71671e086 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -17,7 +17,7 @@ android:animateLayoutChanges="true" android:orientation="vertical" android:paddingHorizontal="5dp" - android:paddingTop="5dp" > + android:paddingTop="25dp" > Date: Fri, 20 Jan 2023 18:49:53 +0100 Subject: [PATCH 2/2] Hide the status bar when hiding the controllers --- .../com/github/libretube/ui/views/CustomExoPlayerView.kt | 1 + .../main/java/com/github/libretube/util/WindowHelper.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 2717298b7..b592b9574 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -205,6 +205,7 @@ internal class CustomExoPlayerView( // remove the callback to hide the controller handler.removeCallbacks(hideControllerRunnable) super.hideController() + (context as? MainActivity)?.windowHelper?.hideStatusBar() } override fun showController() { diff --git a/app/src/main/java/com/github/libretube/util/WindowHelper.kt b/app/src/main/java/com/github/libretube/util/WindowHelper.kt index e75c6855d..7f669d25f 100644 --- a/app/src/main/java/com/github/libretube/util/WindowHelper.kt +++ b/app/src/main/java/com/github/libretube/util/WindowHelper.kt @@ -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()) + } }