diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt
index c91bed15d..ded6d3efb 100644
--- a/app/src/main/java/io/legado/app/constant/PreferKey.kt
+++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt
@@ -108,6 +108,7 @@ object PreferKey {
const val welcomeShowTextDark = "welcomeShowTextDark"
const val welcomeShowIcon = "welcomeShowIcon"
const val welcomeShowIconDark = "welcomeShowIconDark"
+ const val pageTouchSlop = "pageTouchSlop"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"
diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt
index 8be6ccd4f..81d15e3fe 100644
--- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt
+++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt
@@ -321,6 +321,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefString("searchGroup", value)
}
+ var pageTouchSlop: Int
+ get() = appCtx.getPrefInt(PreferKey.pageTouchSlop, 0)
+ set(value) {
+ appCtx.putPrefInt(PreferKey.pageTouchSlop, value)
+ }
+
private fun getPrefUserAgent(): String {
val ua = appCtx.getPrefString(PreferKey.userAgent)
if (ua.isNullOrBlank()) {
diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
index 55b9356c2..60ef6b29b 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
@@ -53,6 +53,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
val defaultAnimationSpeed = 300
private var pressDown = false
private var isMove = false
+ private var isPageMove = false
//起始点
var startX: Float = 0f
@@ -81,6 +82,13 @@ class ReadView(context: Context, attrs: AttributeSet) :
private val initialTextPos = TextPos(0, 0, 0)
val slopSquare by lazy { ViewConfiguration.get(context).scaledTouchSlop }
+ val pageSlopSquare by lazy {
+ if (AppConfig.pageTouchSlop == 0) {
+ slopSquare
+ } else {
+ AppConfig.pageTouchSlop
+ }
+ }
private val tlRect = RectF()
private val tcRect = RectF()
private val trRect = RectF()
@@ -188,6 +196,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
postDelayed(longPressRunnable, longPressTimeout)
pressDown = true
isMove = false
+ isPageMove = false
pageDelegate?.onTouch(event)
pageDelegate?.onDown()
setStartPoint(event.x, event.y)
@@ -197,12 +206,16 @@ class ReadView(context: Context, attrs: AttributeSet) :
isMove =
abs(startX - event.x) > slopSquare || abs(startY - event.y) > slopSquare
}
+ if (!isPageMove) {
+ isPageMove =
+ abs(startX - event.x) > pageSlopSquare || abs(startY - event.y) > pageSlopSquare
+ }
if (isMove) {
longPressed = false
removeCallbacks(longPressRunnable)
if (isTextSelected) {
selectText(event.x, event.y)
- } else {
+ } else if (isPageMove) {
pageDelegate?.onTouch(event)
}
}
@@ -212,7 +225,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
removeCallbacks(longPressRunnable)
if (!pressDown) return true
pressDown = false
- if (!isMove) {
+ if (!isPageMove) {
if (!longPressed && !pressOnTextSelected) {
onSingleTapUp()
return true
@@ -220,7 +233,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
}
if (isTextSelected) {
callBack.showTextActionMenu()
- } else if (isMove) {
+ } else if (isPageMove) {
pageDelegate?.onTouch(event)
}
pressOnTextSelected = false
@@ -231,7 +244,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
pressDown = false
if (isTextSelected) {
callBack.showTextActionMenu()
- } else if (isMove) {
+ } else if (isPageMove) {
pageDelegate?.onTouch(event)
}
pressOnTextSelected = false
@@ -283,6 +296,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
kotlin.runCatching {
curPage.longPress(startX, startY) { relativePos, lineIndex, charIndex ->
isTextSelected = true
+ pressOnTextSelected = true
initialTextPos.upData(relativePos, lineIndex, charIndex)
val startPos = TextPos(relativePos, lineIndex, charIndex)
val endPos = TextPos(relativePos, lineIndex, charIndex)
@@ -357,7 +371,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
*/
private fun onSingleTapUp() {
when {
- isTextSelected -> isTextSelected = false
+ isTextSelected -> Unit
mcRect.contains(startX, startY) -> if (!isAbortAnim) {
click(AppConfig.clickActionMC)
}
diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt
index 471006247..d054c31e6 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt
@@ -11,6 +11,7 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
protected var curBitmap: Bitmap? = null
protected var prevBitmap: Bitmap? = null
protected var nextBitmap: Bitmap? = null
+ protected val slopSquare by lazy { readView.slopSquare * readView.slopSquare }
override fun setDirection(direction: PageDirection) {
super.setDirection(direction)
@@ -71,7 +72,7 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
val deltaX = (focusX - startX).toInt()
val deltaY = (focusY - startY).toInt()
val distance = deltaX * deltaX + deltaY * deltaY
- isMoved = distance > readView.slopSquare
+ isMoved = distance > slopSquare
if (isMoved) {
if (sumX - startX > 0) {
//如果上一页不存在
diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
index 9f9f9e038..e2b311262 100644
--- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
@@ -6,6 +6,7 @@ import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.View
+import android.view.ViewConfiguration
import androidx.core.view.postDelayed
import androidx.fragment.app.activityViewModels
import androidx.preference.ListPreference
@@ -42,6 +43,7 @@ class OtherConfigFragment : PreferenceFragment(),
AppConfig.defaultBookTreeUri = treeUri.toString()
}
}
+ private val slopSquare by lazy { ViewConfiguration.get(context).scaledTouchSlop }
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
@@ -58,6 +60,7 @@ class OtherConfigFragment : PreferenceFragment(),
}
upPreferenceSummary(PreferKey.checkSource, CheckSource.summary)
upPreferenceSummary(PreferKey.bitmapCacheSize, AppConfig.bitmapCacheSize.toString())
+ upPreferenceSummary(PreferKey.pageTouchSlop, slopSquare.toString())
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -117,6 +120,16 @@ class OtherConfigFragment : PreferenceFragment(),
ImageProvider.bitmapLruCache.resize(ImageProvider.cacheSize)
}
}
+ PreferKey.pageTouchSlop -> {
+ NumberPickerDialog(requireContext())
+ .setTitle(getString(R.string.page_touch_slop_dialog_title))
+ .setMaxValue(9999)
+ .setMinValue(0)
+ .setValue(AppConfig.pageTouchSlop)
+ .show {
+ AppConfig.pageTouchSlop = it
+ }
+ }
}
return super.onPreferenceTreeClick(preference)
}
@@ -168,6 +181,7 @@ class OtherConfigFragment : PreferenceFragment(),
PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value)
PreferKey.webPort -> preference.summary = getString(R.string.web_port_summary, value)
PreferKey.bitmapCacheSize -> preference.summary = getString(R.string.bitmap_cache_size_summary, value)
+ PreferKey.pageTouchSlop -> preference.summary = getString(R.string.page_touch_slop_summary, value)
else -> if (preference is ListPreference) {
val index = preference.findIndexOfValue(value)
// Set the summary to reflect the new value.
diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml
index 745eeedba..da84ae19f 100644
--- a/app/src/main/res/values-es-rES/strings.xml
+++ b/app/src/main/res/values-es-rES/strings.xml
@@ -1003,4 +1003,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml
index 0b8f25f64..5abffefef 100644
--- a/app/src/main/res/values-ja-rJP/strings.xml
+++ b/app/src/main/res/values-ja-rJP/strings.xml
@@ -1006,4 +1006,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 2330320d8..c408ab7a6 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -1006,4 +1006,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 0f79c0a58..80a3df2fa 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -1003,4 +1003,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 23fbac7a8..b6375b7bb 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -1005,4 +1005,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 2128c5fba..58bc32cf2 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -1005,4 +1005,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bde301b76..1be2b90dd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1006,4 +1006,7 @@
阅读时间排序
阅读时长:
最后阅读时间:
+ 滑动翻页阈值
+ 滑动翻页阈值(0 = 系统默认值)
+ 滑动多长距离才会触发滑动翻页(系统默认值 %s px)
diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml
index 8da45d5a6..033d88ad1 100644
--- a/app/src/main/res/xml/pref_config_other.xml
+++ b/app/src/main/res/xml/pref_config_other.xml
@@ -128,6 +128,12 @@
android:title="@string/threads_num_title"
app:iconSpaceReserved="false" />
+
+