diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
4 files changed, 44 insertions, 26 deletions
diff --git a/java/src/com/android/inputmethod/latin/EditingUtils.java b/java/src/com/android/inputmethod/latin/EditingUtils.java index 7d673175e..93106ac27 100644 --- a/java/src/com/android/inputmethod/latin/EditingUtils.java +++ b/java/src/com/android/inputmethod/latin/EditingUtils.java @@ -38,8 +38,7 @@ public class EditingUtils { private static int getCursorPosition(InputConnection connection) { if (null == connection) return INVALID_CURSOR_POSITION; - ExtractedText extracted = connection.getExtractedText( - new ExtractedTextRequest(), 0); + final ExtractedText extracted = connection.getExtractedText(new ExtractedTextRequest(), 0); if (extracted == null) { return INVALID_CURSOR_POSITION; } diff --git a/java/src/com/android/inputmethod/latin/InputAttributes.java b/java/src/com/android/inputmethod/latin/InputAttributes.java index 9c32f947c..229ae2f3c 100644 --- a/java/src/com/android/inputmethod/latin/InputAttributes.java +++ b/java/src/com/android/inputmethod/latin/InputAttributes.java @@ -29,6 +29,7 @@ public class InputAttributes { final public boolean mInputTypeNoAutoCorrect; final public boolean mIsSettingsSuggestionStripOn; final public boolean mApplicationSpecifiedCompletionOn; + final public int mEditorAction; public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) { final int inputType = null != editorInfo ? editorInfo.inputType : 0; @@ -91,6 +92,8 @@ public class InputAttributes { mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode; } + mEditorAction = (editorInfo == null) ? EditorInfo.IME_ACTION_UNSPECIFIED + : editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION; } @SuppressWarnings("unused") diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7232a4883..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 @@ -1257,6 +1269,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen handleLanguageSwitchKey(); break; default: + if (primaryCode == Keyboard.CODE_TAB + && mInputAttributes.mEditorAction == EditorInfo.IME_ACTION_NEXT) { + performEditorAction(EditorInfo.IME_ACTION_NEXT); + break; + } mSpaceState = SPACE_STATE_NONE; if (mSettingsValues.isWordSeparator(primaryCode)) { didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState); @@ -1473,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( diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index e64e7a685..8a29dcc13 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -149,10 +149,8 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel { final MoreSuggestions pane = (MoreSuggestions)getKeyboard(); final int defaultCoordX = pane.mOccupiedWidth / 2; // The coordinates of panel's left-top corner in parentView's coordinate system. - final int x = pointX - defaultCoordX - container.getPaddingLeft() - + parentView.getPaddingLeft(); - final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom() - + parentView.getPaddingTop(); + final int x = pointX - defaultCoordX - container.getPaddingLeft(); + final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom(); window.setContentView(container); window.setWidth(container.getMeasuredWidth()); |