From 96797c29fbdc98072d008c6dd8b71d54f01257a2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 12 Aug 2020 22:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=BE=E7=A4=BA=E4=BA=AE?= =?UTF-8?q?=E5=BA=A6=E8=B0=83=E8=8A=82=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + .../io/legado/app/ui/book/read/ReadBookActivity.kt | 3 +++ .../main/java/io/legado/app/ui/book/read/ReadMenu.kt | 11 ++++++++--- .../app/ui/book/read/config/MoreConfigDialog.kt | 3 +++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_read.xml | 6 ++++++ 9 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 4b949fe4e..059bb0382 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -51,6 +51,7 @@ object PreferKey { const val transparentStatusBar = "transparentStatusBar" const val defaultCover = "defaultCover" const val replaceEnableDefault = "replaceEnableDefault" + const val showBrightnessView = "showBrightnessView" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 461f7598b..512d22a6f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -819,6 +819,9 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo observeEvent(PreferKey.textSelectAble) { page_view.curPage.upSelectAble(it) } + observeEvent(PreferKey.showBrightnessView) { + read_menu.upBrightnessState() + } } private fun upScreenTimeOut() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 89a30b8d1..0af320475 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -12,6 +12,7 @@ import androidx.core.view.isVisible import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus +import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.Selector @@ -33,6 +34,7 @@ class ReadMenu : FrameLayout { private lateinit var menuBottomOut: Animation private var bottomBackgroundList: ColorStateList private var onMenuOutEnd: (() -> Unit)? = null + val showBrightnessView get() = context.getPrefBoolean(PreferKey.showBrightnessView, true) constructor(context: Context) : super(context) @@ -69,7 +71,7 @@ class ReadMenu : FrameLayout { bindEvent() } - private fun upBrightnessState() { + fun upBrightnessState() { if (brightnessAuto()) { iv_brightness_auto.setColorFilter(context.accentColor) seek_brightness.isEnabled = false @@ -112,7 +114,7 @@ class ReadMenu : FrameLayout { } private fun brightnessAuto(): Boolean { - return context.getPrefBoolean("brightnessAuto", true) + return context.getPrefBoolean("brightnessAuto", true) || !showBrightnessView } private fun bindEvent() { @@ -210,11 +212,13 @@ class ReadMenu : FrameLayout { } private fun initAnimation() { + //显示菜单 menuTopIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_in) menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in) menuTopIn.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { callBack?.upSystemUiVisibility() + ll_brightness.visible(showBrightnessView) } override fun onAnimationEnd(animation: Animation) { @@ -234,7 +238,8 @@ class ReadMenu : FrameLayout { //隐藏菜单 menuTopOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_out) - menuBottomOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_out) + menuBottomOut = + AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_out) menuTopOut.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { vw_menu_bg.setOnClickListener(null) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 99e7e8421..f446681a8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -115,6 +115,9 @@ class MoreConfigDialog : DialogFragment() { PreferKey.textBottomJustify -> { postEvent(EventBus.UP_CONFIG, true) } + PreferKey.showBrightnessView -> { + postEvent(PreferKey.showBrightnessView, "") + } } } diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 68413189b..2e47d7132 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -741,4 +741,5 @@ 强调色不能和文字颜色相似 格式不对 错误 + 显示亮度调节控件 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 8e48622e5..684041caf 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -741,5 +741,6 @@ 强调色不能和文字颜色相似 格式不对 错误 + 显示亮度调节控件 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index ceed039ae..9b40b42c4 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -741,4 +741,5 @@ 强调色不能和文字颜色相似 格式不对 错误 + 显示亮度调节控件 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6475b1f22..b501e6f54 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -742,5 +742,6 @@ 强调色不能和文字颜色相似 格式不对 错误 + 显示亮度调节控件 \ No newline at end of file diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 6125aba08..35a290bdd 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -84,6 +84,12 @@ android:key="selectText" app:iconSpaceReserved="false" /> + +