am 22959faa: Merge "Stop relying on the soft keyboard to get the editor action."

* commit '22959faad4ad6a6284404ffc667ec823991f3710':
  Stop relying on the soft keyboard to get the editor action.
main
Jean Chalard 2013-01-16 23:19:04 -08:00 committed by Android Git Automerger
commit 81731134fb
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,
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.

View File

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

View File

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

View File

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