From 9d1c73ffd88cd1bfef3de048b0b3a9a7dfbcfa70 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 10 Sep 2012 19:27:45 +0900 Subject: 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 --- .../android/inputmethod/latin/RichInputConnection.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java') 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) { -- cgit v1.2.3-83-g751a