aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-10-02 18:40:06 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-11-14 18:27:00 +0900
commit1931c1cab1c2b077030210f2dd7a1839da7211bc (patch)
tree7ee77cc062f1be5906dd72465e329c338e9f7684 /java/src
parenteaaee2864752bdedde4875e1e71ff174a2ef1828 (diff)
downloadlatinime-1931c1cab1c2b077030210f2dd7a1839da7211bc.tar.gz
latinime-1931c1cab1c2b077030210f2dd7a1839da7211bc.tar.xz
latinime-1931c1cab1c2b077030210f2dd7a1839da7211bc.zip
Fix language switch key behavior
Bug: 7075923 Change-Id: I306e1ff5d9f873541e84e1fafb64b9473947f623
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java48
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputMethodManager.java5
2 files changed, 35 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3dfffc4a6..0711a2386 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -56,7 +56,6 @@ import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.accessibility.AccessibilityUtils;
@@ -142,7 +141,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private SharedPreferences mPrefs;
@UsedForTesting final KeyboardSwitcher mKeyboardSwitcher;
private final SubtypeSwitcher mSubtypeSwitcher;
- private boolean mShouldSwitchToLastSubtype = true;
+ private final SubtypeState mSubtypeState = new SubtypeState();
private boolean mIsMainDictionaryAvailable;
private UserBinaryDictionary mUserDictionary;
@@ -366,6 +365,33 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
}
}
+ static final class SubtypeState {
+ private InputMethodSubtype mLastActiveSubtype;
+ private boolean mCurrentSubtypeUsed;
+
+ public void currentSubtypeUsed() {
+ mCurrentSubtypeUsed = true;
+ }
+
+ public void switchSubtype(final IBinder token, final RichInputMethodManager richImm) {
+ final InputMethodSubtype currentSubtype = richImm.getInputMethodManager()
+ .getCurrentInputMethodSubtype();
+ final InputMethodSubtype lastActiveSubtype = mLastActiveSubtype;
+ final boolean currentSubtypeUsed = mCurrentSubtypeUsed;
+ if (currentSubtypeUsed) {
+ mLastActiveSubtype = currentSubtype;
+ mCurrentSubtypeUsed = false;
+ }
+ if (currentSubtypeUsed
+ && richImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastActiveSubtype)
+ && !currentSubtype.equals(lastActiveSubtype)) {
+ richImm.setInputMethodAndSubtype(token, lastActiveSubtype);
+ return;
+ }
+ richImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
+ }
+ }
+
public LatinIME() {
super();
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
@@ -897,6 +923,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// Make a note of the cursor position
mLastSelectionStart = newSelStart;
mLastSelectionEnd = newSelEnd;
+ mSubtypeState.currentSubtypeUsed();
}
/**
@@ -1244,20 +1271,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mRichImm.switchToNextInputMethod(token, false /* onlyCurrentIme */);
return;
}
- if (mShouldSwitchToLastSubtype) {
- final InputMethodManager imm = mRichImm.getInputMethodManager();
- final InputMethodSubtype lastSubtype = imm.getLastInputMethodSubtype();
- final boolean lastSubtypeBelongsToThisIme =
- mRichImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastSubtype);
- if (lastSubtypeBelongsToThisIme && imm.switchToLastInputMethod(token)) {
- mShouldSwitchToLastSubtype = false;
- } else {
- mRichImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
- mShouldSwitchToLastSubtype = true;
- }
- } else {
- mRichImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
- }
+ mSubtypeState.switchSubtype(token, mRichImm);
}
private void sendDownUpKeyEventForBackwardCompatibility(final int code) {
@@ -1326,7 +1340,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
handleBackspace(spaceState);
mDeleteCount++;
mExpectingUpdateSelection = true;
- mShouldSwitchToLastSubtype = true;
LatinImeLogger.logOnDelete(x, y);
break;
case Constants.CODE_SHIFT:
@@ -1382,7 +1395,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
handleCharacter(primaryCode, keyX, keyY, spaceState);
}
mExpectingUpdateSelection = true;
- mShouldSwitchToLastSubtype = true;
break;
}
switcher.onCodeInput(primaryCode);
diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
index d7055f747..b3832303d 100644
--- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
+++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
@@ -206,6 +206,11 @@ public final class RichInputMethodManager {
return null;
}
+ public void setInputMethodAndSubtype(final IBinder token, final InputMethodSubtype subtype) {
+ mImmWrapper.mImm.setInputMethodAndSubtype(
+ token, mInputMethodInfoOfThisIme.getId(), subtype);
+ }
+
public void setAdditionalInputMethodSubtypes(final InputMethodSubtype[] subtypes) {
mImmWrapper.mImm.setAdditionalInputMethodSubtypes(
mInputMethodInfoOfThisIme.getId(), subtypes);