diff options
| author | satok <satok@google.com> | 2010-11-19 18:45:53 +0900 |
|---|---|---|
| committer | satok <satok@google.com> | 2010-11-23 10:26:11 +0900 |
| commit | 4e4569dab5c75804b01a19b2d6e6101b445c1c68 (patch) | |
| tree | b8c01fe6563c0b2a2c782979ea52f4828f98e567 /core | |
| parent | e45674e284f690ca9c395811ae0703c276514f2b (diff) | |
| download | frameworks_base-4e4569dab5c75804b01a19b2d6e6101b445c1c68.zip frameworks_base-4e4569dab5c75804b01a19b2d6e6101b445c1c68.tar.gz frameworks_base-4e4569dab5c75804b01a19b2d6e6101b445c1c68.tar.bz2 | |
Add an API to get shortcut IMEs
- If there are no selected shortcut IMEs, the most applicable voice input will be selected as a shortcut IME
Change-Id: Ibd0f7ef5101013569c303820a3adc9038a97356d
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 34 | ||||
| -rw-r--r-- | core/java/com/android/internal/view/IInputMethodManager.aidl | 3 |
2 files changed, 37 insertions, 0 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index fe55f34..a5f3ade 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -23,6 +23,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; +import android.os.Parcelable; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; @@ -47,6 +48,7 @@ import com.android.internal.view.InputBindResult; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -1452,6 +1454,38 @@ public final class InputMethodManager { } } + public List<Pair<InputMethodInfo, InputMethodSubtype>> getShortcutInputMethodsAndSubtypes() { + synchronized (mH) { + List<Pair<InputMethodInfo, InputMethodSubtype>> ret = + new ArrayList<Pair<InputMethodInfo, InputMethodSubtype>>(); + try { + // TODO: We should change the return type from List<Object> to List<Parcelable> + List<Object> info = mService.getShortcutInputMethodsAndSubtypes(); + // "info" has imi1, subtype1, imi2, subtype2, imi3, subtype3,..... in the list + Object imi; + Object subtype; + if (info != null && info.size() > 0) { + final int N = info.size(); + if (N % 2 == 0) { + for (int i = 0; i < N;) { + if ((imi = info.get(i++)) instanceof InputMethodInfo) { + subtype = info.get(i++); + ret.add(new Pair<InputMethodInfo, InputMethodSubtype> ( + (InputMethodInfo)imi, + (subtype instanceof InputMethodSubtype) ? + (InputMethodSubtype)subtype : null)); + } + } + } else { + Log.w(TAG, "The size of list was illegal."); + } + } + } catch (RemoteException e) { + Log.w(TAG, "IME died: " + mCurId, e); + } + return ret; + } + } public boolean switchToLastInputMethod(IBinder imeToken) { synchronized (mH) { try { diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index 63d05ec..125b210 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -32,6 +32,9 @@ interface IInputMethodManager { List<InputMethodInfo> getInputMethodList(); List<InputMethodInfo> getEnabledInputMethodList(); List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in InputMethodInfo imi); + // TODO: We should change the return type from List to List<Parcelable> + // Currently there is a bug that aidl doesn't accept List<Parcelable> + List getShortcutInputMethodsAndSubtypes(); void addClient(in IInputMethodClient client, in IInputContext inputContext, int uid, int pid); void removeClient(in IInputMethodClient client); |
