Add a setter of InputMethodSubtype to InputMethodManager

- Public API: void setCurrentInputMethodSubtype(int pos)

Change-Id: I55daa19ba924999def544bf841f00bf54852f3e1
This commit is contained in:
satok
2010-11-10 01:04:04 +09:00
parent 03eb319a3a
commit b66d287e30
4 changed files with 42 additions and 3 deletions

View File

@@ -988,8 +988,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
if (id.equals(mCurMethodId)) {
if (subtypeId != NOT_A_SUBTYPE_ID) {
InputMethodSubtype subtype = info.getSubtypes().get(subtypeId);
ArrayList<InputMethodSubtype> subtypes = info.getSubtypes();
if (subtypeId >= 0 && subtypeId < subtypes.size()) {
InputMethodSubtype subtype = subtypes.get(subtypeId);
if (subtype != mCurrentSubtype) {
synchronized (mMethodMap) {
if (mCurMethod != null) {
@@ -1964,6 +1965,20 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return mCurrentSubtype;
}
public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {
synchronized (mMethodMap) {
if (subtype != null && mCurMethodId != null) {
InputMethodInfo imi = mMethodMap.get(mCurMethodId);
int subtypeId = getSubtypeIdFromHashCode(imi, subtype.hashCode());
if (subtypeId != NOT_A_SUBTYPE_ID) {
setInputMethodLocked(mCurMethodId, subtypeId);
return true;
}
}
return false;
}
}
/**
* Utility class for putting and getting settings for InputMethod
* TODO: Move all putters and getters of settings to this class.