From 8992646090a3c74e7df844f39e6b1150b388f459 Mon Sep 17 00:00:00 2001 From: Anil Kumar Beesetti <66936649+anilbeesetti@users.noreply.github.com> Date: Mon, 14 Aug 2023 02:14:34 +0530 Subject: [PATCH] refactor: use `WindowInsetsControllerCompat` instead of deprecated methods (#302) * refactor: remove deprecated methods to hide system ui * fix: action bar reappear after changing the brightness * lint: run ktlintFormat * refactor: remove sdk check * fix: system bars stay visible after closing dialog * fix: add player theme to set navigationbar and statusbar colors to transparent * fix: draw behind navigationbar and statusbar * refactor: remove swipeToShowStatusBars extensions Remove fix for status bar reappearing on LineageOS after changing brightness with gesture. This can always be added back when official Android version from manufacturers also need this fix. --------- Co-authored-by: Jarne Demeulemeester --- app/phone/src/main/AndroidManifest.xml | 3 +- .../dev/jdtech/jellyfin/BasePlayerActivity.kt | 42 ++++++++++--------- .../dev/jdtech/jellyfin/PlayerActivity.kt | 8 ++++ core/src/main/res/values/themes.xml | 6 +++ 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/app/phone/src/main/AndroidManifest.xml b/app/phone/src/main/AndroidManifest.xml index 57840a31..0ac39b0f 100644 --- a/app/phone/src/main/AndroidManifest.xml +++ b/app/phone/src/main/AndroidManifest.xml @@ -25,7 +25,8 @@ + android:screenOrientation="sensorLandscape" + android:theme="@style/Theme.Findroid.Player" /> - val cutout = windowInsets.displayCutout - playerControls.updatePadding( - left = cutout?.safeInsetLeft ?: 0, - top = cutout?.safeInsetTop ?: 0, - right = cutout?.safeInsetRight ?: 0, - bottom = cutout?.safeInsetBottom ?: 0, - ) - return@setOnApplyWindowInsetsListener windowInsets - } + playerControls.setOnApplyWindowInsetsListener { _, windowInsets -> + val cutout = windowInsets.displayCutout + playerControls.updatePadding( + left = cutout?.safeInsetLeft ?: 0, + top = cutout?.safeInsetTop ?: 0, + right = cutout?.safeInsetRight ?: 0, + bottom = cutout?.safeInsetBottom ?: 0, + ) + return@setOnApplyWindowInsetsListener windowInsets + } } } diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/PlayerActivity.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/PlayerActivity.kt index c7e2f14c..8d25fe88 100644 --- a/app/phone/src/main/java/dev/jdtech/jellyfin/PlayerActivity.kt +++ b/app/phone/src/main/java/dev/jdtech/jellyfin/PlayerActivity.kt @@ -19,6 +19,7 @@ import androidx.lifecycle.repeatOnLifecycle import androidx.media3.common.C import androidx.media3.exoplayer.ExoPlayer import androidx.media3.ui.DefaultTimeBar +import androidx.media3.ui.PlayerView import androidx.media3.ui.TrackSelectionDialogBuilder import androidx.navigation.navArgs import dagger.hilt.android.AndroidEntryPoint @@ -57,6 +58,13 @@ class PlayerActivity : BasePlayerActivity() { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) binding.playerView.player = viewModel.player + binding.playerView.setControllerVisibilityListener( + PlayerView.ControllerVisibilityListener { visibility -> + if (visibility == View.GONE) { + hideSystemUI() + } + }, + ) val playerControls = binding.playerView.findViewById(R.id.player_controls) val lockedControls = binding.playerView.findViewById(R.id.locked_player_view) diff --git a/core/src/main/res/values/themes.xml b/core/src/main/res/values/themes.xml index 8a17c4fb..f92fdc29 100644 --- a/core/src/main/res/values/themes.xml +++ b/core/src/main/res/values/themes.xml @@ -1,4 +1,10 @@ + + +