From fbf9c30e9a5de52492122d558b4121b30b41b979 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 20 Jan 2023 18:49:53 +0100 Subject: [PATCH] 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()) + } }