diff --git a/app/src/main/java/org/fcitx/fcitx5/android/data/prefs/AppPrefs.kt b/app/src/main/java/org/fcitx/fcitx5/android/data/prefs/AppPrefs.kt
index ef20c79fe..492d3057a 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/data/prefs/AppPrefs.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/data/prefs/AppPrefs.kt
@@ -62,6 +62,8 @@ class AppPrefs(private val sharedPreferences: SharedPreferences) {
"haptic_on_keyup",
false
) { hapticOnKeyPress.getValue() != InputFeedbackMode.Disabled }
+ val hapticOnRepeat = switch(R.string.haptic_on_repeat, "haptic_on_repeat", false)
+
val buttonPressVibrationMilliseconds: ManagedPreference.PInt
val buttonLongPressVibrationMilliseconds: ManagedPreference.PInt
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/BaseKeyboard.kt b/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/BaseKeyboard.kt
index fa9ef3351..9bc8045ce 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/BaseKeyboard.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/BaseKeyboard.kt
@@ -67,6 +67,8 @@ abstract class BaseKeyboard(
private val vivoKeypressWorkaround by prefs.advanced.vivoKeypressWorkaround
+ private val hapticOnRepeat by prefs.keyboard.hapticOnRepeat
+
var popupActionListener: PopupActionListener? = null
private val selectionSwipeThreshold = dp(10f)
@@ -162,7 +164,7 @@ abstract class BaseKeyboard(
swipeRepeatEnabled = true
swipeThresholdX = selectionSwipeThreshold
swipeThresholdY = disabledSwipeThreshold
- onGestureListener = OnGestureListener { _, event ->
+ onGestureListener = OnGestureListener { view, event ->
when (event.type) {
GestureType.Move -> when (val count = event.countX) {
0 -> false
@@ -172,6 +174,7 @@ abstract class BaseKeyboard(
val action = KeyAction.SymAction(KeySym(sym), KeyStates.Empty)
repeat(count.absoluteValue) {
onAction(action)
+ if (hapticOnRepeat) InputFeedbacks.hapticFeedback(view)
}
true
}
@@ -184,12 +187,13 @@ abstract class BaseKeyboard(
swipeRepeatEnabled = true
swipeThresholdX = selectionSwipeThreshold
swipeThresholdY = disabledSwipeThreshold
- onGestureListener = OnGestureListener { _, event ->
+ onGestureListener = OnGestureListener { view, event ->
when (event.type) {
GestureType.Move -> {
val count = event.countX
if (count != 0) {
onAction(KeyAction.MoveSelectionAction(count))
+ if (hapticOnRepeat) InputFeedbacks.hapticFeedback(view)
true
} else false
}
@@ -216,8 +220,9 @@ abstract class BaseKeyboard(
}
is KeyDef.Behavior.Repeat -> {
repeatEnabled = true
- onRepeatListener = { _ ->
+ onRepeatListener = { view ->
onAction(it.action)
+ if (hapticOnRepeat) InputFeedbacks.hapticFeedback(view)
}
}
is KeyDef.Behavior.Swipe -> {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 679a9a108..12bcee0a7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -283,4 +283,5 @@
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: