From 51df44085701e4b18b17e40370575498fc52af92 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 21 Jan 2022 18:17:09 +0100 Subject: [PATCH] improving the UX related to long pressing space --- .../com/simplemobiletools/keyboard/views/MyKeyboardView.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index 8cbcc02..6ebb420 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -1140,7 +1140,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mHandler!!.sendMessageDelayed(msg, REPEAT_START_DELAY.toLong()) // if the user long presses Space, move the cursor after swipine left/right if (mKeys[mCurrentKey].codes.firstOrNull() == MyKeyboard.KEYCODE_SPACE) { - mLastSpaceMoveX = touchX + mLastSpaceMoveX = -1 } else { repeatKey(true) } @@ -1181,6 +1181,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } if (mIsLongPressingSpace) { + if (mLastSpaceMoveX == -1) { + mLastSpaceMoveX = mLastX + } + val diff = mLastX - mLastSpaceMoveX if (diff < -mSpaceMoveThreshold) {