aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-05-09 00:24:00 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-09 00:24:00 -0700
commitc8bde75cf455c02efc57c2e35bbe446b83c23739 (patch)
treecd17f9f206fbde369b7e21eeb4be44bec1bba013 /java/src
parentd5cd7e64aa30096241f63e47a9169699bdd98231 (diff)
parent03ca17c8415854c4c949b92b66543c920562ac3d (diff)
downloadlatinime-c8bde75cf455c02efc57c2e35bbe446b83c23739.tar.gz
latinime-c8bde75cf455c02efc57c2e35bbe446b83c23739.tar.xz
latinime-c8bde75cf455c02efc57c2e35bbe446b83c23739.zip
Merge "Optimize InputConnection.getCursorCapsMode calling" into jb-dev
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index fc83167bb..213c0ac82 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1026,13 +1026,25 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
public boolean getCurrentAutoCapsState() {
+ if (!mSettingsValues.mAutoCap) return false;
+
+ final EditorInfo ei = getCurrentInputEditorInfo();
+ if (ei == null) return false;
+
+ final int inputType = ei.inputType;
+ if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) return true;
+
+ final boolean noNeedToCheckCapsMode = (inputType & (InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
+ | InputType.TYPE_TEXT_FLAG_CAP_WORDS)) == 0;
+ if (noNeedToCheckCapsMode) return false;
+
final InputConnection ic = getCurrentInputConnection();
- EditorInfo ei = getCurrentInputEditorInfo();
- if (mSettingsValues.mAutoCap && ic != null && ei != null
- && ei.inputType != InputType.TYPE_NULL) {
- return ic.getCursorCapsMode(ei.inputType) != 0;
- }
- return false;
+ if (ic == null) return false;
+ // TODO: This blocking IPC call is heavy. Consider doing this without using IPC calls.
+ // Note: getCursorCapsMode() returns the current capitalization mode that is any
+ // combination of CAP_MODE_CHARACTERS, CAP_MODE_WORDS, and CAP_MODE_SENTENCES. 0 means none
+ // of them.
+ return ic.getCursorCapsMode(inputType) != 0;
}
// "ic" may be null