Hide alternative PiP controls setting if PiP is not enabled.

This commit is contained in:
Isira Seneviratne 2023-03-29 18:52:53 +05:30
parent fe9a48e1d3
commit e66c0b6674

View File

@ -59,16 +59,22 @@ class PlayerSettings : BasePreferenceFragment() {
true true
} }
val pictureInPicture = findPreference<SwitchPreferenceCompat>( val pictureInPicture =
PreferenceKeys.PICTURE_IN_PICTURE findPreference<SwitchPreferenceCompat>(PreferenceKeys.PICTURE_IN_PICTURE)!!
)!! pictureInPicture.isVisible =
PictureInPictureCompat.isPictureInPictureAvailable(requireContext())
val pauseOnQuit = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PAUSE_ON_QUIT) val pauseOnQuit = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PAUSE_ON_QUIT)
pictureInPicture.isVisible = PictureInPictureCompat val alternativePipControls =
.isPictureInPictureAvailable(requireContext()) findPreference<SwitchPreferenceCompat>(PreferenceKeys.ALTERNATIVE_PIP_CONTROLS)
pauseOnQuit?.isVisible = !pictureInPicture.isVisible || !pictureInPicture.isChecked val isPipEnabled = pictureInPicture.isVisible && pictureInPicture.isChecked
pauseOnQuit?.isVisible = !isPipEnabled
alternativePipControls?.isVisible = isPipEnabled
pictureInPicture.setOnPreferenceChangeListener { _, newValue -> pictureInPicture.setOnPreferenceChangeListener { _, newValue ->
pauseOnQuit?.isVisible = !(newValue as Boolean) val isChecked = newValue as Boolean
pauseOnQuit?.isVisible = !isChecked
alternativePipControls?.isVisible = isChecked
true true
} }