diff options
author | 2014-08-05 23:21:59 +0900 | |
---|---|---|
committer | 2014-08-06 11:38:11 +0900 | |
commit | 9273f3832b51f5d23d86df624600381ed6d6585f (patch) | |
tree | b613094527db307aaa06c1b9d901bfca1ec31480 /java/src/com/android/inputmethod | |
parent | 50c12c83b322f78c90e3f72d1fa4422d13bfa7c6 (diff) | |
download | latinime-9273f3832b51f5d23d86df624600381ed6d6585f.tar.gz latinime-9273f3832b51f5d23d86df624600381ed6d6585f.tar.xz latinime-9273f3832b51f5d23d86df624600381ed6d6585f.zip |
[HS3] Fix a bug on ICS
There is a bug in ICS where the input connection won't take
any writing commands after rotation until the cursor moves.
This fixes it by wiggling the cursor position once before trying
to do anything.
Bug: 16810766
Change-Id: Ib14c70bd0550420cecfa86dea501d13a1a91e296
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 22 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index a6b3b710b..ea63cef02 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin; import android.inputmethodservice.InputMethodService; +import android.os.Build; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; @@ -811,4 +812,25 @@ public final class RichInputConnection { public boolean isCursorPositionKnown() { return INVALID_CURSOR_POSITION != mExpectedSelStart; } + + /** + * Work around a bug that was present before Jelly Bean upon rotation. + * + * Before Jelly Bean, there is a bug where setComposingRegion and other committing + * functions on the input connection get ignored until the cursor moves. This method works + * around the bug by wiggling the cursor first, which reactivates the connection and has + * the subsequent methods work, then restoring it to its original position. + * + * On platforms on which this method is not present, this is a no-op. + */ + public void maybeMoveTheCursorAroundAndRestoreToWorkaroundABug() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { + if (mExpectedSelStart > 0) { + mIC.setSelection(mExpectedSelStart - 1, mExpectedSelStart - 1); + } else { + mIC.setSelection(mExpectedSelStart + 1, mExpectedSelStart + 1); + } + mIC.setSelection(mExpectedSelStart, mExpectedSelEnd); + } + } } diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index b511f69a6..2be792040 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -1437,6 +1437,7 @@ public final class InputLogic { mLatinIME.getCoordinatesForCurrentKeyboard(codePoints)); mWordComposer.setCursorPositionWithinWord( typedWord.codePointCount(0, numberOfCharsInWordBeforeCursor)); + mConnection.maybeMoveTheCursorAroundAndRestoreToWorkaroundABug(); mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor, expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor()); if (suggestions.size() <= (shouldIncludeResumedWordInSuggestions ? 1 : 0)) { |