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 e0b01090a..b69a6e503 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 @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.reader -import android.os.Build import android.os.Bundle import android.widget.CompoundButton import android.widget.Spinner @@ -85,14 +84,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia background_color.bindToPreference(preferences.readerTheme()) show_page_number.bindToPreference(preferences.showPageNumber()) fullscreen.bindToPreference(preferences.fullscreen()) - - 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()) - } - + 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 f484fbef9..c8900a9f4 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 @@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.util.preference.intListPreference import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes +import eu.kanade.tachiyomi.util.system.hasDisplayCutout class SettingsReaderController : SettingsController() { @@ -86,9 +87,7 @@ class SettingsReaderController : SettingsController() { defaultValue = true } - val hasDisplayCutout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && - activity?.window?.decorView?.rootWindowInsets?.displayCutout != null - if (hasDisplayCutout) { + if (activity?.hasDisplayCutout() == true) { switchPreference { key = Keys.cutoutShort titleRes = R.string.pref_cutout_short diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ActivityExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ActivityExtensions.kt index 04ef89d00..c654daf4c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ActivityExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ActivityExtensions.kt @@ -4,6 +4,7 @@ import android.app.Activity import android.content.ClipData import android.content.ClipboardManager import android.content.Context +import android.os.Build import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.lang.truncateCenter @@ -21,3 +22,13 @@ fun Activity.copyToClipboard(label: String, content: String) { toast(getString(R.string.copied_to_clipboard, content.truncateCenter(50))) } + +/** + * Checks whether if the device has a display cutout (i.e. notch, camera cutout, etc.). + * + * Only works in Android 9+. + */ +fun Activity.hasDisplayCutout(): Boolean { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && + window.decorView.rootWindowInsets?.displayCutout != null +} diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index 7538c3413..211d23174 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -132,7 +132,6 @@ android:layout_height="wrap_content" android:text="@string/pref_cutout_short" android:textColor="?android:attr/textColorSecondary" - android:visibility="gone" app:layout_constraintTop_toBottomOf="@id/fullscreen" />