Merge "Distinguish action-enter/shift-enter/enter"
This commit is contained in:
commit
34b8856077
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,11 +1383,41 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
ResearchLogger.getInstance().onResearchKeySelected(this);
|
||||
}
|
||||
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);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
// Reset after any single keystroke, except shift and symbol-shift
|
||||
if (!didAutoCorrect && primaryCode != Constants.CODE_SHIFT
|
||||
&& primaryCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)
|
||||
mLastComposedWord.deactivate();
|
||||
if (Constants.CODE_DELETE != primaryCode) {
|
||||
mEnteredText = null;
|
||||
}
|
||||
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()) {
|
||||
|
@ -1412,17 +1439,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
handleCharacter(primaryCode, keyX, keyY, spaceState);
|
||||
}
|
||||
mExpectingUpdateSelection = true;
|
||||
break;
|
||||
}
|
||||
switcher.onCodeInput(primaryCode);
|
||||
// Reset after any single keystroke, except shift and symbol-shift
|
||||
if (!didAutoCorrect && primaryCode != Constants.CODE_SHIFT
|
||||
&& primaryCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)
|
||||
mLastComposedWord.deactivate();
|
||||
if (Constants.CODE_DELETE != primaryCode) {
|
||||
mEnteredText = null;
|
||||
}
|
||||
mConnection.endBatchEdit();
|
||||
return didAutoCorrect;
|
||||
}
|
||||
|
||||
// Called from PointerTracker through the KeyboardActionListener interface
|
||||
|
|
Loading…
Reference in a new issue