pull/475/head
gedoor 4 years ago
parent 93f54e7018
commit 680e2cb4c8
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 12
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 55
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.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. 7
      app/src/main/res/xml/pref_config_read.xml

@ -5,7 +5,6 @@ object PreferKey {
const val language = "language"
const val themeMode = "themeMode"
const val hideStatusBar = "hideStatusBar"
const val clickTurnPage = "clickTurnPage"
const val clickActionTopLeft = "clickActionTopLeft"
const val clickActionTopCenter = "clickActionTopCenter"
const val clickActionTopRight = "clickActionTopRight"

@ -137,24 +137,16 @@ object AppConfig {
val importKeepName get() = App.INSTANCE.getPrefBoolean(PreferKey.importKeepName)
val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true)
val clickActionTopLeft get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTopLeft, 2)
val clickActionTopCenter get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTopCenter, 2)
val clickActionTopRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionTopRight, 1)
val clickActionMiddleLeft get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMiddleLeft, 2)
val clickActionMiddleCenter
get() = App.INSTANCE.getPrefInt(
PreferKey.clickActionMiddleCenter,
0
)
get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMiddleCenter, 0)
val clickActionMiddleRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionMiddleRight, 1)
val clickActionBottomLeft get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomLeft, 2)
val clickActionBottomCenter
get() = App.INSTANCE.getPrefInt(
PreferKey.clickActionBottomCenter,
1
)
get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomCenter, 1)
val clickActionBottomRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomRight, 1)
}

@ -19,6 +19,8 @@ import org.jetbrains.anko.sdk27.listeners.onClick
class ClickActionConfigDialog : BaseDialogFragment() {
private val actions = linkedMapOf<Int, String>()
override fun onStart() {
super.onStart()
(activity as ReadBookActivity).bottomDialog++
@ -43,27 +45,23 @@ class ClickActionConfigDialog : BaseDialogFragment() {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
view.setBackgroundColor(getCompatColor(R.color.translucent))
actions[-1] = getString(R.string.non_action)
actions[0] = getString(R.string.menu)
actions[1] = getString(R.string.next_page)
actions[2] = getString(R.string.prev_page)
initData()
initViewEvent()
}
private fun initData() = with(AppConfig) {
tv_top_left.text = getActionString(clickActionTopLeft)
tv_top_center.text = getActionString(clickActionTopCenter)
tv_top_right.text = getActionString(clickActionTopRight)
tv_middle_left.text = getActionString(clickActionMiddleLeft)
tv_middle_right.text = getActionString(clickActionMiddleRight)
tv_bottom_left.text = getActionString(clickActionBottomLeft)
tv_bottom_center.text = getActionString(clickActionBottomCenter)
tv_bottom_right.text = getActionString(clickActionBottomRight)
}
private fun getActionString(action: Int): String {
return when (action) {
0 -> getString(R.string.menu)
2 -> getString(R.string.prev_page)
else -> getString(R.string.next_page)
}
tv_top_left.text = actions[clickActionTopLeft]
tv_top_center.text = actions[clickActionTopCenter]
tv_top_right.text = actions[clickActionTopRight]
tv_middle_left.text = actions[clickActionMiddleLeft]
tv_middle_right.text = actions[clickActionMiddleRight]
tv_bottom_left.text = actions[clickActionBottomLeft]
tv_bottom_center.text = actions[clickActionBottomCenter]
tv_bottom_right.text = actions[clickActionBottomRight]
}
private fun initViewEvent() {
@ -73,64 +71,59 @@ class ClickActionConfigDialog : BaseDialogFragment() {
tv_top_left.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionTopLeft, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_top_center.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionTopCenter, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_top_right.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionTopRight, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_middle_left.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionMiddleLeft, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_middle_right.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionMiddleRight, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_bottom_left.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionBottomLeft, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_bottom_center.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionBottomCenter, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
tv_bottom_right.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionBottomRight, action)
(it as? TextView)?.text = getActionString(action)
(it as? TextView)?.text = actions[action]
}
}
}
private fun selectAction(success: (action: Int) -> Unit) {
val actions = arrayListOf(
getString(R.string.menu),
getString(R.string.next_page),
getString(R.string.prev_page)
)
selector(
getString(R.string.select_action),
actions
actions.values.toList()
) { _, index ->
success.invoke(index)
success.invoke(actions.keys.toList()[index])
}
}

@ -295,12 +295,8 @@ class PageView(context: Context, attrs: AttributeSet) :
private fun click(action: Int) {
when (action) {
0 -> callBack.showActionMenu()
1 -> if (AppConfig.clickTurnPage) {
pageDelegate?.nextPageByAnim(defaultAnimationSpeed)
}
2 -> if (AppConfig.clickTurnPage) {
pageDelegate?.prevPageByAnim(defaultAnimationSpeed)
}
1 -> pageDelegate?.nextPageByAnim(defaultAnimationSpeed)
2 -> pageDelegate?.prevPageByAnim(defaultAnimationSpeed)
}
}

@ -784,5 +784,6 @@
<string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
<string name="non_action">无操作</string>
</resources>

@ -784,5 +784,6 @@
<string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
<string name="non_action">无操作</string>
</resources>

@ -787,5 +787,6 @@
<string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
<string name="non_action">无操作</string>
</resources>

@ -790,5 +790,6 @@
<string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
<string name="non_action">无操作</string>
</resources>

@ -62,13 +62,6 @@
app:iconSpaceReserved="false"
app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/click_turn_page"
android:key="clickTurnPage"
app:iconSpaceReserved="false"
app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/volume_key_page_on_play"

Loading…
Cancel
Save