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 } })