Merge "Move getLastInputMethodSubtype() logic to InputMethodSettings"
This commit is contained in:
committed by
Android (Google) Code Review
commit
461369d570
@@ -4167,23 +4167,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
if (!calledFromValidUserLocked()) {
|
||||
return null;
|
||||
}
|
||||
final Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
|
||||
// TODO: Handle the case of the last IME with no subtypes
|
||||
if (lastIme == null || TextUtils.isEmpty(lastIme.first)
|
||||
|| TextUtils.isEmpty(lastIme.second)) return null;
|
||||
final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
|
||||
if (lastImi == null) return null;
|
||||
try {
|
||||
final int lastSubtypeHash = Integer.parseInt(lastIme.second);
|
||||
final int lastSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode(lastImi,
|
||||
lastSubtypeHash);
|
||||
if (lastSubtypeId < 0 || lastSubtypeId >= lastImi.getSubtypeCount()) {
|
||||
return null;
|
||||
}
|
||||
return lastImi.getSubtypeAt(lastSubtypeId);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
return mSettings.getLastInputMethodSubtypeLocked();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -592,6 +592,27 @@ final class InputMethodUtils {
|
||||
return getLastSubtypeForInputMethodLockedInternal(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
InputMethodSubtype getLastInputMethodSubtypeLocked() {
|
||||
final Pair<String, String> lastIme = getLastInputMethodAndSubtypeLocked();
|
||||
// TODO: Handle the case of the last IME with no subtypes
|
||||
if (lastIme == null || TextUtils.isEmpty(lastIme.first)
|
||||
|| TextUtils.isEmpty(lastIme.second)) return null;
|
||||
final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
|
||||
if (lastImi == null) return null;
|
||||
try {
|
||||
final int lastSubtypeHash = Integer.parseInt(lastIme.second);
|
||||
final int lastSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode(lastImi,
|
||||
lastSubtypeHash);
|
||||
if (lastSubtypeId < 0 || lastSubtypeId >= lastImi.getSubtypeCount()) {
|
||||
return null;
|
||||
}
|
||||
return lastImi.getSubtypeAt(lastSubtypeId);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String getLastSubtypeForInputMethodLocked(String imeId) {
|
||||
Pair<String, String> ime = getLastSubtypeForInputMethodLockedInternal(imeId);
|
||||
if (ime != null) {
|
||||
|
||||
Reference in New Issue
Block a user