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
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:parentStyle="defaultEnterKeyStyle" />
|
latin:parentStyle="shiftEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<!-- Smiley in textShortMessage field.
|
<!-- Smiley in textShortMessage field.
|
||||||
Overrides common enter key style. -->
|
Overrides common enter key style. -->
|
||||||
|
|
|
@ -99,7 +99,11 @@
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
latin:parentStyle="navigateMoreKeysStyle" />
|
latin:parentStyle="navigateMoreKeysStyle" />
|
||||||
<key-style
|
<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:code="!code/key_action_enter"
|
||||||
latin:keyIcon="!icon/undefined"
|
latin:keyIcon="!icon/undefined"
|
||||||
latin:backgroundType="action"
|
latin:backgroundType="action"
|
||||||
|
@ -112,7 +116,7 @@
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:parentStyle="defaultEnterKeyStyle" />
|
latin:parentStyle="shiftEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionGo"
|
latin:imeAction="actionGo"
|
||||||
|
@ -120,7 +124,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyLabel="!text/label_go_key"
|
latin:keyLabel="!text/label_go_key"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionNext"
|
latin:imeAction="actionNext"
|
||||||
|
@ -128,7 +132,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyLabel="!text/label_next_key"
|
latin:keyLabel="!text/label_next_key"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionPrevious"
|
latin:imeAction="actionPrevious"
|
||||||
|
@ -136,7 +140,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyLabel="!text/label_previous_key"
|
latin:keyLabel="!text/label_previous_key"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionDone"
|
latin:imeAction="actionDone"
|
||||||
|
@ -144,7 +148,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyLabel="!text/label_done_key"
|
latin:keyLabel="!text/label_done_key"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionSend"
|
latin:imeAction="actionSend"
|
||||||
|
@ -152,7 +156,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyLabel="!text/label_send_key"
|
latin:keyLabel="!text/label_send_key"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionSearch"
|
latin:imeAction="actionSearch"
|
||||||
|
@ -160,7 +164,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyIcon="!icon/search_key"
|
latin:keyIcon="!icon/search_key"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
latin:imeAction="actionCustomLabel"
|
latin:imeAction="actionCustomLabel"
|
||||||
|
@ -168,7 +172,7 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keyLabelFlags="fromCustomActionLabel"
|
latin:keyLabelFlags="fromCustomActionLabel"
|
||||||
latin:parentStyle="defaultActionKeyStyle" />
|
latin:parentStyle="defaultActionEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<!-- imeAction is either actionNone or actionUnspecified. -->
|
<!-- imeAction is either actionNone or actionUnspecified. -->
|
||||||
<default>
|
<default>
|
||||||
|
|
|
@ -51,6 +51,7 @@ public final class KeyboardCodesSet {
|
||||||
"key_action_enter",
|
"key_action_enter",
|
||||||
"key_action_next",
|
"key_action_next",
|
||||||
"key_action_previous",
|
"key_action_previous",
|
||||||
|
"key_shift_enter",
|
||||||
"key_language_switch",
|
"key_language_switch",
|
||||||
"key_research",
|
"key_research",
|
||||||
"key_unspecified",
|
"key_unspecified",
|
||||||
|
@ -86,6 +87,7 @@ public final class KeyboardCodesSet {
|
||||||
Constants.CODE_ACTION_ENTER,
|
Constants.CODE_ACTION_ENTER,
|
||||||
Constants.CODE_ACTION_NEXT,
|
Constants.CODE_ACTION_NEXT,
|
||||||
Constants.CODE_ACTION_PREVIOUS,
|
Constants.CODE_ACTION_PREVIOUS,
|
||||||
|
Constants.CODE_SHIFT_ENTER,
|
||||||
Constants.CODE_LANGUAGE_SWITCH,
|
Constants.CODE_LANGUAGE_SWITCH,
|
||||||
Constants.CODE_RESEARCH,
|
Constants.CODE_RESEARCH,
|
||||||
Constants.CODE_UNSPECIFIED,
|
Constants.CODE_UNSPECIFIED,
|
||||||
|
|
|
@ -184,8 +184,9 @@ public final class Constants {
|
||||||
public static final int CODE_ACTION_PREVIOUS = -9;
|
public static final int CODE_ACTION_PREVIOUS = -9;
|
||||||
public static final int CODE_LANGUAGE_SWITCH = -10;
|
public static final int CODE_LANGUAGE_SWITCH = -10;
|
||||||
public static final int CODE_RESEARCH = -11;
|
public static final int CODE_RESEARCH = -11;
|
||||||
|
public static final int CODE_SHIFT_ENTER = -12;
|
||||||
// Code value representing the code is not specified.
|
// 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) {
|
public static boolean isLetterCode(final int code) {
|
||||||
return code >= CODE_SPACE;
|
return code >= CODE_SPACE;
|
||||||
|
|
|
@ -1369,9 +1369,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
case Constants.CODE_SHORTCUT:
|
case Constants.CODE_SHORTCUT:
|
||||||
mSubtypeSwitcher.switchToShortcutIME(this);
|
mSubtypeSwitcher.switchToShortcutIME(this);
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_ACTION_ENTER:
|
|
||||||
performEditorAction(getActionId(switcher.getKeyboard()));
|
|
||||||
break;
|
|
||||||
case Constants.CODE_ACTION_NEXT:
|
case Constants.CODE_ACTION_NEXT:
|
||||||
performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
||||||
break;
|
break;
|
||||||
|
@ -1386,32 +1383,20 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
ResearchLogger.getInstance().onResearchKeySelected(this);
|
ResearchLogger.getInstance().onResearchKeySelected(this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case Constants.CODE_ACTION_ENTER:
|
||||||
mSpaceState = SPACE_STATE_NONE;
|
final int actionId = getActionId(switcher.getKeyboard());
|
||||||
if (mSettings.getCurrent().isWordSeparator(primaryCode)) {
|
if (EditorInfo.IME_ACTION_NONE != actionId
|
||||||
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
&& EditorInfo.IME_ACTION_UNSPECIFIED != actionId) {
|
||||||
} else {
|
performEditorAction(actionId);
|
||||||
if (SPACE_STATE_PHANTOM == spaceState) {
|
break;
|
||||||
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;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
switcher.onCodeInput(primaryCode);
|
switcher.onCodeInput(primaryCode);
|
||||||
|
@ -1425,6 +1410,38 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
mConnection.endBatchEdit();
|
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
|
// Called from PointerTracker through the KeyboardActionListener interface
|
||||||
@Override
|
@Override
|
||||||
public void onTextInput(final String rawText) {
|
public void onTextInput(final String rawText) {
|
||||||
|
|
Loading…
Reference in a new issue