diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 6a01b0190..ea86d98cb 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -209,7 +209,7 @@ public final class KeyCodeDescriptionMapper { private String getDescriptionForActionKey(final Context context, final Keyboard keyboard, final Key key) { final KeyboardId keyboardId = keyboard.mId; - final int actionId = keyboardId.imeActionId(); + final int actionId = keyboardId.imeAction(); final int resId; // Always use the label, if available. diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index f9ff7b089..02116ca08 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -172,12 +172,7 @@ public final class KeyboardId { } public int imeAction() { - return InputTypeUtils.getActionIdFromEditorInfo(mEditorInfo); - } - - public int imeActionId() { - final int actionId = imeAction(); - return actionId == InputTypeUtils.IME_ACTION_CUSTOM_LABEL ? mEditorInfo.actionId : actionId; + return InputTypeUtils.getImeOptionsActionIdFromEditorInfo(mEditorInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/InputTypeUtils.java b/java/src/com/android/inputmethod/latin/InputTypeUtils.java index 55414b809..e2eacb3f0 100644 --- a/java/src/com/android/inputmethod/latin/InputTypeUtils.java +++ b/java/src/com/android/inputmethod/latin/InputTypeUtils.java @@ -105,7 +105,7 @@ public final class InputTypeUtils implements InputType { return true; } - public static int getActionIdFromEditorInfo(final EditorInfo editorInfo) { + 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; @@ -115,4 +115,9 @@ public final class InputTypeUtils implements InputType { return actionId; } } + + 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 8913b1543..819625225 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -166,6 +166,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private boolean mExpectingUpdateSelection; private int mDeleteCount; private long mLastKeyTime; + private int mActionId; // Member variables for remembering the current device orientation. private int mDisplayOrientation; @@ -754,6 +755,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mLastSelectionStart = editorInfo.initialSelStart; mLastSelectionEnd = editorInfo.initialSelEnd; + mActionId = InputTypeUtils.getConcreteActionIdFromEditorInfo(editorInfo); mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelDoubleSpacePeriodTimer(); @@ -1272,10 +1274,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction return mOptionsDialog != null && mOptionsDialog.isShowing(); } - private static int getActionId(final Keyboard keyboard) { - return keyboard != null ? keyboard.mId.imeActionId() : EditorInfo.IME_ACTION_NONE; - } - private void performEditorAction(final int actionId) { mConnection.performEditorAction(actionId); } @@ -1384,10 +1382,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } break; case Constants.CODE_ACTION_ENTER: - final int actionId = getActionId(switcher.getKeyboard()); - if (EditorInfo.IME_ACTION_NONE != actionId - && EditorInfo.IME_ACTION_UNSPECIFIED != actionId) { - performEditorAction(actionId); + if (EditorInfo.IME_ACTION_NONE != mActionId + && EditorInfo.IME_ACTION_UNSPECIFIED != mActionId) { + performEditorAction(mActionId); break; } didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState);