From e0fa3fd919c24c4140cfd3484b1524ad42c10af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 31 Aug 2023 13:36:39 +0200 Subject: [PATCH] Ensure no multiple capital letters appear without using delay This fixes the issue of capitalizing two letters when SHIFT is active, but it does not use delay. It instead always updates shift state right right after a key press, to ensure it is in the right state as soon as next key is typed. This removes the delay added in #210. --- .../keyboard/services/SimpleKeyboardIME.kt | 5 ++--- .../keyboard/views/MyKeyboardView.kt | 12 +++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt index e1212e9..7f3d81f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -260,14 +260,13 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } } inputConnection.commitText(codeChar.toString(), 1) + updateShiftKeyState() } } else -> { inputConnection.commitText(codeChar.toString(), 1) - if (originalText == null) { - updateShiftKeyState() - } + updateShiftKeyState() } } } 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 d164f89..d37e517 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -1218,14 +1218,12 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val secondKeyIndex = getPressedKeyIndex(newPointerX, newPointerY) showPreview(secondKeyIndex) - mHandler!!.postDelayed({ - detectAndSendKey(secondKeyIndex, newPointerX, newPointerY, eventTime) + detectAndSendKey(secondKeyIndex, newPointerX, newPointerY, eventTime) - val secondKeyCode = mKeys.getOrNull(secondKeyIndex)?.code - if (secondKeyCode != null) { - mOnKeyboardActionListener!!.onPress(secondKeyCode) - } - }, REPEAT_INTERVAL.toLong()) + val secondKeyCode = mKeys.getOrNull(secondKeyIndex)?.code + if (secondKeyCode != null) { + mOnKeyboardActionListener!!.onPress(secondKeyCode) + } showPreview(NOT_A_KEY) invalidateKey(mCurrentKey)