Hide reader cutout setting if no cutout detected

This commit is contained in:
arkon 2020-04-22 23:22:03 -04:00
parent f71708e5c5
commit 2a4f35959b
2 changed files with 10 additions and 2 deletions

View File

@ -85,10 +85,14 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
background_color.bindToPreference(preferences.readerTheme())
show_page_number.bindToPreference(preferences.showPageNumber())
fullscreen.bindToPreference(preferences.fullscreen())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val hasDisplayCutout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
activity.window?.decorView?.rootWindowInsets?.displayCutout != null
if (hasDisplayCutout) {
cutout_short.visible()
cutout_short.bindToPreference(preferences.cutoutShort())
}
keepscreen.bindToPreference(preferences.keepScreenOn())
long_tap.bindToPreference(preferences.readWithLongTap())
always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition())

View File

@ -77,13 +77,17 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_fullscreen
defaultValue = true
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val hasDisplayCutout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
activity?.window?.decorView?.rootWindowInsets?.displayCutout != null
if (hasDisplayCutout) {
switchPreference {
key = Keys.cutoutShort
titleRes = R.string.pref_cutout_short
defaultValue = true
}
}
switchPreference {
key = Keys.keepScreenOn
titleRes = R.string.pref_keep_screen_on