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

pull/1161/head
gedoor 3 years ago
parent e0a66f0967
commit 3cc1db8516
  1. 2
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 14
      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)

@ -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