From 59de7526152e9ed6a6f57ed3629f1bdc3c571bd5 Mon Sep 17 00:00:00 2001 From: Dmitriy Chernysh Date: Mon, 9 Oct 2023 22:26:29 +0300 Subject: [PATCH 1/2] Fixed issue with caching for mini keyboard views: Getting 'miniKeyboardView' from 'mMiniKeyboardCache' and not from the previously shown layout. Fix #251. + removed mMiniKeyboard!!.mOnKeyboardActionListener is not needed in MyKeyboardView.onLongPress() func. Originally defined in SimpleKeyboardIME class. --- .../keyboard/views/MyKeyboardView.kt | 35 ++----------------- 1 file changed, 3 insertions(+), 32 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 d37e517..c2b5e42 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -1012,37 +1012,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mMiniKeyboard = miniKeyboardView } - mMiniKeyboard!!.mOnKeyboardActionListener = object : OnKeyboardActionListener { - override fun onKey(code: Int) { - mOnKeyboardActionListener!!.onKey(code) - dismissPopupKeyboard() - } - - override fun onPress(primaryCode: Int) { - mOnKeyboardActionListener!!.onPress(primaryCode) - } - - override fun onActionUp() { - mOnKeyboardActionListener!!.onActionUp() - } - - override fun moveCursorLeft() { - mOnKeyboardActionListener!!.moveCursorLeft() - } - - override fun moveCursorRight() { - mOnKeyboardActionListener!!.moveCursorRight() - } - - override fun onText(text: String) { - mOnKeyboardActionListener!!.onText(text) - } - - override fun reloadKeyboard() { - mOnKeyboardActionListener!!.reloadKeyboard() - } - } - val keyboard = if (popupKey.popupCharacters != null) { MyKeyboard(context, popupKeyboardId, popupKey.popupCharacters!!, popupKey.width) } else { @@ -1056,7 +1025,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut ) mMiniKeyboardCache[popupKey] = mMiniKeyboardContainer } else { - mMiniKeyboard = keyboardPopupBinding!!.miniKeyboardView + //Using 'miniKeyboardView' from cache + mMiniKeyboard = mMiniKeyboardCache[popupKey]?.let(KeyboardPopupKeyboardBinding::bind)?.miniKeyboardView + ?: keyboardPopupBinding!!.miniKeyboardView } getLocationInWindow(mCoordinates) From a08a63e468b33ee202a74e57c9fa43a8afe75690 Mon Sep 17 00:00:00 2001 From: Dmitriy Chernysh Date: Mon, 9 Oct 2023 23:51:31 +0300 Subject: [PATCH 2/2] Simplified - getting miniKeyboardContainer from mMiniKeyboardCache[popupKey] - getting miniKeyboardView using view binding - comment removed --- .../com/simplemobiletools/keyboard/views/MyKeyboardView.kt | 2 -- 1 file changed, 2 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 c2b5e42..bb49abe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -1025,9 +1025,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut ) mMiniKeyboardCache[popupKey] = mMiniKeyboardContainer } else { - //Using 'miniKeyboardView' from cache mMiniKeyboard = mMiniKeyboardCache[popupKey]?.let(KeyboardPopupKeyboardBinding::bind)?.miniKeyboardView - ?: keyboardPopupBinding!!.miniKeyboardView } getLocationInWindow(mCoordinates)