From 0f39a898412789f50f3ec016768c85df39f0dac0 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 29 Aug 2024 14:28:21 +0700 Subject: [PATCH] fix(android): Prioritize certain actions over multi-line for ENTER key --- .../java/com/keyman/engine/KMManager.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java b/android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java index b921ac6c0a..89690dffec 100644 --- a/android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java +++ b/android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java @@ -1274,17 +1274,13 @@ public final class KMManager { /** * Sets enterMode which specifies how the System keyboard ENTER key is handled * - * @param imeOptions EditorInfo.imeOptions - * @param inputType InputType + * @param imeOptions EditorInfo.imeOptions used to determine the action + * @param inputType InputType used to determine if the text field is multi-line */ public static void setEnterMode(int imeOptions, int inputType) { - if ((inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0) { - enterMode = EnterModeType.NEWLINE; - return; - } - - int imeActions = imeOptions & EditorInfo.IME_MASK_ACTION; EnterModeType value = EnterModeType.DEFAULT; + int imeActions = imeOptions & EditorInfo.IME_MASK_ACTION; + boolean isMultiLine = (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0; switch (imeActions) { case EditorInfo.IME_ACTION_GO: @@ -1296,7 +1292,8 @@ public final class KMManager { break; case EditorInfo.IME_ACTION_SEND: - value = EnterModeType.SEND; + value = isMultiLine ? + EnterModeType.NEWLINE :EnterModeType.SEND; break; case EditorInfo.IME_ACTION_NEXT: @@ -1304,7 +1301,8 @@ public final class KMManager { break; case EditorInfo.IME_ACTION_DONE: - value = EnterModeType.DONE; + value = isMultiLine ? + EnterModeType.NEWLINE : EnterModeType.DONE; break; case EditorInfo.IME_ACTION_PREVIOUS: @@ -1312,7 +1310,8 @@ public final class KMManager { break; default: - value = EnterModeType.DEFAULT; + value = isMultiLine ? + EnterModeType.NEWLINE : EnterModeType.DEFAULT; } enterMode = value;