From e66c0b6674ad631b16702fdcee8728738b34a3f8 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 29 Mar 2023 18:52:53 +0530 Subject: [PATCH] Hide alternative PiP controls setting if PiP is not enabled. --- .../ui/preferences/PlayerSettings.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt index cb5d20a6f..a40168fed 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt @@ -59,16 +59,22 @@ class PlayerSettings : BasePreferenceFragment() { true } - val pictureInPicture = findPreference( - PreferenceKeys.PICTURE_IN_PICTURE - )!! + val pictureInPicture = + findPreference(PreferenceKeys.PICTURE_IN_PICTURE)!! + pictureInPicture.isVisible = + PictureInPictureCompat.isPictureInPictureAvailable(requireContext()) + val pauseOnQuit = findPreference(PreferenceKeys.PAUSE_ON_QUIT) - pictureInPicture.isVisible = PictureInPictureCompat - .isPictureInPictureAvailable(requireContext()) - pauseOnQuit?.isVisible = !pictureInPicture.isVisible || !pictureInPicture.isChecked + val alternativePipControls = + findPreference(PreferenceKeys.ALTERNATIVE_PIP_CONTROLS) + val isPipEnabled = pictureInPicture.isVisible && pictureInPicture.isChecked + pauseOnQuit?.isVisible = !isPipEnabled + alternativePipControls?.isVisible = isPipEnabled pictureInPicture.setOnPreferenceChangeListener { _, newValue -> - pauseOnQuit?.isVisible = !(newValue as Boolean) + val isChecked = newValue as Boolean + pauseOnQuit?.isVisible = !isChecked + alternativePipControls?.isVisible = isChecked true }