diff options
author | 2012-04-02 23:57:43 -0700 | |
---|---|---|
committer | 2012-04-02 23:57:43 -0700 | |
commit | 8443af57baa6d95ac39c55ba6988a9d5a28f86b5 (patch) | |
tree | 747edc2f559940c5cef4991ca5dba8a62d6c5299 /java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java | |
parent | c734c2aca1830643d169fd292e0c9d4d9306af5a (diff) | |
parent | 9cc2c94c8b4bfd4e00e5d3478b9f6e520e791bc5 (diff) | |
download | latinime-8443af57baa6d95ac39c55ba6988a9d5a28f86b5.tar.gz latinime-8443af57baa6d95ac39c55ba6988a9d5a28f86b5.tar.xz latinime-8443af57baa6d95ac39c55ba6988a9d5a28f86b5.zip |
Merge "Remove InputMethodSubtypeCompatWrapper"
Diffstat (limited to 'java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java')
-rw-r--r-- | java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java | 72 |
1 files changed, 12 insertions, 60 deletions
diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index 0f03c2ef8..7f0b071a3 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -21,10 +21,9 @@ import android.os.IBinder; import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; +import android.view.inputmethod.InputMethodSubtype; import java.lang.reflect.Method; -import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,21 +31,6 @@ import java.util.Map; // 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_getLastInputMethodSubtype = - CompatUtils.getMethod(InputMethodManager.class, "getLastInputMethodSubtype"); - 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 Method METHOD_switchToLastInputMethod = CompatUtils.getMethod( - InputMethodManager.class, "switchToLastInputMethod", IBinder.class); private static final Method METHOD_switchToNextInputMethod = CompatUtils.getMethod( InputMethodManager.class, "switchToNextInputMethod", IBinder.class, Boolean.TYPE); @@ -66,62 +50,30 @@ public class InputMethodManagerCompatWrapper { Context.INPUT_METHOD_SERVICE); } - public InputMethodSubtypeCompatWrapper getCurrentInputMethodSubtype() { - Object o = CompatUtils.invoke(mImm, null, METHOD_getCurrentInputMethodSubtype); - return new InputMethodSubtypeCompatWrapper(o); + public InputMethodSubtype getCurrentInputMethodSubtype() { + return mImm.getCurrentInputMethodSubtype(); } - public InputMethodSubtypeCompatWrapper getLastInputMethodSubtype() { - Object o = CompatUtils.invoke(mImm, null, METHOD_getLastInputMethodSubtype); - return new InputMethodSubtypeCompatWrapper(o); + public InputMethodSubtype getLastInputMethodSubtype() { + return mImm.getLastInputMethodSubtype(); } - public List<InputMethodSubtypeCompatWrapper> getEnabledInputMethodSubtypeList( + public List<InputMethodSubtype> getEnabledInputMethodSubtypeList( InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { - Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList, - imi, allowsImplicitlySelectedSubtypes); - if (retval == null || !(retval instanceof List<?>) || ((List<?>)retval).isEmpty()) { - // Returns an empty list - return Collections.emptyList(); - } - return CompatUtils.copyInputMethodSubtypeListToWrapper(retval); + return mImm.getEnabledInputMethodSubtypeList(imi, allowsImplicitlySelectedSubtypes); } - public Map<InputMethodInfo, List<InputMethodSubtypeCompatWrapper>> - getShortcutInputMethodsAndSubtypes() { - Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes); - if (retval == null || !(retval instanceof Map<?, ?>) || ((Map<?, ?>)retval).isEmpty()) { - // Returns an empty map - return Collections.emptyMap(); - } - Map<InputMethodInfo, List<InputMethodSubtypeCompatWrapper>> shortcutMap = - new HashMap<InputMethodInfo, List<InputMethodSubtypeCompatWrapper>>(); - 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.copyInputMethodSubtypeListToWrapper(retvalMap.get(key))); - } - return shortcutMap; + public Map<InputMethodInfo, List<InputMethodSubtype>> getShortcutInputMethodsAndSubtypes() { + return mImm.getShortcutInputMethodsAndSubtypes(); } // We don't call this method when we switch between subtypes within this IME. - public void setInputMethodAndSubtype( - IBinder token, String id, InputMethodSubtypeCompatWrapper subtype) { - // TODO: Support subtype change on non-subtype-supported platform. - if (subtype != null && subtype.hasOriginalObject()) { - CompatUtils.invoke(mImm, null, METHOD_setInputMethodAndSubtype, - token, id, subtype.getOriginalObject()); - } else { - mImm.setInputMethod(token, id); - } + public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { + mImm.setInputMethodAndSubtype(token, id, subtype); } public boolean switchToLastInputMethod(IBinder token) { - return (Boolean)CompatUtils.invoke(mImm, false, METHOD_switchToLastInputMethod, token); + return mImm.switchToLastInputMethod(token); } public boolean switchToNextInputMethod(IBinder token, boolean onlyCurrentIme) { |