Stop relying on the soft keyboard to get the editor action.

Bug: 7969231
Change-Id: I9848c63c4c51550b5dc53c981eafa74e7fa95197
main
Jean Chalard 2013-01-15 17:56:37 +09:00
parent b4f89c0368
commit d818f1e3b6
4 changed files with 13 additions and 16 deletions

View File

@ -209,7 +209,7 @@ public final class KeyCodeDescriptionMapper {
private String getDescriptionForActionKey(final Context context, final Keyboard keyboard, private String getDescriptionForActionKey(final Context context, final Keyboard keyboard,
final Key key) { final Key key) {
final KeyboardId keyboardId = keyboard.mId; final KeyboardId keyboardId = keyboard.mId;
final int actionId = keyboardId.imeActionId(); final int actionId = keyboardId.imeAction();
final int resId; final int resId;
// Always use the label, if available. // Always use the label, if available.

View File

@ -172,12 +172,7 @@ public final class KeyboardId {
} }
public int imeAction() { public int imeAction() {
return InputTypeUtils.getActionIdFromEditorInfo(mEditorInfo); return InputTypeUtils.getImeOptionsActionIdFromEditorInfo(mEditorInfo);
}
public int imeActionId() {
final int actionId = imeAction();
return actionId == InputTypeUtils.IME_ACTION_CUSTOM_LABEL ? mEditorInfo.actionId : actionId;
} }
@Override @Override

View File

@ -105,7 +105,7 @@ public final class InputTypeUtils implements InputType {
return true; 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; final int actionId = editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) { if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
return EditorInfo.IME_ACTION_NONE; return EditorInfo.IME_ACTION_NONE;
@ -115,4 +115,9 @@ public final class InputTypeUtils implements InputType {
return actionId; return actionId;
} }
} }
public static int getConcreteActionIdFromEditorInfo(final EditorInfo editorInfo) {
final int actionId = getImeOptionsActionIdFromEditorInfo(editorInfo);
return actionId == InputTypeUtils.IME_ACTION_CUSTOM_LABEL ? editorInfo.actionId : actionId;
}
} }

View File

@ -166,6 +166,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private boolean mExpectingUpdateSelection; private boolean mExpectingUpdateSelection;
private int mDeleteCount; private int mDeleteCount;
private long mLastKeyTime; private long mLastKeyTime;
private int mActionId;
// Member variables for remembering the current device orientation. // Member variables for remembering the current device orientation.
private int mDisplayOrientation; private int mDisplayOrientation;
@ -754,6 +755,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mLastSelectionStart = editorInfo.initialSelStart; mLastSelectionStart = editorInfo.initialSelStart;
mLastSelectionEnd = editorInfo.initialSelEnd; mLastSelectionEnd = editorInfo.initialSelEnd;
mActionId = InputTypeUtils.getConcreteActionIdFromEditorInfo(editorInfo);
mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelUpdateSuggestionStrip();
mHandler.cancelDoubleSpacePeriodTimer(); mHandler.cancelDoubleSpacePeriodTimer();
@ -1272,10 +1274,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
return mOptionsDialog != null && mOptionsDialog.isShowing(); 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) { private void performEditorAction(final int actionId) {
mConnection.performEditorAction(actionId); mConnection.performEditorAction(actionId);
} }
@ -1384,10 +1382,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
} }
break; break;
case Constants.CODE_ACTION_ENTER: case Constants.CODE_ACTION_ENTER:
final int actionId = getActionId(switcher.getKeyboard()); if (EditorInfo.IME_ACTION_NONE != mActionId
if (EditorInfo.IME_ACTION_NONE != actionId && EditorInfo.IME_ACTION_UNSPECIFIED != mActionId) {
&& EditorInfo.IME_ACTION_UNSPECIFIED != actionId) { performEditorAction(mActionId);
performEditorAction(actionId);
break; break;
} }
didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState); didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState);