Skip to content

Commit f899df2

Browse files
committed
feat: change longClickDuration to 500
1 parent 49b9058 commit f899df2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/src/main/kotlin/li/songe/gkd/data/GkdAction.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ sealed class ActionPerformer(val action: String) {
124124
val p = position?.calc(rect)
125125
val x = p?.first ?: ((rect.right + rect.left) / 2f)
126126
val y = p?.second ?: ((rect.bottom + rect.top) / 2f)
127-
// 内部的 DEFAULT_LONG_PRESS_TIMEOUT 常量是 400
128-
// 而 ViewConfiguration.getLongPressTimeout() 返回 300, 这将导致触发普通的 click 事件
127+
// 500 https://cs.android.com/android/platform/superproject/+/android-8.1.0_r81:frameworks/base/core/java/android/view/ViewConfiguration.java;l=65
128+
// 400 https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/view/ViewConfiguration.java;drc=8b948e548b782592ae280a3cd9a91798afe6df9d;l=82
129+
// 某些系统的 ViewConfiguration.getLongPressTimeout() 返回 300 , 这将导致触发普通的 click 事件
130+
val longClickDuration = 500L
129131
return ActionResult(
130132
action = action,
131133
result = if (0 <= x && 0 <= y && x <= ScreenUtils.getScreenWidth() && y <= ScreenUtils.getScreenHeight()) {
132-
val result = safeLongTap(x, y, 400)
134+
val result = safeLongTap(x, y, longClickDuration)
133135
if (result != null) {
134136
return ActionResult(action, result, true, position = x to y)
135137
}
@@ -138,7 +140,7 @@ sealed class ActionPerformer(val action: String) {
138140
path.moveTo(x, y)
139141
gestureDescription.addStroke(
140142
GestureDescription.StrokeDescription(
141-
path, 0, 400L
143+
path, 0, longClickDuration
142144
)
143145
)
144146
// TODO 传入处理 callback

0 commit comments

Comments
 (0)