mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01: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:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user