Stop relying on the soft keyboard to get the editor action.
Bug: 7969231 Change-Id: I9848c63c4c51550b5dc53c981eafa74e7fa95197
This commit is contained in:
parent
b4f89c0368
commit
d818f1e3b6
4 changed files with 13 additions and 16 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue