From 8ba4f33709e6c40ade96922f88feace6e4b75b56 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 28 Apr 2014 07:39:00 +0900 Subject: Use shouldOfferSwitchingToNextInputMethod when available With this CL, LatinIME starts using InputMethodManager#shouldOfferSwitchingToNextInputMethod when available and API level is higher than 19 (KitKat). Note that relevant settings of LatinIME will be ignored if InputMethodManager#shouldOfferSwitchingToNextInputMethod is considered to be available at the moment. We will revisit here to reorganize the user visible settings before the new global IME switching mechanism becomes publicly available. BUG: 12965588 Change-Id: I0188fa56cba8e983c61cef3ae3400a0e3821f718 --- .../inputmethod/compat/InputMethodManagerCompatWrapper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (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 index a80c3fefe..18b3a6060 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -28,6 +28,12 @@ public final class InputMethodManagerCompatWrapper { private static final Method METHOD_switchToNextInputMethod = CompatUtils.getMethod( InputMethodManager.class, "switchToNextInputMethod", IBinder.class, Boolean.TYPE); + // Note that InputMethodManager.shouldOfferSwitchingToNextInputMethod() has been introduced + // in API level 19 (Build.VERSION_CODES.KITKAT). + private static final Method METHOD_shouldOfferSwitchingToNextInputMethod = + CompatUtils.getMethod(InputMethodManager.class, + "shouldOfferSwitchingToNextInputMethod", IBinder.class); + public final InputMethodManager mImm; public InputMethodManagerCompatWrapper(final Context context) { @@ -38,4 +44,9 @@ public final class InputMethodManagerCompatWrapper { return (Boolean)CompatUtils.invoke(mImm, false /* defaultValue */, METHOD_switchToNextInputMethod, token, onlyCurrentIme); } + + public boolean shouldOfferSwitchingToNextInputMethod(final IBinder token) { + return (Boolean)CompatUtils.invoke(mImm, false /* defaultValue */, + METHOD_shouldOfferSwitchingToNextInputMethod, token); + } } -- cgit v1.2.3-83-g751a