From 2a4f35959b6c060ae6390e2b2898e83cc0fda054 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 22 Apr 2020 23:22:03 -0400 Subject: [PATCH] Hide reader cutout setting if no cutout detected --- .../eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt | 6 +++++- .../kanade/tachiyomi/ui/setting/SettingsReaderController.kt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index e6fa18ab9..e0b01090a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -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()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index 1ceb0e959..e40e12394 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -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