diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 796d4ac79..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 @@ -1478,22 +1490,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen sendKeyCodePoint(Keyboard.CODE_SPACE); } - if ((isAlphabet(primaryCode) + // NOTE: isCursorTouchingWord() is a blocking IPC call, so it often takes several + // dozen milliseconds. Avoid calling it as much as possible, since we are on the UI + // thread here. + if (!isComposingWord && (isAlphabet(primaryCode) || mSettingsValues.isSymbolExcludedFromWordSeparators(primaryCode)) && isSuggestionsRequested() && !isCursorTouchingWord()) { - if (!isComposingWord) { - // Reset entirely the composing state anyway, then start composing a new word unless - // the character is a single quote. The idea here is, single quote is not a - // separator and it should be treated as a normal character, except in the first - // position where it should not start composing a word. - isComposingWord = (Keyboard.CODE_SINGLE_QUOTE != primaryCode); - // Here we don't need to reset the last composed word. It will be reset - // when we commit this one, if we ever do; if on the other hand we backspace - // it entirely and resume suggestions on the previous word, we'd like to still - // have touch coordinates for it. - resetComposingState(false /* alsoResetLastComposedWord */); - clearSuggestions(); - } + // Reset entirely the composing state anyway, then start composing a new word unless + // the character is a single quote. The idea here is, single quote is not a + // separator and it should be treated as a normal character, except in the first + // position where it should not start composing a word. + isComposingWord = (Keyboard.CODE_SINGLE_QUOTE != primaryCode); + // Here we don't need to reset the last composed word. It will be reset + // when we commit this one, if we ever do; if on the other hand we backspace + // it entirely and resume suggestions on the previous word, we'd like to still + // have touch coordinates for it. + resetComposingState(false /* alsoResetLastComposedWord */); + clearSuggestions(); } if (isComposingWord) { mWordComposer.add( |