diff --git a/app/src/main/java/com/osfans/trime/ime/keyboard/GestureFrame.kt b/app/src/main/java/com/osfans/trime/ime/keyboard/GestureFrame.kt index cd594547f6..4eb5e33adf 100644 --- a/app/src/main/java/com/osfans/trime/ime/keyboard/GestureFrame.kt +++ b/app/src/main/java/com/osfans/trime/ime/keyboard/GestureFrame.kt @@ -38,7 +38,7 @@ open class GestureFrame(context: Context) : FrameLayout(context) { private var longPressJob: Job? = null @Volatile - var longPressFeedbackEnabled = false + var longPressFeedbackEnabled = true @Volatile private var swipeTriggered = false @@ -105,10 +105,10 @@ open class GestureFrame(context: Context) : FrameLayout(context) { delay(longPressTimeout.toLong()) if (touchId != currentTouchId) return@launch if (!(swipeTriggered || longPressTriggered || shouldPerformSwipe)) { - if (longPressFeedbackEnabled) { + longPressTriggered = performLongClick() + if (longPressFeedbackEnabled && longPressTriggered) { InputFeedbackManager.keyPressVibrate(this@GestureFrame, true) } - longPressTriggered = performLongClick() } } swipeStartX = x diff --git a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardGestureFrame.kt b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardGestureFrame.kt index bea63094e6..3dcb5bba0a 100644 --- a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardGestureFrame.kt +++ b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardGestureFrame.kt @@ -177,7 +177,7 @@ open class KeyboardGestureFrame(context: Context) : FrameLayout(context) { if (state.isLongPressed) { onPopupSelected?.invoke(keyIndex) - deactivateKeyFeedback(keyIndex) + deactivateKeyFeedback(keyIndex, KeyBehavior.LONG_CLICK) return true } @@ -250,13 +250,16 @@ open class KeyboardGestureFrame(context: Context) : FrameLayout(context) { val keyIndex = state.keyIndex state.longPressJob = lifecycleScope.launch { delay(longPressTimeout.toLong()) - if (activePointers.get(pointerId) != state || state.shouldPerformSwipe) return@launch + if (activePointers.get(pointerId) != state || state.shouldPerformSwipe || state.slideActivated) return@launch state.isLongPressed = true if (isKeyRepeatable(keyIndex)) { onKeyActionListener?.invoke(keyIndex, KeyBehavior.CLICK) launchRepeatClickJob(pointerId, state) } else { - if (onKeyActionListener?.invoke(keyIndex, KeyBehavior.LONG_CLICK) == true) deactivateKeyFeedback(keyIndex) + if (onKeyActionListener?.invoke(keyIndex, KeyBehavior.LONG_CLICK) == true) { + deactivateKeyFeedback(keyIndex, KeyBehavior.LONG_CLICK) + activePointers.delete(pointerId) + } } } } @@ -307,8 +310,8 @@ open class KeyboardGestureFrame(context: Context) : FrameLayout(context) { onKeyStateListener?.invoke(keyIndex, behavior, true, false, false) } - private fun deactivateKeyFeedback(keyIndex: Int) { - onKeyStateListener?.invoke(keyIndex, KeyBehavior.CLICK, false, false, false) + private fun deactivateKeyFeedback(keyIndex: Int, behavior: KeyBehavior = KeyBehavior.CLICK) { + onKeyStateListener?.invoke(keyIndex, behavior, false, false, false) } private val touchPaint by lazy { diff --git a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt index cb3cc8155c..837e7152f6 100644 --- a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt +++ b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt @@ -114,6 +114,7 @@ class KeyboardView( onKeyActionListener = { keyIndex, behavior -> if (behavior == KeyBehavior.LONG_CLICK && hasPopupKeys(keyIndex)) { + keyboardActionListener?.onPress(keyIndex, false) val popupKeys = mKeys.get(keyIndex).popup val bounds = getKeyBounds(keyIndex) popupActionListener.onPopupAction( @@ -172,7 +173,7 @@ class KeyboardView( key?.onReleased() invalidateKey(key) hidePopup(keyIndex) - if (vibrateOnKeyRelease) keyboardActionListener?.onPress(keyIndex, false) + if (behavior == KeyBehavior.LONG_CLICK || vibrateOnKeyRelease) keyboardActionListener?.onPress(keyIndex, false) } } }