From 916a64774c2b6dc5781bb7279a1868f33254fdd4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Jan 2022 21:35:14 +0100 Subject: [PATCH] insert the proper character at releasing a key after long pressing --- .../keyboard/views/MyKeyboardView.kt | 10 ++++++++++ app/src/main/res/drawable/btn_keyboard_key.xml | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) 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 12cd37e..9074d3f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -1099,6 +1099,16 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { + if (mMiniKeyboard != null) { + val coords = intArrayOf(0, 0) + mMiniKeyboard!!.getLocationOnScreen(coords) + val keys = mMiniKeyboard!!.mKeys + val widthPerKey = mMiniKeyboard!!.width / keys.size + var selectedKeyIndex = Math.floor((me.x - coords[0]) / widthPerKey.toDouble()).toInt() + selectedKeyIndex = Math.max(0, Math.min(selectedKeyIndex, keys.size - 1)) + val selectedKeyCodes = keys[selectedKeyIndex].codes + onKeyboardActionListener!!.onKey(selectedKeyCodes[0], selectedKeyCodes.toIntArray()) + } dismissPopupKeyboard() } } diff --git a/app/src/main/res/drawable/btn_keyboard_key.xml b/app/src/main/res/drawable/btn_keyboard_key.xml index 9399750..8e3c212 100644 --- a/app/src/main/res/drawable/btn_keyboard_key.xml +++ b/app/src/main/res/drawable/btn_keyboard_key.xml @@ -1,14 +1,4 @@ - +