소스 검색

Hide reader cutout setting if no cutout detected

arkon 5 년 전
부모
커밋
2a4f35959b

+ 5 - 1
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())

+ 5 - 1
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