Distinguish action-enter/shift-enter/enter
Bug: 7969231 Change-Id: I75d495ee1ea126da9be4e269ee990ee0a97793c1
This commit is contained in:
parent
c995dbcf59
commit
dcfceaff1b
5 changed files with 63 additions and 39 deletions
|
@ -71,7 +71,7 @@
|
|||
>
|
||||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:parentStyle="defaultEnterKeyStyle" />
|
||||
latin:parentStyle="shiftEnterKeyStyle" />
|
||||
</case>
|
||||
<!-- Smiley in textShortMessage field.
|
||||
Overrides common enter key style. -->
|
||||
|
|
|
@ -99,7 +99,11 @@
|
|||
latin:backgroundType="functional"
|
||||
latin:parentStyle="navigateMoreKeysStyle" />
|
||||
<key-style
|
||||
latin:styleName="defaultActionKeyStyle"
|
||||
latin:styleName="shiftEnterKeyStyle"
|
||||
latin:code="!code/key_shift_enter"
|
||||
latin:parentStyle="defaultEnterKeyStyle" />
|
||||
<key-style
|
||||
latin:styleName="defaultActionEnterKeyStyle"
|
||||
latin:code="!code/key_action_enter"
|
||||
latin:keyIcon="!icon/undefined"
|
||||
latin:backgroundType="action"
|
||||
|
@ -112,7 +116,7 @@
|
|||
>
|
||||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:parentStyle="defaultEnterKeyStyle" />
|
||||
latin:parentStyle="shiftEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionGo"
|
||||
|
@ -120,7 +124,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyLabel="!text/label_go_key"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionNext"
|
||||
|
@ -128,7 +132,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyLabel="!text/label_next_key"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionPrevious"
|
||||
|
@ -136,7 +140,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyLabel="!text/label_previous_key"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionDone"
|
||||
|
@ -144,7 +148,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyLabel="!text/label_done_key"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionSend"
|
||||
|
@ -152,7 +156,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyLabel="!text/label_send_key"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionSearch"
|
||||
|
@ -160,7 +164,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyIcon="!icon/search_key"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<case
|
||||
latin:imeAction="actionCustomLabel"
|
||||
|
@ -168,7 +172,7 @@
|
|||
<key-style
|
||||
latin:styleName="enterKeyStyle"
|
||||
latin:keyLabelFlags="fromCustomActionLabel"
|
||||
latin:parentStyle="defaultActionKeyStyle" />
|
||||
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||
</case>
|
||||
<!-- imeAction is either actionNone or actionUnspecified. -->
|
||||
<default>
|
||||
|
|
|
@ -51,6 +51,7 @@ public final class KeyboardCodesSet {
|
|||
"key_action_enter",
|
||||
"key_action_next",
|
||||
"key_action_previous",
|
||||
"key_shift_enter",
|
||||
"key_language_switch",
|
||||
"key_research",
|
||||
"key_unspecified",
|
||||
|
@ -86,6 +87,7 @@ public final class KeyboardCodesSet {
|
|||
Constants.CODE_ACTION_ENTER,
|
||||
Constants.CODE_ACTION_NEXT,
|
||||
Constants.CODE_ACTION_PREVIOUS,
|
||||
Constants.CODE_SHIFT_ENTER,
|
||||
Constants.CODE_LANGUAGE_SWITCH,
|
||||
Constants.CODE_RESEARCH,
|
||||
Constants.CODE_UNSPECIFIED,
|
||||
|
|
|
@ -184,8 +184,9 @@ public final class Constants {
|
|||
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;
|
||||
// Code value representing the code is not specified.
|
||||
public static final int CODE_UNSPECIFIED = -12;
|
||||
public static final int CODE_UNSPECIFIED = -13;
|
||||
|
||||
public static boolean isLetterCode(final int code) {
|
||||
return code >= CODE_SPACE;
|
||||
|
|
|
@ -1369,9 +1369,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
case Constants.CODE_SHORTCUT:
|
||||
mSubtypeSwitcher.switchToShortcutIME(this);
|
||||
break;
|
||||
case Constants.CODE_ACTION_ENTER:
|
||||
performEditorAction(getActionId(switcher.getKeyboard()));
|
||||
break;
|
||||
case Constants.CODE_ACTION_NEXT:
|
||||
performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
||||
break;
|
||||
|
@ -1386,32 +1383,20 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
ResearchLogger.getInstance().onResearchKeySelected(this);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
mSpaceState = SPACE_STATE_NONE;
|
||||
if (mSettings.getCurrent().isWordSeparator(primaryCode)) {
|
||||
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
||||
} else {
|
||||
if (SPACE_STATE_PHANTOM == spaceState) {
|
||||
if (ProductionFlag.IS_INTERNAL) {
|
||||
if (mWordComposer.isComposingWord() && mWordComposer.isBatchMode()) {
|
||||
Stats.onAutoCorrection(
|
||||
"", mWordComposer.getTypedWord(), " ", mWordComposer);
|
||||
}
|
||||
}
|
||||
commitTyped(LastComposedWord.NOT_A_SEPARATOR);
|
||||
}
|
||||
final int keyX, keyY;
|
||||
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
|
||||
keyX = x;
|
||||
keyY = y;
|
||||
} else {
|
||||
keyX = Constants.NOT_A_COORDINATE;
|
||||
keyY = Constants.NOT_A_COORDINATE;
|
||||
}
|
||||
handleCharacter(primaryCode, keyX, keyY, spaceState);
|
||||
case Constants.CODE_ACTION_ENTER:
|
||||
final int actionId = getActionId(switcher.getKeyboard());
|
||||
if (EditorInfo.IME_ACTION_NONE != actionId
|
||||
&& EditorInfo.IME_ACTION_UNSPECIFIED != actionId) {
|
||||
performEditorAction(actionId);
|
||||
break;
|
||||
}
|
||||
mExpectingUpdateSelection = true;
|
||||
didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState);
|
||||
break;
|
||||
case Constants.CODE_SHIFT_ENTER:
|
||||
didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState);
|
||||
break;
|
||||
default:
|
||||
didAutoCorrect = handleNonSpecialCharacter(primaryCode, x, y, spaceState);
|
||||
break;
|
||||
}
|
||||
switcher.onCodeInput(primaryCode);
|
||||
|
@ -1425,6 +1410,38 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
mConnection.endBatchEdit();
|
||||
}
|
||||
|
||||
private boolean handleNonSpecialCharacter(final int primaryCode, final int x, final int y,
|
||||
final int spaceState) {
|
||||
mSpaceState = SPACE_STATE_NONE;
|
||||
final boolean didAutoCorrect;
|
||||
if (mSettings.getCurrent().isWordSeparator(primaryCode)) {
|
||||
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
||||
} else {
|
||||
didAutoCorrect = false;
|
||||
if (SPACE_STATE_PHANTOM == spaceState) {
|
||||
if (ProductionFlag.IS_INTERNAL) {
|
||||
if (mWordComposer.isComposingWord() && mWordComposer.isBatchMode()) {
|
||||
Stats.onAutoCorrection(
|
||||
"", mWordComposer.getTypedWord(), " ", mWordComposer);
|
||||
}
|
||||
}
|
||||
commitTyped(LastComposedWord.NOT_A_SEPARATOR);
|
||||
}
|
||||
final int keyX, keyY;
|
||||
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
|
||||
keyX = x;
|
||||
keyY = y;
|
||||
} else {
|
||||
keyX = Constants.NOT_A_COORDINATE;
|
||||
keyY = Constants.NOT_A_COORDINATE;
|
||||
}
|
||||
handleCharacter(primaryCode, keyX, keyY, spaceState);
|
||||
}
|
||||
mExpectingUpdateSelection = true;
|
||||
return didAutoCorrect;
|
||||
}
|
||||
|
||||
// Called from PointerTracker through the KeyboardActionListener interface
|
||||
@Override
|
||||
public void onTextInput(final String rawText) {
|
||||
|
|
Loading…
Reference in a new issue