Merge pull request #12315 from keymanapp/fix/android/enter-search

fix(android): Prioritize certain actions over multi-line for ENTER key
This commit is contained in:
Darcy Wong 2024-08-29 20:16:34 +07:00 committed by GitHub
commit 31d2b76b30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;