From 3cc1db85168c12841211d4f89408010809807bae Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 23 Jul 2021 13:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=85=E8=AF=BB=E4=BA=AE=E5=BA=A6=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E4=BB=B6=E5=88=86=E5=88=AB=E8=AE=B0=E4=BD=8F?= =?UTF-8?q?=E7=99=BD=E5=A4=A9=E5=92=8C=E5=A4=9C=E9=97=B4=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 2 ++ .../main/java/io/legado/app/help/AppConfig.kt | 16 +++++++++++++++- .../java/io/legado/app/ui/book/read/ReadMenu.kt | 6 +++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 30f96e2b0..cc1a23bb6 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -80,6 +80,8 @@ object PreferKey { const val useZhLayout = "useZhLayout" const val fullScreenGesturesSupport = "fullScreenGesturesSupport" const val highBrush = "highBrush" + const val brightness = "brightness" + const val nightBrightness = "nightBrightness" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 97a43f359..01b02eac5 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -79,6 +79,20 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { appCtx.putPrefBoolean(PreferKey.showUnread, value) } + var readBrightness: Int + get() = if (isNightTheme) { + appCtx.getPrefInt(PreferKey.nightBrightness, 100) + } else { + appCtx.getPrefInt(PreferKey.brightness, 100) + } + set(value) { + if (isNightTheme) { + appCtx.putPrefInt(PreferKey.nightBrightness, value) + } else { + appCtx.putPrefInt(PreferKey.brightness, value) + } + } + val useDefaultCover: Boolean get() = appCtx.getPrefBoolean(PreferKey.useDefaultCover, false) @@ -232,7 +246,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val ua = appCtx.getPrefString(PreferKey.userAgent) if (ua.isNullOrBlank()) { return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" - } + } return ua } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 671b7ba5d..9b0cee69d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -85,7 +85,7 @@ class ReadMenu @JvmOverloads constructor( vwBg.setOnClickListener(null) vwNavigationBar.setOnClickListener(null) llBrightness.setOnClickListener(null) - seekBrightness.progress = context.getPrefInt("brightness", 100) + seekBrightness.progress = AppConfig.readBrightness } fun upBrightnessState() { @@ -96,7 +96,7 @@ class ReadMenu @JvmOverloads constructor( binding.ivBrightnessAuto.setColorFilter(context.buttonDisabledColor) binding.seekBrightness.isEnabled = true } - setScreenBrightness(context.getPrefInt("brightness", 100)) + setScreenBrightness(AppConfig.readBrightness) } /** @@ -156,7 +156,7 @@ class ReadMenu @JvmOverloads constructor( } override fun onStopTrackingTouch(seekBar: SeekBar) { - context.putPrefInt("brightness", seekBar.progress) + AppConfig.readBrightness = seekBar.progress } })