From 4ca744791ebb7add5058048cdc7d6016a3a232d8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Sep 2019 22:18:08 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/readbook/ReadBookActivity.kt | 2 +- app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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() }