增强点击翻页设置

pull/473/head
gedoor 4 years ago
parent 268b23c30e
commit af12fdeca7
  1. 9
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 2
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 2
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt
  5. 33
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  6. 3
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  7. 1
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt
  8. 5
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  9. 7
      app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt
  10. 116
      app/src/main/res/layout/dialog_click_action_config.xml
  11. 2
      app/src/main/res/values-zh-rHK/strings.xml
  12. 2
      app/src/main/res/values-zh-rTW/strings.xml
  13. 2
      app/src/main/res/values-zh/strings.xml
  14. 2
      app/src/main/res/values/strings.xml
  15. 6
      app/src/main/res/xml/pref_config_read.xml

@ -6,7 +6,14 @@ object PreferKey {
const val themeMode = "themeMode" const val themeMode = "themeMode"
const val hideStatusBar = "hideStatusBar" const val hideStatusBar = "hideStatusBar"
const val clickTurnPage = "clickTurnPage" const val clickTurnPage = "clickTurnPage"
const val clickAllNext = "clickAllNext" const val clickActionTopLeft = "clickActionTopLeft"
const val clickActionTopCenter = "clickActionTopCenter"
const val clickActionTopRight = "clickActionTopRight"
const val clickActionCenterLeft = "clickActionCenterLeft"
const val clickActionCenterRight = "clickActionCenterRight"
const val clickActionBottomLeft = "clickActionBottomLeft"
const val clickActionBottomCenter = "clickActionBottomCenter"
const val clickActionBottomRight = "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"

@ -136,5 +136,7 @@ object AppConfig {
val changeSourceLoadToc get() = App.INSTANCE.getPrefBoolean(PreferKey.changeSourceLoadToc) val changeSourceLoadToc get() = App.INSTANCE.getPrefBoolean(PreferKey.changeSourceLoadToc)
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)
} }

@ -153,8 +153,6 @@ object ReadBookConfig {
App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value) App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value)
} }
} }
val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true)
val clickAllNext get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)
val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true)
val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true) val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true)
var hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) var hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar)

@ -24,6 +24,7 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.service.help.CacheBook import io.legado.app.service.help.CacheBook
import io.legado.app.service.help.ReadBook import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.config.BgTextConfigDialog import io.legado.app.ui.book.read.config.BgTextConfigDialog
import io.legado.app.ui.book.read.config.ClickActionConfigDialog
import io.legado.app.ui.book.read.config.PaddingConfigDialog import io.legado.app.ui.book.read.config.PaddingConfigDialog
import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.ui.widget.text.AutoCompleteTextView
@ -94,6 +95,10 @@ abstract class ReadBookBaseActivity :
BgTextConfigDialog().show(supportFragmentManager, "bgTextConfig") BgTextConfigDialog().show(supportFragmentManager, "bgTextConfig")
} }
fun showClickRegionalConfig() {
ClickActionConfigDialog().show(supportFragmentManager, "clickActionConfig")
}
/** /**
* 屏幕方向 * 屏幕方向
*/ */

@ -0,0 +1,33 @@
package io.legado.app.ui.book.read.config
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
class ClickActionConfigDialog : BaseDialogFragment() {
override fun onStart() {
super.onStart()
dialog?.window?.let {
it.setBackgroundDrawableResource(R.color.transparent)
it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.dialog_click_action_config, container)
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
}
}

@ -116,6 +116,9 @@ class MoreConfigDialog : DialogFragment() {
override fun onPreferenceTreeClick(preference: Preference?): Boolean { override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) { when (preference?.key) {
"customPageKey" -> PageKeyDialog(requireContext()).show() "customPageKey" -> PageKeyDialog(requireContext()).show()
"clickRegionalConfig" -> {
(activity as? ReadBookActivity)?.showClickRegionalConfig()
}
} }
return super.onPreferenceTreeClick(preference) return super.onPreferenceTreeClick(preference)
} }

@ -117,7 +117,6 @@ class ReadAloudConfigDialog : DialogFragment() {
when (preference) { when (preference) {
is ListPreference -> { is ListPreference -> {
val index = preference.findIndexOfValue(value) val index = preference.findIndexOfValue(value)
// Set the summary to reflect the new value.
preference.summary = if (index >= 0) preference.entries[index] else null preference.summary = if (index >= 0) preference.entries[index] else null
} }
else -> { else -> {

@ -10,6 +10,7 @@ import android.util.AttributeSet
import android.view.MotionEvent import android.view.MotionEvent
import android.view.ViewConfiguration import android.view.ViewConfiguration
import android.widget.FrameLayout import android.widget.FrameLayout
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.service.help.ReadBook import io.legado.app.service.help.ReadBook
@ -247,8 +248,8 @@ class PageView(context: Context, attrs: AttributeSet) :
if (!isAbortAnim) { if (!isAbortAnim) {
callBack.clickCenter() callBack.clickCenter()
} }
} else if (ReadBookConfig.clickTurnPage) { } else if (AppConfig.clickTurnPage) {
if (startX > width / 2 || ReadBookConfig.clickAllNext) { if (startX > width / 2) {
pageDelegate?.nextPageByAnim(defaultAnimationSpeed) pageDelegate?.nextPageByAnim(defaultAnimationSpeed)
} else { } else {
pageDelegate?.prevPageByAnim(defaultAnimationSpeed) pageDelegate?.prevPageByAnim(defaultAnimationSpeed)

@ -9,6 +9,7 @@ import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
@Suppress("unused")
open class StrokeTextView(context: Context, attrs: AttributeSet?) : open class StrokeTextView(context: Context, attrs: AttributeSet?) :
AppCompatTextView(context, attrs) { AppCompatTextView(context, attrs) {
@ -40,7 +41,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
.setSelectedStrokeColor(context.getCompatColor(R.color.accent)) .setSelectedStrokeColor(context.getCompatColor(R.color.accent))
.setPressedBgColor(context.getCompatColor(R.color.transparent30)) .setPressedBgColor(context.getCompatColor(R.color.transparent30))
.create() .create()
this.setTextColor( setTextColor(
Selector.colorBuild() Selector.colorBuild()
.setDefaultColor(context.getCompatColor(R.color.secondaryText)) .setDefaultColor(context.getCompatColor(R.color.secondaryText))
.setSelectedColor(context.getCompatColor(R.color.accent)) .setSelectedColor(context.getCompatColor(R.color.accent))
@ -58,7 +59,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
.setSelectedStrokeColor(context.accentColor) .setSelectedStrokeColor(context.accentColor)
.setPressedBgColor(context.getCompatColor(R.color.transparent30)) .setPressedBgColor(context.getCompatColor(R.color.transparent30))
.create() .create()
this.setTextColor( setTextColor(
Selector.colorBuild() Selector.colorBuild()
.setDefaultColor(context.getPrimaryTextColor(isLight)) .setDefaultColor(context.getPrimaryTextColor(isLight))
.setSelectedColor(context.accentColor) .setSelectedColor(context.accentColor)
@ -75,7 +76,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
.setSelectedStrokeColor(ThemeStore.accentColor(context)) .setSelectedStrokeColor(ThemeStore.accentColor(context))
.setPressedBgColor(context.getCompatColor(R.color.transparent30)) .setPressedBgColor(context.getCompatColor(R.color.transparent30))
.create() .create()
this.setTextColor( setTextColor(
Selector.colorBuild() Selector.colorBuild()
.setDefaultColor(ThemeStore.textColorSecondary(context)) .setDefaultColor(ThemeStore.textColorSecondary(context))
.setSelectedColor(ThemeStore.accentColor(context)) .setSelectedColor(ThemeStore.accentColor(context))

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="NestedWeights">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_top_left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="上一页" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_top_center"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="上一页" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_top_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="下一页" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_center_left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="上一页" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_center"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
android:text="@string/menu" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_center_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="下一页" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_bottom_left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
tools:ignore="NestedWeights"
android:layout_margin="3dp"
android:gravity="center"
tools:text="上一页" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_bottom_center"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="下一页" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/view_bottom_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="3dp"
android:gravity="center"
tools:text="下一页" />
</LinearLayout>
</LinearLayout>

@ -197,7 +197,6 @@
<string name="book"></string> <string name="book"></string>
<string name="volume_key_page">音量鍵翻頁</string> <string name="volume_key_page">音量鍵翻頁</string>
<string name="click_turn_page">點擊翻頁</string> <string name="click_turn_page">點擊翻頁</string>
<string name="click_all_next_page">點擊總是翻下一頁</string>
<string name="page_anim">翻頁動畫</string> <string name="page_anim">翻頁動畫</string>
<string name="keep_light">屏幕超時</string> <string name="keep_light">屏幕超時</string>
<string name="back">返回</string> <string name="back">返回</string>
@ -781,5 +780,6 @@
<string name="copy_url">拷贝URL</string> <string name="copy_url">拷贝URL</string>
<string name="no_book">没有书籍</string> <string name="no_book">没有书籍</string>
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string>
</resources> </resources>

@ -197,7 +197,6 @@
<string name="book"></string> <string name="book"></string>
<string name="volume_key_page">音量鍵翻頁</string> <string name="volume_key_page">音量鍵翻頁</string>
<string name="click_turn_page">點擊翻頁</string> <string name="click_turn_page">點擊翻頁</string>
<string name="click_all_next_page">點擊總是翻下一頁</string>
<string name="page_anim">翻頁動畫</string> <string name="page_anim">翻頁動畫</string>
<string name="keep_light">螢幕超時</string> <string name="keep_light">螢幕超時</string>
<string name="back">返回</string> <string name="back">返回</string>
@ -781,5 +780,6 @@
<string name="copy_url">拷贝URL</string> <string name="copy_url">拷贝URL</string>
<string name="no_book">没有书籍</string> <string name="no_book">没有书籍</string>
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string>
</resources> </resources>

@ -199,7 +199,6 @@
<string name="book"></string> <string name="book"></string>
<string name="volume_key_page">音量键翻页</string> <string name="volume_key_page">音量键翻页</string>
<string name="click_turn_page">点击翻页</string> <string name="click_turn_page">点击翻页</string>
<string name="click_all_next_page">点击总是翻下一页</string>
<string name="page_anim">翻页动画</string> <string name="page_anim">翻页动画</string>
<string name="keep_light">屏幕超时</string> <string name="keep_light">屏幕超时</string>
<string name="back">返回</string> <string name="back">返回</string>
@ -784,5 +783,6 @@
<string name="copy_url">拷贝URL</string> <string name="copy_url">拷贝URL</string>
<string name="no_book">没有书籍</string> <string name="no_book">没有书籍</string>
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string>
</resources> </resources>

@ -200,7 +200,6 @@
<string name="book">Book</string> <string name="book">Book</string>
<string name="volume_key_page">Volume keys to turn page</string> <string name="volume_key_page">Volume keys to turn page</string>
<string name="click_turn_page">Tap screen to turn page</string> <string name="click_turn_page">Tap screen to turn page</string>
<string name="click_all_next_page">Tap screen always to next page</string>
<string name="page_anim">Flip animation</string> <string name="page_anim">Flip animation</string>
<string name="keep_light">Keep screen awake</string> <string name="keep_light">Keep screen awake</string>
<string name="back">Back</string> <string name="back">Back</string>
@ -787,5 +786,6 @@
<string name="copy_url">拷贝URL</string> <string name="copy_url">拷贝URL</string>
<string name="no_book">没有书籍</string> <string name="no_book">没有书籍</string>
<string name="keep_original_name">保留原名</string> <string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string>
</resources> </resources>

@ -69,10 +69,10 @@
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:isBottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.Preference
android:defaultValue="false" android:defaultValue="false"
android:title="@string/click_all_next_page" android:title="@string/click_regional_config"
android:key="clickAllNext" android:key="clickRegionalConfig"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:isBottomBackground="true" /> app:isBottomBackground="true" />

Loading…
Cancel
Save