diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index d381e410b..d9a1cdd26 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -463,7 +463,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea */ override fun setScreenBrightness(value: Int) { var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE - if (this.getPrefBoolean("brightnessAuto").not()) { + if (!read_menu.brightnessAuto()) { brightness = value.toFloat() if (brightness < 1f) brightness = 1f brightness /= 255f diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt index 362059afc..4afcfda10 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt @@ -52,7 +52,7 @@ class ReadMenu : FrameLayout { } private fun upBrightness() { - if (context.getPrefBoolean("brightnessAuto", true)) { + if (brightnessAuto()) { iv_brightness_auto.setColorFilter(context.accentColor) seek_brightness.isEnabled = false } else { @@ -83,11 +83,15 @@ class ReadMenu : FrameLayout { seek_read_page.progress = dur } + fun brightnessAuto(): Boolean { + return context.getPrefBoolean("brightnessAuto", true) + } + private fun bindEvent() { iv_brightness_auto.onClick { context.putPrefBoolean( "brightnessAuto", - !context.getPrefBoolean("brightnessAuto", true) + !brightnessAuto() ) upBrightness() }