增强点击翻页设置

pull/473/head
gedoor 4 years ago
parent 0b6249b9a7
commit fc1c64f06b
  1. 5
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 18
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 81
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  4. 18
      app/src/main/res/layout/dialog_click_action_config.xml
  5. 2
      app/src/main/res/values-zh-rHK/strings.xml
  6. 2
      app/src/main/res/values-zh-rTW/strings.xml
  7. 2
      app/src/main/res/values-zh/strings.xml
  8. 2
      app/src/main/res/values/strings.xml

@ -9,8 +9,9 @@ object PreferKey {
const val clickActionTopLeft = "clickActionTopLeft" const val clickActionTopLeft = "clickActionTopLeft"
const val clickActionTopCenter = "clickActionTopCenter" const val clickActionTopCenter = "clickActionTopCenter"
const val clickActionTopRight = "clickActionTopRight" const val clickActionTopRight = "clickActionTopRight"
const val clickActionCenterLeft = "clickActionCenterLeft" const val clickActionMiddleLeft = "clickActionMiddleLeft"
const val clickActionCenterRight = "clickActionCenterRight" const val clickActionMiddleCenter = "clickActionMiddleCenter"
const val clickActionMiddleRight = "clickActionMiddleRight"
const val clickActionBottomLeft = "clickActionBottomLeft" const val clickActionBottomLeft = "clickActionBottomLeft"
const val clickActionBottomCenter = "clickActionBottomCenter" const val clickActionBottomCenter = "clickActionBottomCenter"
const val clickActionBottomRight = "clickActionBottomRight" const val clickActionBottomRight = "clickActionBottomRight"

@ -138,5 +138,23 @@ object AppConfig {
val importKeepName get() = App.INSTANCE.getPrefBoolean(PreferKey.importKeepName) val importKeepName get() = App.INSTANCE.getPrefBoolean(PreferKey.importKeepName)
val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) 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
)
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
)
val clickActionBottomRight get() = App.INSTANCE.getPrefInt(PreferKey.clickActionBottomRight, 1)
} }

@ -7,8 +7,12 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.putPrefInt
import kotlinx.android.synthetic.main.dialog_click_action_config.* import kotlinx.android.synthetic.main.dialog_click_action_config.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
@ -38,10 +42,87 @@ class ClickActionConfigDialog : BaseDialogFragment() {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
view.setBackgroundColor(getCompatColor(R.color.translucent)) view.setBackgroundColor(getCompatColor(R.color.translucent))
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)
}
}
private fun initViewEvent() {
iv_close.onClick { iv_close.onClick {
dismiss() dismiss()
} }
tv_top_left.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionTopLeft, action)
}
}
tv_top_center.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionTopCenter, action)
}
}
tv_top_right.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionTopRight, action)
}
}
tv_middle_left.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionMiddleLeft, action)
}
}
tv_middle_right.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionMiddleRight, action)
}
}
tv_bottom_left.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionBottomLeft, action)
}
}
tv_bottom_center.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionBottomCenter, action)
}
}
tv_bottom_right.onClick {
selectAction { action ->
putPrefInt(PreferKey.clickActionBottomRight, 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
) { _, index ->
success.invoke(index)
}
}
} }

@ -47,7 +47,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/view_top_left" android:id="@+id/tv_top_left"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -58,7 +58,7 @@
tools:text="上一页" /> tools:text="上一页" />
<TextView <TextView
android:id="@+id/view_top_center" android:id="@+id/tv_top_center"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -69,7 +69,7 @@
tools:text="上一页" /> tools:text="上一页" />
<TextView <TextView
android:id="@+id/view_top_right" android:id="@+id/tv_top_right"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -88,7 +88,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/view_center_left" android:id="@+id/tv_middle_left"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -99,7 +99,7 @@
tools:text="上一页" /> tools:text="上一页" />
<TextView <TextView
android:id="@+id/view_center" android:id="@+id/tv_middle_center"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -110,7 +110,7 @@
android:textColor="@color/white" /> android:textColor="@color/white" />
<TextView <TextView
android:id="@+id/view_center_right" android:id="@+id/tv_middle_right"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -129,7 +129,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/view_bottom_left" android:id="@+id/tv_bottom_left"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -141,7 +141,7 @@
tools:text="上一页" /> tools:text="上一页" />
<TextView <TextView
android:id="@+id/view_bottom_center" android:id="@+id/tv_bottom_center"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"
@ -152,7 +152,7 @@
tools:text="下一页" /> tools:text="下一页" />
<TextView <TextView
android:id="@+id/view_bottom_right" android:id="@+id/tv_bottom_right"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="3dp" android:layout_margin="3dp"

@ -782,5 +782,7 @@
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string> <string name="click_regional_config">点击区域设置</string>
<string name="colse">关闭</string> <string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
</resources> </resources>

@ -782,5 +782,7 @@
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string> <string name="click_regional_config">点击区域设置</string>
<string name="colse">关闭</string> <string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
</resources> </resources>

@ -785,5 +785,7 @@
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string> <string name="click_regional_config">点击区域设置</string>
<string name="colse">关闭</string> <string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
</resources> </resources>

@ -788,5 +788,7 @@
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string> <string name="click_regional_config">点击区域设置</string>
<string name="colse">关闭</string> <string name="colse">关闭</string>
<string name="next_page">下一页</string>
<string name="prev_page">上一页</string>
</resources> </resources>

Loading…
Cancel
Save