pull/480/head
gedoor 4 years ago
parent e7a0a212e2
commit c71a525de8
  1. 18
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 20
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 32
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  4. 18
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -4,15 +4,15 @@ object PreferKey {
const val language = "language" const val language = "language"
const val themeMode = "themeMode" const val themeMode = "themeMode"
const val hideStatusBar = "hideStatusBar" const val hideStatusBar = "hideStatusBar"
const val clickActionTopLeft = "clickActionTopLeft" const val clickActionTL = "clickActionTopLeft"
const val clickActionTopCenter = "clickActionTopCenter" const val clickActionTC = "clickActionTopCenter"
const val clickActionTopRight = "clickActionTopRight" const val clickActionTR = "clickActionTopRight"
const val clickActionMiddleLeft = "clickActionMiddleLeft" const val clickActionML = "clickActionMiddleLeft"
const val clickActionMiddleCenter = "clickActionMiddleCenter" const val clickActionMC = "clickActionMiddleCenter"
const val clickActionMiddleRight = "clickActionMiddleRight" const val clickActionMR = "clickActionMiddleRight"
const val clickActionBottomLeft = "clickActionBottomLeft" const val clickActionBL = "clickActionBottomLeft"
const val clickActionBottomCenter = "clickActionBottomCenter" const val clickActionBC = "clickActionBottomCenter"
const val clickActionBottomRight = "clickActionBottomRight" const val clickActionBR = "clickActionBottomRight"
const val hideNavigationBar = "hideNavigationBar" const val hideNavigationBar = "hideNavigationBar"
const val precisionSearch = "precisionSearch" const val precisionSearch = "precisionSearch"
const val speakEngine = "speakEngine" const val speakEngine = "speakEngine"

@ -137,16 +137,14 @@ object AppConfig {
val importKeepName get() = App.INSTANCE.getPrefBoolean(PreferKey.importKeepName) val importKeepName get() = App.INSTANCE.getPrefBoolean(PreferKey.importKeepName)
val clickActionTopLeft get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTopLeft, 2) val clickActionTL get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTL, 2)
val clickActionTopCenter get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTopCenter, 2) val clickActionTC get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTC, 2)
val clickActionTopRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTopRight, 1) val clickActionTR get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTR, 1)
val clickActionMiddleLeft get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMiddleLeft, 2) val clickActionML get() = App.INSTANCE.getPrefInt(PreferKey.clickActionML, 2)
val clickActionMiddleCenter val clickActionMC get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMC, 0)
get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMiddleCenter, 0) val clickActionMR get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMR, 1)
val clickActionMiddleRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMiddleRight, 1) val clickActionBL get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBL, 2)
val clickActionBottomLeft get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomLeft, 2) val clickActionBC get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBC, 1)
val clickActionBottomCenter val clickActionBR get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBR, 1)
get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomCenter, 1)
val clickActionBottomRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomRight, 1)
} }

@ -56,14 +56,14 @@ class ClickActionConfigDialog : BaseDialogFragment() {
} }
private fun initData() = with(AppConfig) { private fun initData() = with(AppConfig) {
tv_top_left.text = actions[clickActionTopLeft] tv_top_left.text = actions[clickActionTL]
tv_top_center.text = actions[clickActionTopCenter] tv_top_center.text = actions[clickActionTC]
tv_top_right.text = actions[clickActionTopRight] tv_top_right.text = actions[clickActionTR]
tv_middle_left.text = actions[clickActionMiddleLeft] tv_middle_left.text = actions[clickActionML]
tv_middle_right.text = actions[clickActionMiddleRight] tv_middle_right.text = actions[clickActionMR]
tv_bottom_left.text = actions[clickActionBottomLeft] tv_bottom_left.text = actions[clickActionBL]
tv_bottom_center.text = actions[clickActionBottomCenter] tv_bottom_center.text = actions[clickActionBC]
tv_bottom_right.text = actions[clickActionBottomRight] tv_bottom_right.text = actions[clickActionBR]
} }
private fun initViewEvent() { private fun initViewEvent() {
@ -72,49 +72,49 @@ class ClickActionConfigDialog : BaseDialogFragment() {
} }
tv_top_left.onClick { tv_top_left.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionTopLeft, action) putPrefInt(PreferKey.clickActionTL, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_top_center.onClick { tv_top_center.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionTopCenter, action) putPrefInt(PreferKey.clickActionTC, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_top_right.onClick { tv_top_right.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionTopRight, action) putPrefInt(PreferKey.clickActionTR, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_middle_left.onClick { tv_middle_left.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionMiddleLeft, action) putPrefInt(PreferKey.clickActionML, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_middle_right.onClick { tv_middle_right.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionMiddleRight, action) putPrefInt(PreferKey.clickActionMR, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_bottom_left.onClick { tv_bottom_left.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionBottomLeft, action) putPrefInt(PreferKey.clickActionBL, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_bottom_center.onClick { tv_bottom_center.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionBottomCenter, action) putPrefInt(PreferKey.clickActionBC, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }
tv_bottom_right.onClick { tv_bottom_right.onClick {
selectAction { action -> selectAction { action ->
putPrefInt(PreferKey.clickActionBottomRight, action) putPrefInt(PreferKey.clickActionBR, action)
(it as? TextView)?.text = actions[action] (it as? TextView)?.text = actions[action]
} }
} }

@ -261,31 +261,31 @@ class PageView(context: Context, attrs: AttributeSet) :
when { when {
isTextSelected -> isTextSelected = false isTextSelected -> isTextSelected = false
mcRect.contains(startX, startY) -> if (!isAbortAnim) { mcRect.contains(startX, startY) -> if (!isAbortAnim) {
click(AppConfig.clickActionMiddleCenter) click(AppConfig.clickActionMC)
} }
bcRect.contains(startX, startY) -> { bcRect.contains(startX, startY) -> {
click(AppConfig.clickActionBottomCenter) click(AppConfig.clickActionBC)
} }
blRect.contains(startX, startY) -> { blRect.contains(startX, startY) -> {
click(AppConfig.clickActionBottomLeft) click(AppConfig.clickActionBL)
} }
brRect.contains(startX, startY) -> { brRect.contains(startX, startY) -> {
click(AppConfig.clickActionBottomRight) click(AppConfig.clickActionBR)
} }
mlRect.contains(startX, startY) -> { mlRect.contains(startX, startY) -> {
click(AppConfig.clickActionMiddleLeft) click(AppConfig.clickActionML)
} }
mrRect.contains(startX, startY) -> { mrRect.contains(startX, startY) -> {
click(AppConfig.clickActionMiddleRight) click(AppConfig.clickActionMR)
} }
tlRect.contains(startX, startY) -> { tlRect.contains(startX, startY) -> {
click(AppConfig.clickActionTopLeft) click(AppConfig.clickActionTL)
} }
tcRect.contains(startX, startY) -> { tcRect.contains(startX, startY) -> {
click(AppConfig.clickActionTopCenter) click(AppConfig.clickActionTC)
} }
trRect.contains(startX, startY) -> { trRect.contains(startX, startY) -> {
click(AppConfig.clickActionTopRight) click(AppConfig.clickActionTR)
} }
} }
} }

Loading…
Cancel
Save