Avoid calling switchToLastInputMethod when other IMEs are in effect

Bug: 7268389
Change-Id: I4d960cbf063002b4dc0ea813c966366b56c0346d
This commit is contained in:
Tadashi G. Takaoka 2012-10-02 17:09:56 +09:00
parent 6fd7fe5033
commit aec5cc8476

View file

@ -1219,22 +1219,25 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mConnection.performEditorAction(actionId);
}
// TODO: Revise the language switch key behavior to make it much smarter and more reasonable.
private void handleLanguageSwitchKey() {
final boolean includesOtherImes = mCurrentSettings.mIncludesOtherImesInLanguageSwitchList;
final IBinder token = getWindow().getWindow().getAttributes().token;
if (mCurrentSettings.mIncludesOtherImesInLanguageSwitchList) {
mImm.switchToNextInputMethod(token, false /* onlyCurrentIme */);
return;
}
if (mShouldSwitchToLastSubtype) {
final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
final boolean lastSubtypeBelongsToThisIme =
ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype);
if ((includesOtherImes || lastSubtypeBelongsToThisIme)
&& mImm.switchToLastInputMethod(token)) {
if (lastSubtypeBelongsToThisIme && mImm.switchToLastInputMethod(token)) {
mShouldSwitchToLastSubtype = false;
} else {
mImm.switchToNextInputMethod(token, !includesOtherImes);
mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
mShouldSwitchToLastSubtype = true;
}
} else {
mImm.switchToNextInputMethod(token, !includesOtherImes);
mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
}
}