阅读亮度手动条件分别记住白天和夜间模式

pull/1161/head
gedoor 3 years ago
parent e0a66f0967
commit 3cc1db8516
  1. 2
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 16
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt

@ -80,6 +80,8 @@ object PreferKey {
const val useZhLayout = "useZhLayout" const val useZhLayout = "useZhLayout"
const val fullScreenGesturesSupport = "fullScreenGesturesSupport" const val fullScreenGesturesSupport = "fullScreenGesturesSupport"
const val highBrush = "highBrush" const val highBrush = "highBrush"
const val brightness = "brightness"
const val nightBrightness = "nightBrightness"
const val cPrimary = "colorPrimary" const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent" const val cAccent = "colorAccent"

@ -79,6 +79,20 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefBoolean(PreferKey.showUnread, value) 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 val useDefaultCover: Boolean
get() = appCtx.getPrefBoolean(PreferKey.useDefaultCover, false) get() = appCtx.getPrefBoolean(PreferKey.useDefaultCover, false)
@ -232,7 +246,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val ua = appCtx.getPrefString(PreferKey.userAgent) val ua = appCtx.getPrefString(PreferKey.userAgent)
if (ua.isNullOrBlank()) { 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 "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 return ua
} }
} }

@ -85,7 +85,7 @@ class ReadMenu @JvmOverloads constructor(
vwBg.setOnClickListener(null) vwBg.setOnClickListener(null)
vwNavigationBar.setOnClickListener(null) vwNavigationBar.setOnClickListener(null)
llBrightness.setOnClickListener(null) llBrightness.setOnClickListener(null)
seekBrightness.progress = context.getPrefInt("brightness", 100) seekBrightness.progress = AppConfig.readBrightness
} }
fun upBrightnessState() { fun upBrightnessState() {
@ -96,7 +96,7 @@ class ReadMenu @JvmOverloads constructor(
binding.ivBrightnessAuto.setColorFilter(context.buttonDisabledColor) binding.ivBrightnessAuto.setColorFilter(context.buttonDisabledColor)
binding.seekBrightness.isEnabled = true 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) { override fun onStopTrackingTouch(seekBar: SeekBar) {
context.putPrefInt("brightness", seekBar.progress) AppConfig.readBrightness = seekBar.progress
} }
}) })

Loading…
Cancel
Save