mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Fix fullscreen reader for notch device (#2595)
* Fix fullscreen reader for notch device * Make cutout mode configurable * Rename cutout option
This commit is contained in:
parent
a7ece4fdf3
commit
12aa04be93
7 changed files with 44 additions and 1 deletions
|
@ -19,6 +19,8 @@ object PreferenceKeys {
|
|||
|
||||
const val fullscreen = "fullscreen"
|
||||
|
||||
const val cutoutShort = "cutout_short"
|
||||
|
||||
const val keepScreenOn = "pref_keep_screen_on_key"
|
||||
|
||||
const val customBrightness = "pref_custom_brightness_key"
|
||||
|
|
|
@ -67,6 +67,8 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true)
|
||||
|
||||
fun cutoutShort() = rxPrefs.getBoolean(Keys.cutoutShort, true)
|
||||
|
||||
fun keepScreenOn() = rxPrefs.getBoolean(Keys.keepScreenOn, true)
|
||||
|
||||
fun customBrightness() = rxPrefs.getBoolean(Keys.customBrightness, false)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.kanade.tachiyomi.ui.reader
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.annotation.TargetApi
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -8,6 +9,7 @@ import android.content.pm.ActivityInfo
|
|||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.animation.Animation
|
||||
|
@ -565,6 +567,11 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
subscriptions += preferences.fullscreen().asObservable()
|
||||
.subscribe { setFullscreen(it) }
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
subscriptions += preferences.cutoutShort().asObservable()
|
||||
.subscribe { setCutoutShort(it)}
|
||||
}
|
||||
|
||||
subscriptions += preferences.keepScreenOn().asObservable()
|
||||
.subscribe { setKeepScreenOn(it) }
|
||||
|
||||
|
@ -646,6 +653,14 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.P)
|
||||
private fun setCutoutShort(enabled: Boolean) {
|
||||
window.attributes.layoutInDisplayCutoutMode = when (enabled) {
|
||||
true -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||
false -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the keep screen on mode according to [enabled].
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.kanade.tachiyomi.ui.reader
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.Spinner
|
||||
import androidx.core.widget.NestedScrollView
|
||||
|
@ -61,6 +63,10 @@ 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) {
|
||||
cutout_short.visibility = View.VISIBLE
|
||||
cutout_short.bindToPreference(preferences.cutoutShort())
|
||||
}
|
||||
keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||
long_tap.bindToPreference(preferences.readWithLongTap())
|
||||
}
|
||||
|
|
|
@ -74,6 +74,13 @@ class SettingsReaderController : SettingsController() {
|
|||
titleRes = R.string.pref_fullscreen
|
||||
defaultValue = true
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
switchPreference {
|
||||
key = Keys.cutoutShort
|
||||
titleRes = R.string.pref_cutout_short
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.keepScreenOn
|
||||
titleRes = R.string.pref_keep_screen_on
|
||||
|
|
|
@ -125,6 +125,16 @@
|
|||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/true_color" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/cutout_short"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/pref_cutout_short"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@id/fullscreen" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/keepscreen"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -132,7 +142,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:text="@string/pref_keep_screen_on"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/fullscreen" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cutout_short" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/long_tap"
|
||||
|
|
|
@ -183,6 +183,7 @@
|
|||
|
||||
<!-- Reader section -->
|
||||
<string name="pref_fullscreen">Fullscreen</string>
|
||||
<string name="pref_cutout_short">Show content in cutout area</string>
|
||||
<string name="pref_lock_orientation">Lock orientation</string>
|
||||
<string name="pref_page_transitions">Page transitions</string>
|
||||
<string name="pref_double_tap_anim_speed">Double tap animation speed</string>
|
||||
|
|
Loading…
Reference in a new issue