diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
3 files changed, 29 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index 422448edf..50e50233e 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -179,14 +179,13 @@ public final class Constants { public static final int CODE_DELETE = -4; public static final int CODE_SETTINGS = -5; public static final int CODE_SHORTCUT = -6; - public static final int CODE_ACTION_ENTER = -7; - public static final int CODE_ACTION_NEXT = -8; - public static final int CODE_ACTION_PREVIOUS = -9; - public static final int CODE_LANGUAGE_SWITCH = -10; - public static final int CODE_RESEARCH = -11; - public static final int CODE_SHIFT_ENTER = -12; + public static final int CODE_ACTION_NEXT = -7; + public static final int CODE_ACTION_PREVIOUS = -8; + public static final int CODE_LANGUAGE_SWITCH = -9; + public static final int CODE_RESEARCH = -10; + public static final int CODE_SHIFT_ENTER = -11; // Code value representing the code is not specified. - public static final int CODE_UNSPECIFIED = -13; + public static final int CODE_UNSPECIFIED = -12; public static boolean isLetterCode(final int code) { return code >= CODE_SPACE; @@ -200,7 +199,6 @@ public final class Constants { case CODE_DELETE: return "delete"; case CODE_SETTINGS: return "settings"; case CODE_SHORTCUT: return "shortcut"; - case CODE_ACTION_ENTER: return "actionEnter"; case CODE_ACTION_NEXT: return "actionNext"; case CODE_ACTION_PREVIOUS: return "actionPrevious"; case CODE_LANGUAGE_SWITCH: return "languageSwitch"; diff --git a/java/src/com/android/inputmethod/latin/InputTypeUtils.java b/java/src/com/android/inputmethod/latin/InputTypeUtils.java index 2ad619b82..ecb20144b 100644 --- a/java/src/com/android/inputmethod/latin/InputTypeUtils.java +++ b/java/src/com/android/inputmethod/latin/InputTypeUtils.java @@ -106,18 +106,13 @@ public final class InputTypeUtils implements InputType { } public static int getImeOptionsActionIdFromEditorInfo(final EditorInfo editorInfo) { - final int actionId = editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION; if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) { return EditorInfo.IME_ACTION_NONE; } else if (editorInfo.actionLabel != null) { return IME_ACTION_CUSTOM_LABEL; } else { - return actionId; + // Note: this is different from editorInfo.actionId, hence "ImeOptionsActionId" + return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION; } } - - public static int getConcreteActionIdFromEditorInfo(final EditorInfo editorInfo) { - final int actionId = getImeOptionsActionIdFromEditorInfo(editorInfo); - return actionId == InputTypeUtils.IME_ACTION_CUSTOM_LABEL ? editorInfo.actionId : actionId; - } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 73ace2bfa..20209b627 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -165,7 +165,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private boolean mExpectingUpdateSelection; private int mDeleteCount; private long mLastKeyTime; - private int mActionId; private TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet(); // Member variables for remembering the current device orientation. @@ -756,7 +755,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mLastSelectionStart = editorInfo.initialSelStart; mLastSelectionEnd = editorInfo.initialSelEnd; - mActionId = InputTypeUtils.getConcreteActionIdFromEditorInfo(editorInfo); mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelDoubleSpacePeriodTimer(); @@ -1393,13 +1391,28 @@ public final class LatinIME extends InputMethodService implements KeyboardAction ResearchLogger.getInstance().onResearchKeySelected(this); } break; - case Constants.CODE_ACTION_ENTER: - if (EditorInfo.IME_ACTION_NONE != mActionId - && EditorInfo.IME_ACTION_UNSPECIFIED != mActionId) { - performEditorAction(mActionId); - break; + case Constants.CODE_ENTER: + final EditorInfo editorInfo = getCurrentInputEditorInfo(); + final int imeOptionsActionId = + InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo); + if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) { + // Either we have an actionLabel and we should performEditorAction with actionId + // regardless of its value. + performEditorAction(editorInfo.actionId); + } else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) { + // We didn't have an actionLabel, but we had another action to execute. + // EditorInfo.IME_ACTION_NONE explicitly means no action. In contrast, + // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an action, so it + // means there should be an action and the app didn't bother to set a specific + // code for it - presumably it only handles one. It does not have to be treated + // in any specific way: anything that is not IME_ACTION_NONE should be sent to + // performEditorAction. + performEditorAction(imeOptionsActionId); + } else { + // No action label, and the action from imeOptions is NONE: this is a regular + // enter key that should input a carriage return. + didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState); } - didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState); break; case Constants.CODE_SHIFT_ENTER: didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState); |