mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +01:00
Added an option to change the notch mode
Option is enabled (not greyed out) in Reader settings only when a mobile supports notch. Default option is to NOT use the notch area on horizontal view. Also added polish translation to already fixed polish translation file.
This commit is contained in:
parent
5f862f0ed8
commit
bcec01c48b
@ -19,6 +19,8 @@ object PreferenceKeys {
|
||||
|
||||
const val fullscreen = "fullscreen"
|
||||
|
||||
const val isDefaultNotchMode = "pref_notch_mode"
|
||||
|
||||
const val keepScreenOn = "pref_keep_screen_on_key"
|
||||
|
||||
const val customBrightness = "pref_custom_brightness_key"
|
||||
|
@ -72,6 +72,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true)
|
||||
|
||||
fun notchDefaultCutoutMode() = rxPrefs.getBoolean(Keys.isDefaultNotchMode, false)
|
||||
|
||||
fun keepScreenOn() = rxPrefs.getBoolean(Keys.keepScreenOn, true)
|
||||
|
||||
fun customBrightness() = rxPrefs.getBoolean(Keys.customBrightness, false)
|
||||
|
@ -11,12 +11,7 @@ import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.*
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.SeekBar
|
||||
@ -34,9 +29,7 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||
import eu.kanade.tachiyomi.ui.main.BiometricActivity
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.AddToLibraryFirst
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Error
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Success
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.*
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
@ -45,11 +38,11 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.L2RPagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.GLUtil
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
@ -67,7 +60,7 @@ import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
|
||||
@ -692,6 +685,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
||||
|
||||
subscriptions += preferences.colorFilterMode().asObservable()
|
||||
.subscribe { setColorFilter(preferences.colorFilter().getOrDefault()) }
|
||||
|
||||
subscriptions += preferences.notchDefaultCutoutMode().asObservable()
|
||||
.subscribe { setNotchCutoutMode(preferences.notchDefaultCutoutMode().getOrDefault()) }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -804,6 +801,26 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets notch cutout mode to "DEFAULT" mode if true and "NEVER" mode if false.
|
||||
* In "NEVER" mode the space next to the notch won't be used and filled with a black background.
|
||||
*/
|
||||
private fun setNotchCutoutMode(isDefault: Boolean) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
if (!isDefault) {
|
||||
val currentOrientation = resources.configuration.orientation
|
||||
|
||||
if(currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
val params = window.attributes
|
||||
params.layoutInDisplayCutoutMode =
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brightness of the screen. Range is [-75, 100].
|
||||
* From -75 to -1 a semi-transparent black view is overlaid with the minimum brightness.
|
||||
|
@ -87,6 +87,19 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
val cutout = activity?.window?.decorView?.rootWindowInsets?.displayCutout
|
||||
|
||||
switchPreference {
|
||||
key = Keys.isDefaultNotchMode
|
||||
titleRes = R.string.pref_notch_display
|
||||
summaryRes = R.string.pref_notch_display_summary
|
||||
defaultValue = false
|
||||
isEnabled = cutout != null // display option only when a mobile has a notch
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pager_viewer
|
||||
|
||||
|
@ -215,6 +215,8 @@
|
||||
<string name="pref_double_tap_anim_speed">Szybkość podwójnego stuknięcia</string>
|
||||
<string name="pref_show_page_number">Pokazuj numer strony</string>
|
||||
<string name="pref_true_color">Kolor 32 bitowy</string>
|
||||
<string name="pref_notch_display">Użyj przestrzeni sąsiadującej z notchem</string>
|
||||
<string name="pref_notch_display_summary">Działa tylko w widoku horyzontalnym, tak by notch nachodził na wyświetlaną stronę</string>
|
||||
<string name="pref_crop_borders">Przycinaj krawędzie</string>
|
||||
<string name="pref_custom_brightness">Niestandardowa jasność</string>
|
||||
<string name="pref_custom_color_filter">Niestandardowy filtr kolorów</string>
|
||||
|
@ -216,6 +216,8 @@
|
||||
<string name="pref_double_tap_anim_speed">Double tap animation speed</string>
|
||||
<string name="pref_show_page_number">Show page number</string>
|
||||
<string name="pref_true_color">32-bit color</string>
|
||||
<string name="pref_notch_display">Use space next to the notch</string>
|
||||
<string name="pref_notch_display_summary">Works only for the landscape view for the notch to overlap the displayed page</string>
|
||||
<string name="pref_crop_borders">Crop borders</string>
|
||||
<string name="pref_custom_brightness">Use custom brightness</string>
|
||||
<string name="pref_custom_color_filter">Use custom color filter</string>
|
||||
|
Loading…
Reference in New Issue
Block a user