From dcfceaff1b18b102d7fe875b48b84c24cbd822d9 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 15 Jan 2013 17:33:58 +0900 Subject: [PATCH] Distinguish action-enter/shift-enter/enter Bug: 7969231 Change-Id: I75d495ee1ea126da9be4e269ee990ee0a97793c1 --- java/res/xml/key_styles_common.xml | 2 +- java/res/xml/key_styles_enter.xml | 22 +++--- .../keyboard/internal/KeyboardCodesSet.java | 2 + .../android/inputmethod/latin/Constants.java | 3 +- .../android/inputmethod/latin/LatinIME.java | 73 ++++++++++++------- 5 files changed, 63 insertions(+), 39 deletions(-) diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml index 91ebac1da..0834adf20 100644 --- a/java/res/xml/key_styles_common.xml +++ b/java/res/xml/key_styles_common.xml @@ -71,7 +71,7 @@ > + latin:parentStyle="shiftEnterKeyStyle" /> diff --git a/java/res/xml/key_styles_enter.xml b/java/res/xml/key_styles_enter.xml index 3788ca8ba..61a515bad 100644 --- a/java/res/xml/key_styles_enter.xml +++ b/java/res/xml/key_styles_enter.xml @@ -99,7 +99,11 @@ latin:backgroundType="functional" latin:parentStyle="navigateMoreKeysStyle" /> + + latin:parentStyle="shiftEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> + latin:parentStyle="defaultActionEnterKeyStyle" /> diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java index 428e31ccd..0d852dde2 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java @@ -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, diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index 5c8a2edd8..483504cfb 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -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; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4a3511472..ab21cff47 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -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) {