pull/32/head
kunfei 5 years ago
parent 3c79168697
commit 4ca744791e
  1. 2
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt

@ -463,7 +463,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
*/ */
override fun setScreenBrightness(value: Int) { override fun setScreenBrightness(value: Int) {
var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
if (this.getPrefBoolean("brightnessAuto").not()) { if (!read_menu.brightnessAuto()) {
brightness = value.toFloat() brightness = value.toFloat()
if (brightness < 1f) brightness = 1f if (brightness < 1f) brightness = 1f
brightness /= 255f brightness /= 255f

@ -52,7 +52,7 @@ class ReadMenu : FrameLayout {
} }
private fun upBrightness() { private fun upBrightness() {
if (context.getPrefBoolean("brightnessAuto", true)) { if (brightnessAuto()) {
iv_brightness_auto.setColorFilter(context.accentColor) iv_brightness_auto.setColorFilter(context.accentColor)
seek_brightness.isEnabled = false seek_brightness.isEnabled = false
} else { } else {
@ -83,11 +83,15 @@ class ReadMenu : FrameLayout {
seek_read_page.progress = dur seek_read_page.progress = dur
} }
fun brightnessAuto(): Boolean {
return context.getPrefBoolean("brightnessAuto", true)
}
private fun bindEvent() { private fun bindEvent() {
iv_brightness_auto.onClick { iv_brightness_auto.onClick {
context.putPrefBoolean( context.putPrefBoolean(
"brightnessAuto", "brightnessAuto",
!context.getPrefBoolean("brightnessAuto", true) !brightnessAuto()
) )
upBrightness() upBrightness()
} }

Loading…
Cancel
Save