pull/2492/head
kunfei 2 years ago
parent 968c3c4d13
commit 9347ea4943
  1. 10
      app/src/main/java/io/legado/app/help/config/AppConfig.kt
  2. 29
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt

@ -34,19 +34,19 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
PreferKey.clickActionTC -> clickActionTC =
appCtx.getPrefInt(PreferKey.clickActionTC, 2)
PreferKey.clickActionTR -> clickActionTR =
appCtx.getPrefInt(PreferKey.clickActionTR, 2)
appCtx.getPrefInt(PreferKey.clickActionTR, 1)
PreferKey.clickActionML -> clickActionML =
appCtx.getPrefInt(PreferKey.clickActionML, 2)
PreferKey.clickActionMC -> clickActionMC =
appCtx.getPrefInt(PreferKey.clickActionMC, 2)
appCtx.getPrefInt(PreferKey.clickActionMC, 0)
PreferKey.clickActionMR -> clickActionMR =
appCtx.getPrefInt(PreferKey.clickActionMR, 2)
appCtx.getPrefInt(PreferKey.clickActionMR, 1)
PreferKey.clickActionBL -> clickActionBL =
appCtx.getPrefInt(PreferKey.clickActionBL, 2)
PreferKey.clickActionBC -> clickActionBC =
appCtx.getPrefInt(PreferKey.clickActionBC, 2)
appCtx.getPrefInt(PreferKey.clickActionBC, 1)
PreferKey.clickActionBR -> clickActionBR =
appCtx.getPrefInt(PreferKey.clickActionBR, 2)
appCtx.getPrefInt(PreferKey.clickActionBR, 1)
PreferKey.readBodyToLh -> ReadBookConfig.readBodyToLh =
appCtx.getPrefBoolean(PreferKey.readBodyToLh, true)
PreferKey.useZhLayout -> ReadBookConfig.useZhLayout =

@ -14,9 +14,13 @@ import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.putPrefInt
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
import splitties.init.appCtx
/**
* 点击区域设置
*/
class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_config) {
private val binding by viewBinding(DialogClickActionConfigBinding::bind)
private val actions by lazy {
@ -29,6 +33,9 @@ class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_
this[4] = getString(R.string.previous_chapter)
this[5] = getString(R.string.read_aloud_prev_paragraph)
this[6] = getString(R.string.read_aloud_next_paragraph)
this[7] = getString(R.string.bookmark_add)
this[8] = getString(R.string.edit_content)
this[9] = getString(R.string.replace_rule)
}
}
@ -57,6 +64,7 @@ class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_
tvTopCenter.text = actions[AppConfig.clickActionTC]
tvTopRight.text = actions[AppConfig.clickActionTR]
tvMiddleLeft.text = actions[AppConfig.clickActionML]
tvMiddleCenter.text = actions[AppConfig.clickActionMC]
tvMiddleRight.text = actions[AppConfig.clickActionMR]
tvBottomLeft.text = actions[AppConfig.clickActionBL]
tvBottomCenter.text = actions[AppConfig.clickActionBC]
@ -91,6 +99,12 @@ class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_
(it as? TextView)?.text = actions[action]
}
}
binding.tvMiddleCenter.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionMC, action)
(it as? TextView)?.text = actions[action]
}
}
binding.tvMiddleRight.setOnClickListener {
selectAction { action ->
putPrefInt(PreferKey.clickActionMR, action)
@ -126,4 +140,17 @@ class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_
}
}
override fun onDestroy() {
super.onDestroy()
AppConfig.run {
if (clickActionTL * clickActionTC * clickActionTR
* clickActionML * clickActionMC * clickActionMR
* clickActionBL * clickActionBC * clickActionBR != 0
) {
putPrefInt(PreferKey.clickActionMC, 0)
appCtx.toastOnUi("当前没有配置菜单区域,自动恢复中间区域为菜单.")
}
}
}
}
Loading…
Cancel
Save