From 44f20472df8dd60e6409eb417eb94d5e260fb614 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 29 Nov 2024 08:48:13 +0700 Subject: [PATCH] feat(android): Enhance how ENTER key is handled for FV and KMSample2 --- .../src/main/java/com/keyman/kmsample2/SystemKeyboard.java | 5 +++++ .../main/java/com/firstvoices/keyboards/SystemKeyboard.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/android/Samples/KMSample2/app/src/main/java/com/keyman/kmsample2/SystemKeyboard.java b/android/Samples/KMSample2/app/src/main/java/com/keyman/kmsample2/SystemKeyboard.java index 4ad462a76c..438ed237db 100644 --- a/android/Samples/KMSample2/app/src/main/java/com/keyman/kmsample2/SystemKeyboard.java +++ b/android/Samples/KMSample2/app/src/main/java/com/keyman/kmsample2/SystemKeyboard.java @@ -130,6 +130,11 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven super.onStartInput(attribute, restarting); KMManager.onStartInput(attribute, restarting); KMManager.resetContext(KeyboardType.KEYBOARD_TYPE_SYSTEM); + + // Determine special handling for ENTER key + int inputType = attribute.inputType; + KMManager.setEnterMode(attribute.imeOptions, inputType); + // User switched to a new input field so we should extract the text from input field // and pass it to Keyman Engine together with selection range InputConnection ic = getCurrentInputConnection(); diff --git a/oem/firstvoices/android/app/src/main/java/com/firstvoices/keyboards/SystemKeyboard.java b/oem/firstvoices/android/app/src/main/java/com/firstvoices/keyboards/SystemKeyboard.java index f047bc6c78..0e2cffd68e 100644 --- a/oem/firstvoices/android/app/src/main/java/com/firstvoices/keyboards/SystemKeyboard.java +++ b/oem/firstvoices/android/app/src/main/java/com/firstvoices/keyboards/SystemKeyboard.java @@ -150,6 +150,10 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven KMManager.setBannerOptions(mayPredict); } } + + // Determine special handling for ENTER key + KMManager.setEnterMode(attribute.imeOptions, inputType); + // User switched to a new input field so we should extract the text from input field // and pass it to Keyman Engine together with selection range InputConnection ic = getCurrentInputConnection();