Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
Loading