From d62be28515481910bbf4d2e05df89ebb33f54e0e Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 12 Nov 2012 19:37:24 +0900 Subject: [PATCH 1/3] Fix language switch key behavior (DO NOT MERGE) Bug: 7075923 Change-Id: If139411db4aa65eed64337bf2a79387cfcd04496 --- .../InputMethodManagerCompatWrapper.java | 8 ++++ .../android/inputmethod/latin/LatinIME.java | 47 ++++++++++++------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index a01c301ee..ab7bd4914 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -52,6 +52,10 @@ public final class InputMethodManagerCompatWrapper { sInstance.mImm = ImfUtils.getInputMethodManager(context); } + public InputMethodSubtype getCurrentInputMethodSubtype() { + return mImm.getCurrentInputMethodSubtype(); + } + public InputMethodSubtype getLastInputMethodSubtype() { return mImm.getLastInputMethodSubtype(); } @@ -65,6 +69,10 @@ public final class InputMethodManagerCompatWrapper { onlyCurrentIme); } + public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { + mImm.setInputMethodAndSubtype(token, id, subtype); + } + public void showInputMethodPicker() { mImm.showInputMethodPicker(); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f578cc8de..70b387bec 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -141,7 +141,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private SharedPreferences mPrefs; /* package for tests */ final KeyboardSwitcher mKeyboardSwitcher; private final SubtypeSwitcher mSubtypeSwitcher; - private boolean mShouldSwitchToLastSubtype = true; + private final SubtypeState mSubtypeState = new SubtypeState(); private boolean mIsMainDictionaryAvailable; private UserBinaryDictionary mUserDictionary; @@ -365,6 +365,34 @@ 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 InputMethodManagerCompatWrapper imm, + final Context context) { + final InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype(); + final InputMethodSubtype lastActiveSubtype = mLastActiveSubtype; + final boolean currentSubtypeUsed = mCurrentSubtypeUsed; + if (currentSubtypeUsed) { + mLastActiveSubtype = currentSubtype; + mCurrentSubtypeUsed = false; + } + if (currentSubtypeUsed + && ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(context, lastActiveSubtype) + && !currentSubtype.equals(lastActiveSubtype)) { + final String id = ImfUtils.getInputMethodIdOfThisIme(context); + imm.setInputMethodAndSubtype(token, id, lastActiveSubtype); + return; + } + imm.switchToNextInputMethod(token, true /* onlyCurrentIme */); + } + } + public LatinIME() { super(); mSubtypeSwitcher = SubtypeSwitcher.getInstance(); @@ -887,6 +915,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // Make a note of the cursor position mLastSelectionStart = newSelStart; mLastSelectionEnd = newSelEnd; + mSubtypeState.currentSubtypeUsed(); } /** @@ -1235,19 +1264,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mImm.switchToNextInputMethod(token, false /* onlyCurrentIme */); return; } - if (mShouldSwitchToLastSubtype) { - final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype(); - final boolean lastSubtypeBelongsToThisIme = - ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype); - if (lastSubtypeBelongsToThisIme && mImm.switchToLastInputMethod(token)) { - mShouldSwitchToLastSubtype = false; - } else { - mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */); - mShouldSwitchToLastSubtype = true; - } - } else { - mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */); - } + mSubtypeState.switchSubtype(token, mImm, this); } private void sendDownUpKeyEventForBackwardCompatibility(final int code) { @@ -1316,7 +1333,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction handleBackspace(spaceState); mDeleteCount++; mExpectingUpdateSelection = true; - mShouldSwitchToLastSubtype = true; LatinImeLogger.logOnDelete(x, y); break; case Keyboard.CODE_SHIFT: @@ -1372,7 +1388,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction handleCharacter(primaryCode, keyX, keyY, spaceState); } mExpectingUpdateSelection = true; - mShouldSwitchToLastSubtype = true; break; } switcher.onCodeInput(primaryCode); From d0725a68421203ae42d78ceed57767a5204e858e Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 14 Nov 2012 17:37:55 +0900 Subject: [PATCH 2/3] Update shift state only when input field is restarted Bug: 7482766 Change-Id: Ifdfa110c44b95acfbcd3e0aa34f675c70b7d7285 --- .../com/android/inputmethod/latin/LatinIME.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f578cc8de..1436a10ac 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -683,8 +683,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting); } - final boolean selectionChanged = mLastSelectionStart != editorInfo.initialSelStart - || mLastSelectionEnd != editorInfo.initialSelEnd; final boolean inputTypeChanged = !mCurrentSettings.isSameInputType(editorInfo); final boolean isDifferentTextField = !restarting || inputTypeChanged; if (isDifferentTextField) { @@ -732,20 +730,17 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // TODO: Come up with a more comprehensive way to reset the keyboard layout when // a keyboard layout set doesn't get reloaded in this method. switcher.resetKeyboardStateToAlphabet(); + // In apps like Talk, we come here when the text is sent and the field gets emptied and + // we need to re-evaluate the shift state, but not the whole layout which would be + // disruptive. + // Space state must be updated before calling updateShiftState + switcher.updateShiftState(); } setSuggestionStripShownInternal( isSuggestionsStripVisible(), /* needsInputViewShown */ false); mLastSelectionStart = editorInfo.initialSelStart; mLastSelectionEnd = editorInfo.initialSelEnd; - // If we come here something in the text state is very likely to have changed. - // We should update the shift state regardless of whether we are restarting or not, because - // this is not perceived as a layout change that may be disruptive like we may have with - // switcher.loadKeyboard; in apps like Talk, we come here when the text is sent and the - // field gets emptied and we need to re-evaluate the shift state, but not the whole layout - // which would be disruptive. - // Space state must be updated before calling updateShiftState - mKeyboardSwitcher.updateShiftState(); mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelDoubleSpacesTimer(); From aef0acdbe078fe83ed834ffe986e9cb7b4b8df7d Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 15 Nov 2012 00:54:53 +0900 Subject: [PATCH 3/3] DO NOT MERGE - Fix an error in the base char table for LETTER L WITH STROKE Cherrypick of I67a431d8 bug: 7539944 Change-Id: I0d1f9649f30c36b8e464944a5b881c2cb9c05ccf --- native/jni/src/basechars.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/jni/src/basechars.cpp b/native/jni/src/basechars.cpp index 379cb6226..c0ed3c3c8 100644 --- a/native/jni/src/basechars.cpp +++ b/native/jni/src/basechars.cpp @@ -68,7 +68,7 @@ const uint16_t BASE_CHARS[BASE_CHARS_SIZE] = { 0x0049, 0x0069, 0x0049, 0x0069, 0x0049, 0x0069, 0x0049, 0x0069, 0x0049, 0x0131, 0x0049, 0x0069, 0x004a, 0x006a, 0x004b, 0x006b, 0x0138, 0x004c, 0x006c, 0x004c, 0x006c, 0x004c, 0x006c, 0x004c, - 0x006c, 0x0141, 0x0142, 0x004e, 0x006e, 0x004e, 0x006e, 0x004e, + 0x006c, 0x004c, 0x006c, 0x004e, 0x006e, 0x004e, 0x006e, 0x004e, 0x006e, 0x02bc, 0x014a, 0x014b, 0x004f, 0x006f, 0x004f, 0x006f, 0x004f, 0x006f, 0x0152, 0x0153, 0x0052, 0x0072, 0x0052, 0x0072, 0x0052, 0x0072, 0x0053, 0x0073, 0x0053, 0x0073, 0x0053, 0x0073,