diff options
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 18 | ||||
-rw-r--r-- | core/java/com/android/internal/view/IInputMethodManager.aidl | 3 | ||||
-rw-r--r-- | services/java/com/android/server/InputMethodManagerService.java | 15 |
4 files changed, 36 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index 0bbcb37..936eb39 100644 --- a/api/current.txt +++ b/api/current.txt @@ -29299,6 +29299,7 @@ package android.view.inputmethod { method public boolean setCurrentInputMethodSubtype(android.view.inputmethod.InputMethodSubtype); method public void setInputMethod(android.os.IBinder, java.lang.String); method public void setInputMethodAndSubtype(android.os.IBinder, java.lang.String, android.view.inputmethod.InputMethodSubtype); + method public boolean shouldOfferSwitchingToNextInputMethod(android.os.IBinder); method public void showInputMethodAndSubtypeEnabler(java.lang.String); method public void showInputMethodPicker(); method public boolean showSoftInput(android.view.View, int); diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index c8ce6fa..f97e3dd 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1876,6 +1876,24 @@ public final class InputMethodManager { } /** + * Returns true if the current IME needs to offer the users a way to switch to a next input + * method. When the user triggers it, the IME has to call {@link #switchToNextInputMethod} to + * switch to a next input method which is selected by the system. + * @param imeToken Supplies the identifying token given to an input method when it was started, + * which allows it to perform this operation on itself. + */ + public boolean shouldOfferSwitchingToNextInputMethod(IBinder imeToken) { + synchronized (mH) { + try { + return mService.shouldOfferSwitchingToNextInputMethod(imeToken); + } catch (RemoteException e) { + Log.w(TAG, "IME died: " + mCurId, e); + return false; + } + } + } + + /** * Set additional input method subtypes. Only a process which shares the same uid with the IME * can add additional input method subtypes to the IME. * Please note that a subtype's status is stored in the system. diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index ebd3e1c..12ced68 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -56,7 +56,7 @@ interface IInputMethodManager { InputBindResult windowGainedFocus(in IInputMethodClient client, in IBinder windowToken, int controlFlags, int softInputMode, int windowFlags, in EditorInfo attribute, IInputContext inputContext); - + void showInputMethodPickerFromClient(in IInputMethodClient client); void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId); void setInputMethod(in IBinder token, String id); @@ -71,6 +71,7 @@ interface IInputMethodManager { boolean setCurrentInputMethodSubtype(in InputMethodSubtype subtype); boolean switchToLastInputMethod(in IBinder token); boolean switchToNextInputMethod(in IBinder token, boolean onlyCurrentIme); + boolean shouldOfferSwitchingToNextInputMethod(in IBinder token); boolean setInputMethodEnabled(String id, boolean enabled); oneway void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes); } diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index f442f11..45c614f 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -2159,6 +2159,21 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } @Override + public boolean shouldOfferSwitchingToNextInputMethod(IBinder token) { + if (!calledFromValidUser()) { + return false; + } + synchronized (mMethodMap) { + final ImeSubtypeListItem nextSubtype = mImListManager.getNextInputMethod( + false /* onlyCurrentIme */, mMethodMap.get(mCurMethodId), mCurrentSubtype); + if (nextSubtype == null) { + return false; + } + return true; + } + } + + @Override public InputMethodSubtype getLastInputMethodSubtype() { if (!calledFromValidUser()) { return null; |