添加显示亮度调节控制

pull/306/head
gedoor 4 years ago
parent e436fe785b
commit 96797c29fb
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 11
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  4. 3
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  5. 1
      app/src/main/res/values-zh-rHK/strings.xml
  6. 1
      app/src/main/res/values-zh-rTW/strings.xml
  7. 1
      app/src/main/res/values-zh/strings.xml
  8. 1
      app/src/main/res/values/strings.xml
  9. 6
      app/src/main/res/xml/pref_config_read.xml

@ -51,6 +51,7 @@ object PreferKey {
const val transparentStatusBar = "transparentStatusBar" const val transparentStatusBar = "transparentStatusBar"
const val defaultCover = "defaultCover" const val defaultCover = "defaultCover"
const val replaceEnableDefault = "replaceEnableDefault" const val replaceEnableDefault = "replaceEnableDefault"
const val showBrightnessView = "showBrightnessView"
const val cPrimary = "colorPrimary" const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent" const val cAccent = "colorAccent"

@ -819,6 +819,9 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
observeEvent<Boolean>(PreferKey.textSelectAble) { observeEvent<Boolean>(PreferKey.textSelectAble) {
page_view.curPage.upSelectAble(it) page_view.curPage.upSelectAble(it)
} }
observeEvent<String>(PreferKey.showBrightnessView) {
read_menu.upBrightnessState()
}
} }
private fun upScreenTimeOut() { private fun upScreenTimeOut() {

@ -12,6 +12,7 @@ import androidx.core.view.isVisible
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.Selector
@ -33,6 +34,7 @@ class ReadMenu : FrameLayout {
private lateinit var menuBottomOut: Animation private lateinit var menuBottomOut: Animation
private var bottomBackgroundList: ColorStateList private var bottomBackgroundList: ColorStateList
private var onMenuOutEnd: (() -> Unit)? = null private var onMenuOutEnd: (() -> Unit)? = null
val showBrightnessView get() = context.getPrefBoolean(PreferKey.showBrightnessView, true)
constructor(context: Context) : super(context) constructor(context: Context) : super(context)
@ -69,7 +71,7 @@ class ReadMenu : FrameLayout {
bindEvent() bindEvent()
} }
private fun upBrightnessState() { fun upBrightnessState() {
if (brightnessAuto()) { if (brightnessAuto()) {
iv_brightness_auto.setColorFilter(context.accentColor) iv_brightness_auto.setColorFilter(context.accentColor)
seek_brightness.isEnabled = false seek_brightness.isEnabled = false
@ -112,7 +114,7 @@ class ReadMenu : FrameLayout {
} }
private fun brightnessAuto(): Boolean { private fun brightnessAuto(): Boolean {
return context.getPrefBoolean("brightnessAuto", true) return context.getPrefBoolean("brightnessAuto", true) || !showBrightnessView
} }
private fun bindEvent() { private fun bindEvent() {
@ -210,11 +212,13 @@ class ReadMenu : FrameLayout {
} }
private fun initAnimation() { private fun initAnimation() {
//显示菜单
menuTopIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_in) menuTopIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_in)
menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in) menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in)
menuTopIn.setAnimationListener(object : Animation.AnimationListener { menuTopIn.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) { override fun onAnimationStart(animation: Animation) {
callBack?.upSystemUiVisibility() callBack?.upSystemUiVisibility()
ll_brightness.visible(showBrightnessView)
} }
override fun onAnimationEnd(animation: Animation) { override fun onAnimationEnd(animation: Animation) {
@ -234,7 +238,8 @@ class ReadMenu : FrameLayout {
//隐藏菜单 //隐藏菜单
menuTopOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_out) 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 { menuTopOut.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) { override fun onAnimationStart(animation: Animation) {
vw_menu_bg.setOnClickListener(null) vw_menu_bg.setOnClickListener(null)

@ -115,6 +115,9 @@ class MoreConfigDialog : DialogFragment() {
PreferKey.textBottomJustify -> { PreferKey.textBottomJustify -> {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
PreferKey.showBrightnessView -> {
postEvent(PreferKey.showBrightnessView, "")
}
} }
} }

@ -741,4 +741,5 @@
<string name="accent_text_diff">强调色不能和文字颜色相似</string> <string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string> <string name="wrong_format">格式不对</string>
<string name="error">错误</string> <string name="error">错误</string>
<string name="show_brightness_view">显示亮度调节控件</string>
</resources> </resources>

@ -741,5 +741,6 @@
<string name="accent_text_diff">强调色不能和文字颜色相似</string> <string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string> <string name="wrong_format">格式不对</string>
<string name="error">错误</string> <string name="error">错误</string>
<string name="show_brightness_view">显示亮度调节控件</string>
</resources> </resources>

@ -741,4 +741,5 @@
<string name="accent_text_diff">强调色不能和文字颜色相似</string> <string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string> <string name="wrong_format">格式不对</string>
<string name="error">错误</string> <string name="error">错误</string>
<string name="show_brightness_view">显示亮度调节控件</string>
</resources> </resources>

@ -742,5 +742,6 @@
<string name="accent_text_diff">强调色不能和文字颜色相似</string> <string name="accent_text_diff">强调色不能和文字颜色相似</string>
<string name="wrong_format">格式不对</string> <string name="wrong_format">格式不对</string>
<string name="error">错误</string> <string name="error">错误</string>
<string name="show_brightness_view">显示亮度调节控件</string>
</resources> </resources>

@ -84,6 +84,12 @@
android:key="selectText" android:key="selectText"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/show_brightness_view"
android:key="showBrightnessView"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.Preference <io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey" android:key="customPageKey"
android:title="@string/custom_page_key" android:title="@string/custom_page_key"

Loading…
Cancel
Save