aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java9
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java66
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeUtils.java19
3 files changed, 39 insertions, 55 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 69780d0fd..2cd291add 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -49,6 +49,7 @@ import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
@@ -56,7 +57,6 @@ import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
-import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import com.android.inputmethod.compat.SuggestionSpanUtils;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
@@ -627,6 +627,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mHandler.onFinishInput();
}
+ @Override
+ public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) {
+ SubtypeSwitcher.getInstance().updateSubtype(subtype);
+ }
+
private void onStartInputInternal(EditorInfo editorInfo, boolean restarting) {
super.onStartInput(editorInfo, restarting);
}
@@ -1178,7 +1183,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean includesOtherImes = mSettingsValues.mIncludesOtherImesInLanguageSwitchList;
final IBinder token = getWindow().getWindow().getAttributes().token;
if (mShouldSwitchToLastSubtype) {
- final InputMethodSubtypeCompatWrapper lastSubtype = mImm.getLastInputMethodSubtype();
+ final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
final boolean lastSubtypeBelongsToThisIme = SubtypeUtils.checkIfSubtypeBelongsToThisIme(
this, lastSubtype);
if ((includesOtherImes || lastSubtypeBelongsToThisIme)
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 794e5dc3a..e35364420 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -30,9 +30,9 @@ import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
-import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import java.util.ArrayList;
@@ -57,9 +57,8 @@ public class SubtypeSwitcher {
private /* final */ InputMethodManagerCompatWrapper mImm;
private /* final */ Resources mResources;
private /* final */ ConnectivityManager mConnectivityManager;
- private final ArrayList<InputMethodSubtypeCompatWrapper>
- mEnabledKeyboardSubtypesOfCurrentInputMethod =
- new ArrayList<InputMethodSubtypeCompatWrapper>();
+ private final ArrayList<InputMethodSubtype> mEnabledKeyboardSubtypesOfCurrentInputMethod =
+ new ArrayList<InputMethodSubtype>();
private final ArrayList<String> mEnabledLanguagesOfCurrentInputMethod = new ArrayList<String>();
/*-----------------------------------------------------------*/
@@ -67,9 +66,10 @@ public class SubtypeSwitcher {
private boolean mNeedsToDisplayLanguage;
private boolean mIsSystemLanguageSameAsInputLanguage;
private InputMethodInfo mShortcutInputMethodInfo;
- private InputMethodSubtypeCompatWrapper mShortcutSubtype;
- private List<InputMethodSubtypeCompatWrapper> mAllEnabledSubtypesOfCurrentInputMethod;
- private InputMethodSubtypeCompatWrapper mCurrentSubtype;
+ private InputMethodSubtype mShortcutSubtype;
+ private List<InputMethodSubtype> mAllEnabledSubtypesOfCurrentInputMethod;
+ // Note: This variable is always non-null after {@link #initialize(LatinIME)}.
+ private InputMethodSubtype mCurrentSubtype;
private Locale mSystemLocale;
private Locale mInputLocale;
private String mInputLocaleStr;
@@ -102,7 +102,7 @@ public class SubtypeSwitcher {
mSystemLocale = null;
mInputLocale = null;
mInputLocaleStr = null;
- mCurrentSubtype = null;
+ mCurrentSubtype = mImm.getCurrentInputMethodSubtype();
mAllEnabledSubtypesOfCurrentInputMethod = null;
final NetworkInfo info = mConnectivityManager.getActiveNetworkInfo();
@@ -132,7 +132,7 @@ public class SubtypeSwitcher {
null, true);
mEnabledLanguagesOfCurrentInputMethod.clear();
mEnabledKeyboardSubtypesOfCurrentInputMethod.clear();
- for (InputMethodSubtypeCompatWrapper ims : mAllEnabledSubtypesOfCurrentInputMethod) {
+ for (InputMethodSubtype ims : mAllEnabledSubtypesOfCurrentInputMethod) {
final String locale = getSubtypeLocale(ims);
final String mode = ims.getMode();
mLocaleSplitter.setString(locale);
@@ -166,12 +166,12 @@ public class SubtypeSwitcher {
+ ", " + mShortcutSubtype.getMode())));
}
// TODO: Update an icon for shortcut IME
- final Map<InputMethodInfo, List<InputMethodSubtypeCompatWrapper>> shortcuts =
+ final Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts =
mImm.getShortcutInputMethodsAndSubtypes();
mShortcutInputMethodInfo = null;
mShortcutSubtype = null;
for (InputMethodInfo imi : shortcuts.keySet()) {
- List<InputMethodSubtypeCompatWrapper> subtypes = shortcuts.get(imi);
+ List<InputMethodSubtype> subtypes = shortcuts.get(imi);
// TODO: Returns the first found IMI for now. Should handle all shortcuts as
// appropriate.
mShortcutInputMethodInfo = imi;
@@ -189,27 +189,17 @@ public class SubtypeSwitcher {
}
}
- private static String getSubtypeLocale(InputMethodSubtypeCompatWrapper subtype) {
+ private static String getSubtypeLocale(InputMethodSubtype subtype) {
final String keyboardLocale = subtype.getExtraValueOf(
LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LOCALE);
return keyboardLocale != null ? keyboardLocale : subtype.getLocale();
}
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
- public void updateSubtype(InputMethodSubtypeCompatWrapper newSubtype) {
- final String newLocale;
- final String newMode;
+ public void updateSubtype(InputMethodSubtype newSubtype) {
+ final String newLocale = getSubtypeLocale(newSubtype);
+ final String newMode = newSubtype.getMode();
final String oldMode = getCurrentSubtypeMode();
- if (newSubtype == null) {
- // Normally, newSubtype shouldn't be null. But just in case newSubtype was null,
- // fallback to the default locale.
- Log.w(TAG, "Couldn't get the current subtype.");
- newLocale = "en_US";
- newMode = KEYBOARD_MODE;
- } else {
- newLocale = getSubtypeLocale(newSubtype);
- newMode = newSubtype.getMode();
- }
if (DBG) {
Log.w(TAG, "Update subtype to:" + newLocale + "," + newMode
+ ", from: " + mInputLocaleStr + ", " + oldMode);
@@ -284,12 +274,10 @@ public class SubtypeSwitcher {
}
final String imiId = mShortcutInputMethodInfo.getId();
- final InputMethodSubtypeCompatWrapper subtype = mShortcutSubtype;
- switchToTargetIME(imiId, subtype);
+ switchToTargetIME(imiId, mShortcutSubtype);
}
- private void switchToTargetIME(
- final String imiId, final InputMethodSubtypeCompatWrapper subtype) {
+ private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype) {
final IBinder token = mService.getWindow().getWindow().getAttributes().token;
if (token == null) {
return;
@@ -307,7 +295,7 @@ public class SubtypeSwitcher {
return getSubtypeIcon(mShortcutInputMethodInfo, mShortcutSubtype);
}
- private Drawable getSubtypeIcon(InputMethodInfo imi, InputMethodSubtypeCompatWrapper subtype) {
+ private Drawable getSubtypeIcon(InputMethodInfo imi, InputMethodSubtype subtype) {
final PackageManager pm = mService.getPackageManager();
if (imi != null) {
final String imiPackageName = imi.getPackageName();
@@ -348,15 +336,9 @@ public class SubtypeSwitcher {
if (mShortcutSubtype == null) {
return true;
}
- // For compatibility, if the shortcut subtype is dummy, we assume the shortcut IME
- // (built-in voice dummy subtype) is available.
- if (!mShortcutSubtype.hasOriginalObject()) {
- return true;
- }
final boolean allowsImplicitlySelectedSubtypes = true;
- for (final InputMethodSubtypeCompatWrapper enabledSubtype :
- mImm.getEnabledInputMethodSubtypeList(
- mShortcutInputMethodInfo, allowsImplicitlySelectedSubtypes)) {
+ for (final InputMethodSubtype enabledSubtype : mImm.getEnabledInputMethodSubtypeList(
+ mShortcutInputMethodInfo, allowsImplicitlySelectedSubtypes)) {
if (enabledSubtype.equals(mShortcutSubtype)) {
return true;
}
@@ -448,20 +430,20 @@ public class SubtypeSwitcher {
public String getCurrentSubtypeExtraValue() {
// If null, return what an empty ExtraValue would return : the empty string.
- return null != mCurrentSubtype ? mCurrentSubtype.getExtraValue() : "";
+ return mCurrentSubtype.getExtraValue();
}
public boolean currentSubtypeContainsExtraValueKey(String key) {
// If null, return what an empty ExtraValue would return : false.
- return null != mCurrentSubtype ? mCurrentSubtype.containsExtraValueKey(key) : false;
+ return mCurrentSubtype.containsExtraValueKey(key);
}
public String getCurrentSubtypeExtraValueOf(String key) {
// If null, return what an empty ExtraValue would return : null.
- return null != mCurrentSubtype ? mCurrentSubtype.getExtraValueOf(key) : null;
+ return mCurrentSubtype.getExtraValueOf(key);
}
public String getCurrentSubtypeMode() {
- return null != mCurrentSubtype ? mCurrentSubtype.getMode() : KEYBOARD_MODE;
+ return mCurrentSubtype.getMode();
}
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeUtils.java b/java/src/com/android/inputmethod/latin/SubtypeUtils.java
index 8beb71bf1..2c5d58200 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeUtils.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeUtils.java
@@ -18,9 +18,9 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
-import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import java.util.Collections;
import java.util.List;
@@ -31,15 +31,13 @@ public class SubtypeUtils {
}
// TODO: Cache my InputMethodInfo and/or InputMethodSubtype list.
- public static boolean checkIfSubtypeBelongsToThisIme(Context context,
- InputMethodSubtypeCompatWrapper ims) {
+ public static boolean checkIfSubtypeBelongsToThisIme(Context context, InputMethodSubtype ims) {
final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance();
if (imm == null) return false;
final InputMethodInfo myImi = getInputMethodInfo(context.getPackageName());
- final List<InputMethodSubtypeCompatWrapper> subtypes =
- imm.getEnabledInputMethodSubtypeList(myImi, true);
- for (final InputMethodSubtypeCompatWrapper subtype : subtypes) {
+ final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(myImi, true);
+ for (final InputMethodSubtype subtype : subtypes) {
if (subtype.equals(ims)) {
return true;
}
@@ -74,7 +72,7 @@ public class SubtypeUtils {
for (InputMethodInfo imi : imiList) {
// We can return true immediately after we find two or more filtered IMEs.
if (filteredImisCount > 1) return true;
- final List<InputMethodSubtypeCompatWrapper> subtypes =
+ final List<InputMethodSubtype> subtypes =
imm.getEnabledInputMethodSubtypeList(imi, true);
// IMEs that have no subtypes should be counted.
if (subtypes.isEmpty()) {
@@ -83,7 +81,7 @@ public class SubtypeUtils {
}
int auxCount = 0;
- for (InputMethodSubtypeCompatWrapper subtype : subtypes) {
+ for (InputMethodSubtype subtype : subtypes) {
if (subtype.isAuxiliary()) {
++auxCount;
}
@@ -102,13 +100,12 @@ public class SubtypeUtils {
if (filteredImisCount > 1) {
return true;
}
- final List<InputMethodSubtypeCompatWrapper> subtypes =
- imm.getEnabledInputMethodSubtypeList(null, true);
+ final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(null, true);
int keyboardCount = 0;
// imm.getEnabledInputMethodSubtypeList(null, true) will return the current IME's
// both explicitly and implicitly enabled input method subtype.
// (The current IME should be LatinIME.)
- for (InputMethodSubtypeCompatWrapper subtype : subtypes) {
+ for (InputMethodSubtype subtype : subtypes) {
if (SubtypeSwitcher.KEYBOARD_MODE.equals(subtype.getMode())) {
++keyboardCount;
}