aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/values/keycodes.xml1
-rw-r--r--java/res/xml-sw600dp/kbd_key_styles.xml4
-rw-r--r--java/res/xml-sw768dp/kbd_key_styles.xml4
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java16
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java176
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSet.java29
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java17
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java10
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java35
10 files changed, 158 insertions, 153 deletions
diff --git a/java/res/values/keycodes.xml b/java/res/values/keycodes.xml
index 59cc07531..4f8bfed58 100644
--- a/java/res/values/keycodes.xml
+++ b/java/res/values/keycodes.xml
@@ -23,6 +23,7 @@
<integer name="key_tab">9</integer>
<integer name="key_return">10</integer>
<integer name="key_space">32</integer>
+ <integer name="key_dummy">0</integer>
<integer name="key_shift">-1</integer>
<integer name="key_switch_alpha_symbol">-2</integer>
<integer name="key_delete">-5</integer>
diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml
index aba1a8029..e0171b030 100644
--- a/java/res/xml-sw600dp/kbd_key_styles.xml
+++ b/java/res/xml-sw600dp/kbd_key_styles.xml
@@ -78,14 +78,14 @@
latin:code="@integer/key_shortcut"
latin:keyIcon="iconShortcutKey"
latin:keyActionFlags="noKeyPreview|altCodeWhileTyping"
- latin:altCode="@integer/key_space"
+ latin:altCode="@integer/key_dummy"
latin:parentStyle="f2PopupStyle" />
<key-style
latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings"
latin:keyIcon="iconSettingsKey"
latin:keyActionFlags="noKeyPreview|altCodeWhileTyping"
- latin:altCode="@integer/key_space"
+ latin:altCode="@integer/key_dummy"
latin:backgroundType="functional" />
<key-style
latin:styleName="tabKeyStyle"
diff --git a/java/res/xml-sw768dp/kbd_key_styles.xml b/java/res/xml-sw768dp/kbd_key_styles.xml
index e6ec53dd1..d9266508e 100644
--- a/java/res/xml-sw768dp/kbd_key_styles.xml
+++ b/java/res/xml-sw768dp/kbd_key_styles.xml
@@ -60,14 +60,14 @@
latin:code="@integer/key_shortcut"
latin:keyIcon="iconShortcutKey"
latin:keyActionFlags="noKeyPreview|altCodeWhileTyping"
- latin:altCode="@integer/key_space"
+ latin:altCode="@integer/key_dummy"
latin:backgroundType="functional" />
<key-style
latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings"
latin:keyIcon="iconSettingsKey"
latin:keyActionFlags="noKeyPreview|altCodeWhileTyping"
- latin:altCode="@integer/key_space"
+ latin:altCode="@integer/key_dummy"
latin:backgroundType="functional" />
<key-style
latin:styleName="tabKeyStyle"
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index e267aa65c..814b52398 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -151,6 +151,9 @@ public class Keyboard {
}
public Key getKey(int code) {
+ if (code == CODE_DUMMY) {
+ return null;
+ }
final Integer keyCode = code;
if (mKeyCache.containsKey(keyCode)) {
return mKeyCache.get(keyCode);
@@ -232,19 +235,6 @@ public class Keyboard {
return mProximityInfo.getNearestKeys(x, y);
}
- public static String themeName(int themeId) {
- // This should be aligned with theme-*.xml resource files' themeId attribute.
- switch (themeId) {
- case 0: return "Basic";
- case 1: return "BasicHighContrast";
- case 5: return "IceCreamSandwich";
- case 6: return "Stone";
- case 7: return "StoneBold";
- case 8: return "GingerBread";
- default: return null;
- }
- }
-
public static String printableCode(int code) {
switch (code) {
case CODE_SHIFT: return "shift";
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index 44c0c9337..3b3ff0709 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -51,11 +51,10 @@ public class KeyboardId {
public static final int ELEMENT_PHONE_SHIFT = 8;
public static final int ELEMENT_NUMBER = 9;
- // TODO: These constants could be private.
- public static final int F2KEY_MODE_NONE = 0;
- public static final int F2KEY_MODE_SETTINGS = 1;
- public static final int F2KEY_MODE_SHORTCUT_IME = 2;
- public static final int F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS = 3;
+ private static final int F2KEY_MODE_NONE = 0;
+ private static final int F2KEY_MODE_SETTINGS = 1;
+ private static final int F2KEY_MODE_SHORTCUT_IME = 2;
+ private static final int F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS = 3;
public final Locale mLocale;
public final int mOrientation;
@@ -64,73 +63,82 @@ public class KeyboardId {
// TODO: Remove this field.
private final int mXmlId;
public final int mElementState;
- public final boolean mNavigateAction;
- public final boolean mPasswordInput;
- // TODO: Clean up these booleans and modes.
- public final boolean mHasSettingsKey;
- public final int mF2KeyMode;
+ private final int mInputType;
+ private final int mImeOptions;
+ private final boolean mSettingsKeyEnabled;
public final boolean mClobberSettingsKey;
public final boolean mShortcutKeyEnabled;
public final boolean mHasShortcutKey;
- public final int mImeAction;
-
- // TODO: Remove this field.
- private final EditorInfo mEditorInfo;
private final int mHashCode;
- // TODO: The hasSettings, f2KeyMode, and clobberSettingsKey arguments could be reduced.
public KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width,
- int mode, EditorInfo editorInfo, boolean hasSettingsKey, int f2KeyMode,
+ int mode, EditorInfo editorInfo, boolean settingsKeyEnabled,
+ boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) {
+ this(xmlId, elementState, locale, orientation, width, mode,
+ (editorInfo != null ? editorInfo.inputType : 0),
+ (editorInfo != null ? editorInfo.imeOptions : 0),
+ settingsKeyEnabled, clobberSettingsKey, shortcutKeyEnabled, hasShortcutKey);
+ }
+
+ private KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width,
+ int mode, int inputType, int imeOptions, boolean settingsKeyEnabled,
boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) {
- final int inputType = (editorInfo != null) ? editorInfo.inputType : 0;
- final int imeOptions = (editorInfo != null) ? editorInfo.imeOptions : 0;
- this.mElementState = elementState;
this.mLocale = locale;
this.mOrientation = orientation;
this.mWidth = width;
this.mMode = mode;
this.mXmlId = xmlId;
- // Note: Turn off checking navigation flag to show TAB key for now.
- this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType);
-// || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions)
-// || EditorInfoCompatUtils.hasFlagNavigatePrevious(imeOptions);
- this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType)
- || InputTypeCompatUtils.isVisiblePasswordInputType(inputType);
- this.mHasSettingsKey = hasSettingsKey;
- this.mF2KeyMode = f2KeyMode;
+ this.mElementState = elementState;
+ this.mInputType = inputType;
+ this.mImeOptions = imeOptions;
+ this.mSettingsKeyEnabled = settingsKeyEnabled;
this.mClobberSettingsKey = clobberSettingsKey;
this.mShortcutKeyEnabled = shortcutKeyEnabled;
this.mHasShortcutKey = hasShortcutKey;
- // We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and
- // {@link EditorInfo#IME_FLAG_NO_ENTER_ACTION}.
- this.mImeAction = imeOptions & (
- EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
- this.mEditorInfo = editorInfo;
-
- this.mHashCode = Arrays.hashCode(new Object[] {
- locale,
- orientation,
- width,
- mode,
- xmlId,
- elementState,
- mNavigateAction,
- mPasswordInput,
- hasSettingsKey,
- f2KeyMode,
- clobberSettingsKey,
- shortcutKeyEnabled,
- hasShortcutKey,
- mImeAction,
+ this.mHashCode = hashCode(this);
+ }
+
+ private static int hashCode(KeyboardId id) {
+ return Arrays.hashCode(new Object[] {
+ id.mOrientation,
+ id.mElementState,
+ id.mMode,
+ id.mWidth,
+ id.mXmlId,
+ id.navigateAction(),
+ id.passwordInput(),
+ id.mSettingsKeyEnabled,
+ id.mClobberSettingsKey,
+ id.mShortcutKeyEnabled,
+ id.mHasShortcutKey,
+ id.imeAction(),
+ id.mLocale
});
}
+ private boolean equals(KeyboardId other) {
+ if (other == this)
+ return true;
+ return other.mOrientation == this.mOrientation
+ && other.mElementState == this.mElementState
+ && other.mMode == this.mMode
+ && other.mWidth == this.mWidth
+ && other.mXmlId == this.mXmlId
+ && other.navigateAction() == this.navigateAction()
+ && other.passwordInput() == this.passwordInput()
+ && other.mSettingsKeyEnabled == this.mSettingsKeyEnabled
+ && other.mClobberSettingsKey == this.mClobberSettingsKey
+ && other.mShortcutKeyEnabled == this.mShortcutKeyEnabled
+ && other.mHasShortcutKey == this.mHasShortcutKey
+ && other.imeAction() == this.imeAction()
+ && other.mLocale.equals(this.mLocale);
+ }
+
public KeyboardId cloneWithNewXml(int xmlId) {
- return new KeyboardId(xmlId, mElementState, mLocale,
- mOrientation, mWidth, mMode, mEditorInfo, false, F2KEY_MODE_NONE, false, false,
- false);
+ return new KeyboardId(xmlId, mElementState, mLocale, mOrientation, mWidth, mMode,
+ mInputType, mImeOptions, false, false, false, false);
}
// Remove this method.
@@ -154,28 +162,50 @@ public class KeyboardId {
return mElementState == ELEMENT_PHONE_SHIFT;
}
+ public boolean navigateAction() {
+ // Note: Turn off checking navigation flag to show TAB key for now.
+ boolean navigateAction = InputTypeCompatUtils.isWebInputType(mInputType);
+// || EditorInfoCompatUtils.hasFlagNavigateNext(mImeOptions)
+// || EditorInfoCompatUtils.hasFlagNavigatePrevious(mImeOptions);
+ return navigateAction;
+ }
+
+ public boolean passwordInput() {
+ return InputTypeCompatUtils.isPasswordInputType(mInputType)
+ || InputTypeCompatUtils.isVisiblePasswordInputType(mInputType);
+ }
+
+ public int imeAction() {
+ // We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and
+ // {@link EditorInfo#IME_FLAG_NO_ENTER_ACTION}.
+ return mImeOptions & (
+ EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
+ }
+
+ public boolean hasSettingsKey() {
+ return mSettingsKeyEnabled && !mClobberSettingsKey;
+ }
+
+ public int f2KeyMode() {
+ if (mClobberSettingsKey) {
+ // Never shows the Settings key
+ return KeyboardId.F2KEY_MODE_SHORTCUT_IME;
+ }
+
+ if (mSettingsKeyEnabled) {
+ return KeyboardId.F2KEY_MODE_SETTINGS;
+ } else {
+ // It should be alright to fall back to the Settings key on 7-inch layouts
+ // even when the Settings key is not explicitly enabled.
+ return KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
+ }
+ }
+
@Override
public boolean equals(Object other) {
return other instanceof KeyboardId && equals((KeyboardId) other);
}
- private boolean equals(KeyboardId other) {
- return other.mLocale.equals(this.mLocale)
- && other.mOrientation == this.mOrientation
- && other.mWidth == this.mWidth
- && other.mMode == this.mMode
- && other.mXmlId == this.mXmlId
- && other.mElementState == this.mElementState
- && other.mNavigateAction == this.mNavigateAction
- && other.mPasswordInput == this.mPasswordInput
- && other.mHasSettingsKey == this.mHasSettingsKey
- && other.mF2KeyMode == this.mF2KeyMode
- && other.mClobberSettingsKey == this.mClobberSettingsKey
- && other.mShortcutKeyEnabled == this.mShortcutKeyEnabled
- && other.mHasShortcutKey == this.mHasShortcutKey
- && other.mImeAction == this.mImeAction;
- }
-
@Override
public int hashCode() {
return mHashCode;
@@ -188,12 +218,12 @@ public class KeyboardId {
mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode),
- EditorInfoCompatUtils.imeOptionsName(mImeAction),
- f2KeyModeName(mF2KeyMode),
+ EditorInfoCompatUtils.imeOptionsName(imeAction()),
+ f2KeyModeName(f2KeyMode()),
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
- (mNavigateAction ? " navigateAction" : ""),
- (mPasswordInput ? " passwordInput" : ""),
- (mHasSettingsKey ? " hasSettingsKey" : ""),
+ (navigateAction() ? " navigateAction" : ""),
+ (passwordInput() ? " passwordInput" : ""),
+ (hasSettingsKey() ? " hasSettingsKey" : ""),
(mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""),
(mHasShortcutKey ? " hasShortcutKey" : "")
);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
index 9f182aff4..a28cfa85d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
@@ -69,11 +69,10 @@ public class KeyboardSet {
new HashMap<Integer, Integer>();
private final int mMode;
+ private final boolean mSettingsKeyEnabled;
private final boolean mVoiceKeyEnabled;
- private final boolean mNoSettingsKey;
- private final boolean mHasSettingsKey;
- private final int mF2KeyMode;
private final boolean mVoiceKeyOnMain;
+ private final boolean mNoSettingsKey;
private final Locale mLocale;
private final Configuration mConf;
private final DisplayMetrics mMetrics;
@@ -85,7 +84,7 @@ public class KeyboardSet {
final String packageName = context.getPackageName();
mMode = Utils.getKeyboardMode(mEditorInfo);
- final boolean settingsKeyEnabled = settingsValues.isSettingsKeyEnabled();
+ mSettingsKeyEnabled = settingsValues.isSettingsKeyEnabled();
@SuppressWarnings("deprecation")
final boolean noMicrophone = Utils.inPrivateImeOptions(
packageName, LatinIME.IME_OPTION_NO_MICROPHONE, editorInfo)
@@ -95,8 +94,6 @@ public class KeyboardSet {
mVoiceKeyOnMain = settingsValues.isVoiceKeyOnMain();
mNoSettingsKey = Utils.inPrivateImeOptions(
packageName, LatinIME.IME_OPTION_NO_SETTINGS_KEY, editorInfo);
- mHasSettingsKey = settingsKeyEnabled && !mNoSettingsKey;
- mF2KeyMode = getF2KeyMode(settingsKeyEnabled, mNoSettingsKey);
final boolean forceAscii = Utils.inPrivateImeOptions(
packageName, LatinIME.IME_OPTION_FORCE_ASCII, editorInfo);
final boolean asciiCapable = subtypeSwitcher.currentSubtypeContainsExtraValueKey(
@@ -123,8 +120,8 @@ public class KeyboardSet {
final int xmlId = mElementKeyboards.get(elementState);
final boolean hasShortcutKey = mVoiceKeyEnabled && (isSymbols != mVoiceKeyOnMain);
return new KeyboardId(xmlId, elementState, mLocale, mConf.orientation,
- mMetrics.widthPixels, mMode, mEditorInfo, mHasSettingsKey, mF2KeyMode,
- mNoSettingsKey, mVoiceKeyEnabled, hasShortcutKey);
+ mMetrics.widthPixels, mMode, mEditorInfo, mSettingsKeyEnabled, mNoSettingsKey,
+ mVoiceKeyEnabled, hasShortcutKey);
}
private static int getElementState(int mode, boolean isSymbols, boolean isShift) {
@@ -142,22 +139,6 @@ public class KeyboardSet {
}
}
- // TODO: Move to KeyboardId.
- private static int getF2KeyMode(boolean settingsKeyEnabled, boolean noSettingsKey) {
- if (noSettingsKey) {
- // Never shows the Settings key
- return KeyboardId.F2KEY_MODE_SHORTCUT_IME;
- }
-
- if (settingsKeyEnabled) {
- return KeyboardId.F2KEY_MODE_SETTINGS;
- } else {
- // It should be alright to fall back to the Settings key on 7-inch layouts
- // even when the Settings key is not explicitly enabled.
- return KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
- }
- }
-
private void parseKeyboardSet(Resources res, int resId) throws XmlPullParserException,
IOException {
final XmlResourceParser parser = res.getXml(resId);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 165e9aec7..1f3006d9f 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -191,11 +191,11 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
if (DEBUG_CACHE) {
Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": "
+ ((ref == null) ? "LOAD" : "GCed") + " id=" + id
- + " theme=" + Keyboard.themeName(keyboard.mThemeId));
+ + " theme=" + themeName(keyboard.mThemeId));
}
} else if (DEBUG_CACHE) {
Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": HIT id=" + id
- + " theme=" + Keyboard.themeName(keyboard.mThemeId));
+ + " theme=" + themeName(keyboard.mThemeId));
}
keyboard.onAutoCorrectionStateChanged(mIsAutoCorrectionActive);
@@ -463,4 +463,17 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
}
}
}
+
+ private static String themeName(int themeId) {
+ // This should be aligned with theme-*.xml resource files' themeId attribute.
+ switch (themeId) {
+ case 0: return "Basic";
+ case 1: return "BasicHighContrast";
+ case 5: return "IceCreamSandwich";
+ case 6: return "Stone";
+ case 7: return "StoneBold";
+ case 8: return "GingerBread";
+ default: return null;
+ }
+ }
}
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index af5f808fd..e56f2ea84 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -409,19 +409,16 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
invokeReleaseKey(primaryCode);
return true;
}
- }
- if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
- // Both long pressing settings key and space key invoke IME switcher dialog.
- if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
- tracker.onLongPressed();
- invokeReleaseKey(primaryCode);
- return true;
- } else {
- return openMoreKeysPanel(parentKey, tracker);
+ if (primaryCode == Keyboard.CODE_SPACE) {
+ // Long pressing the space key invokes IME switcher dialog.
+ if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
+ tracker.onLongPressed();
+ invokeReleaseKey(primaryCode);
+ return true;
+ }
}
- } else {
- return openMoreKeysPanel(parentKey, tracker);
}
+ return openMoreKeysPanel(parentKey, tracker);
}
private boolean invokeCustomRequest(int code) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index a88a1638c..7382cfa7f 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -613,13 +613,13 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean modeMatched = matchTypedValue(a,
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
final boolean navigateActionMatched = matchBoolean(a,
- R.styleable.Keyboard_Case_navigateAction, id.mNavigateAction);
+ R.styleable.Keyboard_Case_navigateAction, id.navigateAction());
final boolean passwordInputMatched = matchBoolean(a,
- R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput);
+ R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
final boolean hasSettingsKeyMatched = matchBoolean(a,
- R.styleable.Keyboard_Case_hasSettingsKey, id.mHasSettingsKey);
+ R.styleable.Keyboard_Case_hasSettingsKey, id.hasSettingsKey());
final boolean f2KeyModeMatched = matchInteger(a,
- R.styleable.Keyboard_Case_f2KeyMode, id.mF2KeyMode);
+ R.styleable.Keyboard_Case_f2KeyMode, id.f2KeyMode());
final boolean clobberSettingsKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
final boolean shortcutKeyEnabledMatched = matchBoolean(a,
@@ -631,7 +631,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
// {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching
// this attribute with id.mImeOptions as integer value is enough for our purpose.
final boolean imeActionMatched = matchInteger(a,
- R.styleable.Keyboard_Case_imeAction, id.mImeAction);
+ R.styleable.Keyboard_Case_imeAction, id.imeAction());
final boolean localeCodeMatched = matchString(a,
R.styleable.Keyboard_Case_localeCode, id.mLocale.toString());
final boolean languageCodeMatched = matchString(a,
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index eb2f7971e..98fea1b5b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1586,7 +1586,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mHandler.postUpdateSuggestions();
}
- boolean pickedDefault = false;
// Handle separator
final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
@@ -1603,27 +1602,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled
&& !mInputTypeNoAutoCorrect;
if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) {
- pickedDefault = pickDefaultSuggestion(primaryCode);
+ commitCurrentAutoCorrection(primaryCode, ic);
} else {
commitTyped(ic);
}
}
- if (pickedDefault) {
- final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
- final String typedWord = mWordComposer.getTypedWord();
- if (TextUtils.isEmpty(typedWord)) {
- throw new RuntimeException("We have non-committed chars but the typed word "
- + "is empty? Impossible! I must commit suicide.");
- }
- if (!typedWord.equals(autoCorrection)) {
- // This will make the correction flash for a short while as a visual clue
- // to the user that auto-correction happened.
- InputConnectionCompatUtils.commitCorrection(
- ic, mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
- }
- }
-
final boolean swapMagicSpace;
if (Keyboard.CODE_ENTER == primaryCode && (SPACE_STATE_MAGIC == spaceState
|| SPACE_STATE_SWAP_PUNCTUATION == spaceState)) {
@@ -1875,7 +1859,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
setSuggestionStripShown(isSuggestionsStripVisible());
}
- private boolean pickDefaultSuggestion(int separatorCode) {
+ private void commitCurrentAutoCorrection(final int separatorCodePoint,
+ final InputConnection ic) {
// Complete any pending suggestions query first
if (mHandler.hasPendingUpdateSuggestions()) {
mHandler.cancelUpdateSuggestions();
@@ -1884,7 +1869,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
if (autoCorrection != null) {
final String typedWord = mWordComposer.getTypedWord();
- Utils.Stats.onAutoCorrection(typedWord, autoCorrection.toString(), separatorCode);
+ if (TextUtils.isEmpty(typedWord)) {
+ throw new RuntimeException("We have an auto-correction but the typed word "
+ + "is empty? Impossible! I must commit suicide.");
+ }
+ Utils.Stats.onAutoCorrection(typedWord, autoCorrection.toString(), separatorCodePoint);
mExpectingUpdateSelection = true;
commitBestWord(autoCorrection);
if (!autoCorrection.equals(typedWord)) {
@@ -1893,9 +1882,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Add the word to the user unigram dictionary if it's not a known word
addToUserUnigramAndBigramDictionaries(autoCorrection,
UserUnigramDictionary.FREQUENCY_FOR_TYPED);
- return true;
+ if (!typedWord.equals(autoCorrection) && null != ic) {
+ // This will make the correction flash for a short while as a visual clue
+ // to the user that auto-correction happened.
+ InputConnectionCompatUtils.commitCorrection(ic,
+ mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
+ }
}
- return false;
}
@Override