Merge "Fix checking if subtype belongs to this ime" into jb-dev
This commit is contained in:
commit
76d6673b2a
2 changed files with 17 additions and 3 deletions
|
@ -63,7 +63,8 @@ public class ImfUtils {
|
||||||
return getInputMethodInfoOfThisIme(context).getId();
|
return getInputMethodInfoOfThisIme(context).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkIfSubtypeBelongsToThisIme(Context context, InputMethodSubtype ims) {
|
public static boolean checkIfSubtypeBelongsToThisImeAndEnabled(Context context,
|
||||||
|
InputMethodSubtype ims) {
|
||||||
final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context);
|
final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context);
|
||||||
final InputMethodManager imm = getInputMethodManager(context);
|
final InputMethodManager imm = getInputMethodManager(context);
|
||||||
// TODO: Cache all subtypes of this IME for optimization
|
// TODO: Cache all subtypes of this IME for optimization
|
||||||
|
@ -76,6 +77,19 @@ public class ImfUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkIfSubtypeBelongsToThisIme(Context context,
|
||||||
|
InputMethodSubtype ims) {
|
||||||
|
final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context);
|
||||||
|
final int count = myImi.getSubtypeCount();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
final InputMethodSubtype subtype = myImi.getSubtypeAt(i);
|
||||||
|
if (subtype.equals(ims)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hasMultipleEnabledIMEsOrSubtypes(Context context,
|
public static boolean hasMultipleEnabledIMEsOrSubtypes(Context context,
|
||||||
final boolean shouldIncludeAuxiliarySubtypes) {
|
final boolean shouldIncludeAuxiliarySubtypes) {
|
||||||
final InputMethodManager imm = getInputMethodManager(context);
|
final InputMethodManager imm = getInputMethodManager(context);
|
||||||
|
|
|
@ -1148,8 +1148,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final IBinder token = getWindow().getWindow().getAttributes().token;
|
final IBinder token = getWindow().getWindow().getAttributes().token;
|
||||||
if (mShouldSwitchToLastSubtype) {
|
if (mShouldSwitchToLastSubtype) {
|
||||||
final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
|
final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
|
||||||
final boolean lastSubtypeBelongsToThisIme = ImfUtils.checkIfSubtypeBelongsToThisIme(
|
final boolean lastSubtypeBelongsToThisIme =
|
||||||
this, lastSubtype);
|
ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype);
|
||||||
if ((includesOtherImes || lastSubtypeBelongsToThisIme)
|
if ((includesOtherImes || lastSubtypeBelongsToThisIme)
|
||||||
&& mImm.switchToLastInputMethod(token)) {
|
&& mImm.switchToLastInputMethod(token)) {
|
||||||
mShouldSwitchToLastSubtype = false;
|
mShouldSwitchToLastSubtype = false;
|
||||||
|
|
Loading…
Reference in a new issue