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
}
val pictureInPicture = findPreference<SwitchPreferenceCompat>(
PreferenceKeys.PICTURE_IN_PICTURE
)!!
val pictureInPicture =
findPreference<SwitchPreferenceCompat>(PreferenceKeys.PICTURE_IN_PICTURE)!!
pictureInPicture.isVisible =
PictureInPictureCompat.isPictureInPictureAvailable(requireContext())
val pauseOnQuit = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PAUSE_ON_QUIT)
pictureInPicture.isVisible = PictureInPictureCompat
.isPictureInPictureAvailable(requireContext())
pauseOnQuit?.isVisible = !pictureInPicture.isVisible || !pictureInPicture.isChecked
val alternativePipControls =
findPreference<SwitchPreferenceCompat>(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
}