aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-09-10 19:27:45 +0900
committerJean Chalard <jchalard@google.com>2012-09-13 17:46:39 +0900
commit9d1c73ffd88cd1bfef3de048b0b3a9a7dfbcfa70 (patch)
treece643090ba73ec8dc64ff9b8a323a31f04cfc085 /java/src/com/android/inputmethod/latin/RichInputConnection.java
parent18fc3bf4c453fe106be254eeb7aefb4a4a7154ba (diff)
downloadlatinime-9d1c73ffd88cd1bfef3de048b0b3a9a7dfbcfa70.tar.gz
latinime-9d1c73ffd88cd1bfef3de048b0b3a9a7dfbcfa70.tar.xz
latinime-9d1c73ffd88cd1bfef3de048b0b3a9a7dfbcfa70.zip
Import TextUtils.getCapsMode to fix it internally (A1)
This should have on effect at all on behavior, except an increase in performance. Bug: 4967874 Bug: 6950087 Change-Id: Ie2b51efefe84ca767f5dc8e3b80bfef7e1faab3d
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 37e1dbb69..efda623e5 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -192,7 +192,20 @@ public class RichInputConnection {
public int getCursorCapsMode(final int inputType) {
mIC = mParent.getCurrentInputConnection();
if (null == mIC) return Constants.TextUtils.CAP_MODE_OFF;
- return mIC.getCursorCapsMode(inputType);
+ if (!TextUtils.isEmpty(mComposingText)) return Constants.TextUtils.CAP_MODE_OFF;
+ // TODO: this will generally work, but there may be cases where the buffer contains SOME
+ // information but not enough to determine the caps mode accurately. This may happen after
+ // heavy pressing of delete, for example DEFAULT_TEXT_CACHE_SIZE - 5 times or so.
+ // getCapsMode should be updated to be able to return a "not enough info" result so that
+ // we can get more context only when needed.
+ if (TextUtils.isEmpty(mCommittedTextBeforeComposingText) && 0 != mCurrentCursorPosition) {
+ mCommittedTextBeforeComposingText.append(
+ getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE, 0));
+ }
+ // This never calls InputConnection#getCapsMode - in fact, it's a static method that
+ // never blocks or initiates IPC.
+ return StringUtils.getCapsMode(mCommittedTextBeforeComposingText,
+ mCommittedTextBeforeComposingText.length(), inputType);
}
public CharSequence getTextBeforeCursor(final int i, final int j) {