aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-08-06 03:36:53 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-06 03:36:53 +0000
commit98e2748363355d2286215c798225d529f3a1cb34 (patch)
tree2da80e1cc052e3662ff5348938bb3d351905706b /java/src/com/android/inputmethod/latin/RichInputConnection.java
parent0978aa71ea91583c0b8d7e2588549fbb56953e7e (diff)
parent9273f3832b51f5d23d86df624600381ed6d6585f (diff)
downloadlatinime-98e2748363355d2286215c798225d529f3a1cb34.tar.gz
latinime-98e2748363355d2286215c798225d529f3a1cb34.tar.xz
latinime-98e2748363355d2286215c798225d529f3a1cb34.zip
am 9273f383: [HS3] Fix a bug on ICS
* commit '9273f3832b51f5d23d86df624600381ed6d6585f': [HS3] Fix a bug on ICS
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java22
1 files changed, 22 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);
+ }
+ }
}