From 610f1dc8553cf2ed97e763a06a19380c4a6cd636 Mon Sep 17 00:00:00 2001 From: satok Date: Thu, 17 Mar 2011 22:49:06 -0700 Subject: Use reflections for classes related to InputMethodSubtype Change-Id: Ica53ce879c2b4c5eb47f757fb788a795a881c30e --- .../compat/InputMethodManagerCompatWrapper.java | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java (limited to 'java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java') diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java new file mode 100644 index 000000000..648b1892b --- /dev/null +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.compat; + +import android.content.Context; +import android.os.IBinder; +import android.util.Log; +import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodManager; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +// TODO: Override this class with the concrete implementation if we need to take care of the +// performance. +public class InputMethodManagerCompatWrapper { + private static final String TAG = InputMethodManagerCompatWrapper.class.getSimpleName(); + private static final Method METHOD_getCurrentInputMethodSubtype = + CompatUtils.getMethod(InputMethodManager.class, "getCurrentInputMethodSubtype"); + private static final Method METHOD_getEnabledInputMethodSubtypeList = + CompatUtils.getMethod(InputMethodManager.class, "getEnabledInputMethodSubtypeList", + InputMethodInfo.class, boolean.class); + private static final Method METHOD_getShortcutInputMethodsAndSubtypes = + CompatUtils.getMethod(InputMethodManager.class, "getShortcutInputMethodsAndSubtypes"); + private static final Method METHOD_setInputMethodAndSubtype = + CompatUtils.getMethod( + InputMethodManager.class, "setInputMethodAndSubtype", IBinder.class, + String.class, InputMethodSubtypeCompatWrapper.CLASS_InputMethodSubtype); + + private static final InputMethodManagerCompatWrapper sInstance = + new InputMethodManagerCompatWrapper(); + + private InputMethodManager mImm; + private InputMethodManagerCompatWrapper() { + } + + public static InputMethodManagerCompatWrapper getInstance(Context context) { + if (sInstance.mImm == null) { + sInstance.init(context); + } + return sInstance; + } + + private synchronized void init(Context context) { + mImm = (InputMethodManager) context.getSystemService( + Context.INPUT_METHOD_SERVICE); + } + + public InputMethodSubtypeCompatWrapper getCurrentInputMethodSubtype() { + return new InputMethodSubtypeCompatWrapper( + CompatUtils.invoke(mImm, null, METHOD_getCurrentInputMethodSubtype)); + } + + public List getEnabledInputMethodSubtypeList( + InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { + Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList, + imi, allowsImplicitlySelectedSubtypes); + return CompatUtils.copyInputMethodSubtypeListToWrappler((List)retval); + } + + public Map> + getShortcutInputMethodsAndSubtypes() { + Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes); + if (!(retval instanceof Map)) return null; + Map> shortcutMap = + new HashMap>(); + final Map retvalMap = (Map)retval; + for (Object key: retvalMap.keySet()) { + if (!(key instanceof InputMethodInfo)) { + Log.e(TAG, "Class type error."); + return null; + } + shortcutMap.put((InputMethodInfo)key, CompatUtils.copyInputMethodSubtypeListToWrappler( + retvalMap.get(key))); + } + return shortcutMap; + } + + public void setInputMethodAndSubtype( + IBinder token, String id, InputMethodSubtypeCompatWrapper subtype) { + CompatUtils.invoke(mImm, null, METHOD_setInputMethodAndSubtype, + token, id, subtype.getOriginalObject()); + } + + public boolean switchToLastInputMethod(IBinder token) { + if (mImm == null) return false; + return mImm.switchToLastInputMethod(token); + } + + public List getEnabledInputMethodList() { + if (mImm == null) return null; + return mImm.getEnabledInputMethodList(); + } + + public void showInputMethodPicker() { + if (mImm == null) return; + mImm.showInputMethodPicker(); + } +} -- cgit v1.2.3-83-g751a From 10dd34de0ffcde0104f7d2dae3a3c9fd66abffcc Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 18 Mar 2011 21:22:28 -0700 Subject: Add InputMethodServiceCompatWrapper for moving the callback from LatinIME. Change-Id: If6b0180c63738e5e78a20fe5b938ef50d62865d6 --- .../android/inputmethod/compat/CompatUtils.java | 2 +- .../compat/InputMethodManagerCompatWrapper.java | 4 +- .../compat/InputMethodServiceCompatWrapper.java | 65 ++++++++++++++++++++++ .../inputmethod/deprecated/VoiceConnector.java | 15 ++++- .../com/android/inputmethod/latin/LatinIME.java | 11 +--- .../android/inputmethod/latin/SubtypeSwitcher.java | 19 ++++++- 6 files changed, 100 insertions(+), 16 deletions(-) create mode 100644 java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java (limited to 'java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java') diff --git a/java/src/com/android/inputmethod/compat/CompatUtils.java b/java/src/com/android/inputmethod/compat/CompatUtils.java index 157446654..fea15fda5 100644 --- a/java/src/com/android/inputmethod/compat/CompatUtils.java +++ b/java/src/com/android/inputmethod/compat/CompatUtils.java @@ -94,7 +94,7 @@ public class CompatUtils { } } - public static List copyInputMethodSubtypeListToWrappler( + public static List copyInputMethodSubtypeListToWrapper( Object listObject) { if (!(listObject instanceof List)) return null; final List subtypes = diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index 648b1892b..81cf02c35 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -71,7 +71,7 @@ public class InputMethodManagerCompatWrapper { InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList, imi, allowsImplicitlySelectedSubtypes); - return CompatUtils.copyInputMethodSubtypeListToWrappler((List)retval); + return CompatUtils.copyInputMethodSubtypeListToWrapper((List)retval); } public Map> @@ -86,7 +86,7 @@ public class InputMethodManagerCompatWrapper { Log.e(TAG, "Class type error."); return null; } - shortcutMap.put((InputMethodInfo)key, CompatUtils.copyInputMethodSubtypeListToWrappler( + shortcutMap.put((InputMethodInfo)key, CompatUtils.copyInputMethodSubtypeListToWrapper( retvalMap.get(key))); } return shortcutMap; diff --git a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java new file mode 100644 index 000000000..72f3ca0d0 --- /dev/null +++ b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.compat; + +import com.android.inputmethod.latin.SubtypeSwitcher; + +import android.inputmethodservice.InputMethodService; +import android.view.inputmethod.InputMethodSubtype; + +public class InputMethodServiceCompatWrapper extends InputMethodService { + // CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED needs to be false if the API level is 10 + // or previous. Note that InputMethodSubtype was added in the API level 11. + // For the API level 11 or later, LatinIME should override onCurrentInputMethodSubtypeChanged(). + // For the API level 10 or previous, we handle the "subtype changed" events by ourselves + // without having support from framework -- onCurrentInputMethodSubtypeChanged(). + private static final boolean CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED = true; + + private InputMethodManagerCompatWrapper mImm; + + @Override + public void onCreate() { + super.onCreate(); + mImm = InputMethodManagerCompatWrapper.getInstance(this); + } + + // When the API level is 10 or previous, notifyOnCurrentInputMethodSubtypeChanged should + // handle the event the current subtype was changed. LatinIME calls + // notifyOnCurrentInputMethodSubtypeChanged every time LatinIME + // changes the current subtype. + // This call is required to let LatinIME itself know a subtype changed + // event when the API level is 10 or previous. + @SuppressWarnings("unused") + public void notifyOnCurrentInputMethodSubtypeChanged(InputMethodSubtypeCompatWrapper subtype) { + // Do nothing when the API level is 11 or later + if (CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) return; + if (subtype == null) { + subtype = mImm.getCurrentInputMethodSubtype(); + } + if (subtype != null) { + SubtypeSwitcher.getInstance().updateSubtype(subtype); + } + } + + @Override + public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { + // Do nothing when the API level is 10 or previous + if (!CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) return; + SubtypeSwitcher.getInstance().updateSubtype( + new InputMethodSubtypeCompatWrapper(subtype)); + } +} diff --git a/java/src/com/android/inputmethod/deprecated/VoiceConnector.java b/java/src/com/android/inputmethod/deprecated/VoiceConnector.java index 5c78e9d24..a5c307c5b 100644 --- a/java/src/com/android/inputmethod/deprecated/VoiceConnector.java +++ b/java/src/com/android/inputmethod/deprecated/VoiceConnector.java @@ -566,14 +566,24 @@ public class VoiceConnector implements VoiceInput.UiListener { @Override protected void onPostExecute(Boolean result) { + // Calls in this method need to be done in the same thread as the thread which + // called switchToLastInputMethod() if (!result) { if (DEBUG) { Log.d(TAG, "Couldn't switch back to last IME."); } - // Needs to reset here because LatinIME failed to back to any IME and - // the same voice subtype will be triggered in the next time. + // Because the current IME and subtype failed to switch to any other IME and + // subtype by switchToLastInputMethod, the current IME and subtype should keep + // being LatinIME and voice subtype in the next time. And for re-showing voice + // mode, the state of voice input should be reset and the voice view should be + // hidden. mVoiceInput.reset(); mService.requestHideSelf(0); + } else { + // Notify an event that the current subtype was changed. This event will be + // handled if "onCurrentInputMethodSubtypeChanged" can't be implemented + // when the API level is 10 or previous. + mService.notifyOnCurrentInputMethodSubtypeChanged(null); } } }.execute(); @@ -630,6 +640,7 @@ public class VoiceConnector implements VoiceInput.UiListener { } private boolean shouldShowVoiceButton(FieldContext fieldContext, EditorInfo attribute) { + @SuppressWarnings("deprecation") final boolean noMic = Utils.inPrivateImeOptions(null, LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT, attribute) || Utils.inPrivateImeOptions(mService.getPackageName(), diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b34d4575b..b89fcbfcf 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -18,7 +18,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; -import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper; +import com.android.inputmethod.compat.InputMethodServiceCompatWrapper; import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; @@ -69,7 +69,6 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; -import android.view.inputmethod.InputMethodSubtype; import android.widget.FrameLayout; import android.widget.HorizontalScrollView; import android.widget.LinearLayout; @@ -83,7 +82,7 @@ import java.util.Locale; /** * Input method implementation for Qwerty'ish keyboard. */ -public class LatinIME extends InputMethodService implements KeyboardActionListener { +public class LatinIME extends InputMethodServiceCompatWrapper implements KeyboardActionListener { private static final String TAG = LatinIME.class.getSimpleName(); private static final boolean PERF_DEBUG = false; private static final boolean TRACE = false; @@ -96,6 +95,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen * * @deprecated Use {@link LatinIME#IME_OPTION_NO_MICROPHONE} with package name prefixed. */ + @SuppressWarnings("dep-ann") public static final String IME_OPTION_NO_MICROPHONE_COMPAT = "nm"; /** @@ -2339,9 +2339,4 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen for (int i = 0; i < CPS_BUFFER_SIZE; i++) total += mCpsIntervals[i]; System.out.println("CPS = " + ((CPS_BUFFER_SIZE * 1000f) / total)); } - - @Override - public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { - SubtypeSwitcher.getInstance().updateSubtype(new InputMethodSubtypeCompatWrapper(subtype)); - } } diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 4bdd01556..d4db7d0f7 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -31,6 +31,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.AsyncTask; import android.os.IBinder; import android.text.TextUtils; import android.util.Log; @@ -308,12 +309,24 @@ public class SubtypeSwitcher { } final String imiId = mShortcutInputMethodInfo.getId(); final InputMethodSubtypeCompatWrapper subtype = mShortcutSubtype; - new Thread("SwitchToShortcutIME") { + new AsyncTask() { @Override - public void run() { + protected Void doInBackground(Void... params) { mImm.setInputMethodAndSubtype(token, imiId, subtype); + return null; } - }.start(); + + @Override + protected void onPostExecute(Void result) { + // Calls in this method need to be done in the same thread as the thread which + // called switchToShortcutIME(). + + // Notify an event that the current subtype was changed. This event will be + // handled if "onCurrentInputMethodSubtypeChanged" can't be implemented + // when the API level is 10 or previous. + mService.notifyOnCurrentInputMethodSubtypeChanged(subtype); + } + }.execute(); } public Drawable getShortcutIcon() { -- cgit v1.2.3-83-g751a From 2e36fb68d014838a24d1daa1bcbda04254d69be1 Mon Sep 17 00:00:00 2001 From: satok Date: Wed, 23 Mar 2011 14:01:05 -0700 Subject: Added InputMethodInfoCompatWrapper Change-Id: I5f2970e986afbe3b0b24ccf819f57f524e83ef3f --- .../compat/InputMethodInfoCompatWrapper.java | 59 ++++++++++++++++++++++ .../compat/InputMethodManagerCompatWrapper.java | 25 +++++---- .../android/inputmethod/latin/SubtypeSwitcher.java | 11 ++-- java/src/com/android/inputmethod/latin/Utils.java | 4 +- 4 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java (limited to 'java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java') diff --git a/java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java new file mode 100644 index 000000000..8e22bbc79 --- /dev/null +++ b/java/src/com/android/inputmethod/compat/InputMethodInfoCompatWrapper.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.compat; + +import android.content.pm.ServiceInfo; +import android.view.inputmethod.InputMethodInfo; + +import java.lang.reflect.Method; + +public class InputMethodInfoCompatWrapper { + private final InputMethodInfo mImi; + private static final Method METHOD_getSubtypeAt = CompatUtils.getMethod( + InputMethodInfo.class, "getSubtypeAt", int.class); + private static final Method METHOD_getSubtypeCount = CompatUtils.getMethod( + InputMethodInfo.class, "getSubtypeCount"); + + public InputMethodInfoCompatWrapper(InputMethodInfo imi) { + mImi = imi; + } + + public InputMethodInfo getInputMethodInfo() { + return mImi; + } + + public String getId() { + return mImi.getId(); + } + + public String getPackageName() { + return mImi.getPackageName(); + } + + public ServiceInfo getServiceInfo() { + return mImi.getServiceInfo(); + } + + public int getSubtypeCount() { + return (Integer) CompatUtils.invoke(mImi, 0, METHOD_getSubtypeCount); + } + + public InputMethodSubtypeCompatWrapper getSubtypeAt(int index) { + return new InputMethodSubtypeCompatWrapper(CompatUtils.invoke(mImi, null, + METHOD_getSubtypeAt, index)); + } +} diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index 81cf02c35..d1747ba5f 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -23,6 +23,7 @@ import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -68,26 +69,26 @@ public class InputMethodManagerCompatWrapper { } public List getEnabledInputMethodSubtypeList( - InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { + InputMethodInfoCompatWrapper imi, boolean allowsImplicitlySelectedSubtypes) { Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList, - imi, allowsImplicitlySelectedSubtypes); + (imi != null ? imi.getInputMethodInfo() : null), allowsImplicitlySelectedSubtypes); return CompatUtils.copyInputMethodSubtypeListToWrapper((List)retval); } - public Map> + public Map> getShortcutInputMethodsAndSubtypes() { Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes); if (!(retval instanceof Map)) return null; - Map> shortcutMap = - new HashMap>(); + Map> shortcutMap = + new HashMap>(); final Map retvalMap = (Map)retval; - for (Object key: retvalMap.keySet()) { + for (Object key : retvalMap.keySet()) { if (!(key instanceof InputMethodInfo)) { Log.e(TAG, "Class type error."); return null; } - shortcutMap.put((InputMethodInfo)key, CompatUtils.copyInputMethodSubtypeListToWrapper( - retvalMap.get(key))); + shortcutMap.put(new InputMethodInfoCompatWrapper((InputMethodInfo)key), + CompatUtils.copyInputMethodSubtypeListToWrapper(retvalMap.get(key))); } return shortcutMap; } @@ -103,9 +104,13 @@ public class InputMethodManagerCompatWrapper { return mImm.switchToLastInputMethod(token); } - public List getEnabledInputMethodList() { + public List getEnabledInputMethodList() { if (mImm == null) return null; - return mImm.getEnabledInputMethodList(); + List imis = new ArrayList(); + for (InputMethodInfo imi : mImm.getEnabledInputMethodList()) { + imis.add(new InputMethodInfoCompatWrapper(imi)); + } + return imis; } public void showInputMethodPicker() { diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index d4db7d0f7..9bc96995f 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.compat.InputMethodInfoCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper; import com.android.inputmethod.deprecated.VoiceConnector; @@ -35,7 +36,6 @@ import android.os.AsyncTask; import android.os.IBinder; import android.text.TextUtils; import android.util.Log; -import android.view.inputmethod.InputMethodInfo; import java.util.ArrayList; import java.util.Arrays; @@ -71,7 +71,7 @@ public class SubtypeSwitcher { // Variants which should be changed only by reload functions. private boolean mNeedsToDisplayLanguage; private boolean mIsSystemLanguageSameAsInputLanguage; - private InputMethodInfo mShortcutInputMethodInfo; + private InputMethodInfoCompatWrapper mShortcutInputMethodInfo; private InputMethodSubtypeCompatWrapper mShortcutSubtype; private List mAllEnabledSubtypesOfCurrentInputMethod; private InputMethodSubtypeCompatWrapper mCurrentSubtype; @@ -184,9 +184,9 @@ public class SubtypeSwitcher { + ", " + mShortcutSubtype.getMode()))); } // TODO: Update an icon for shortcut IME - Map> shortcuts = + final Map> shortcuts = mImm.getShortcutInputMethodsAndSubtypes(); - for (InputMethodInfo imi: shortcuts.keySet()) { + for (InputMethodInfoCompatWrapper imi : shortcuts.keySet()) { List subtypes = shortcuts.get(imi); // TODO: Returns the first found IMI for now. Should handle all shortcuts as // appropriate. @@ -333,7 +333,8 @@ public class SubtypeSwitcher { return getSubtypeIcon(mShortcutInputMethodInfo, mShortcutSubtype); } - private Drawable getSubtypeIcon(InputMethodInfo imi, InputMethodSubtypeCompatWrapper subtype) { + private Drawable getSubtypeIcon( + InputMethodInfoCompatWrapper imi, InputMethodSubtypeCompatWrapper subtype) { final PackageManager pm = mService.getPackageManager(); if (imi != null) { final String imiPackageName = imi.getPackageName(); diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index f48e1184b..2c21de8c0 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.compat.InputMethodInfoCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.keyboard.KeyboardId; @@ -29,7 +30,6 @@ import android.text.InputType; import android.text.format.DateUtils; import android.util.Log; import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodInfo; import java.io.BufferedReader; import java.io.File; @@ -109,7 +109,7 @@ public class Utils { } public static String getInputMethodId(InputMethodManagerCompatWrapper imm, String packageName) { - for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) { + for (final InputMethodInfoCompatWrapper imi : imm.getEnabledInputMethodList()) { if (imi.getPackageName().equals(packageName)) return imi.getId(); } -- cgit v1.2.3-83-g751a