diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
4 files changed, 24 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d98966e96..c1b1751f1 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1119,8 +1119,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // Factor in auto-caps and manual caps and compute the current caps mode. private int getActualCapsMode() { - final int manual = mKeyboardSwitcher.getManualCapsMode(); - if (manual != WordComposer.CAPS_MODE_OFF) return manual; + final int keyboardShiftMode = mKeyboardSwitcher.getKeyboardShiftMode(); + if (keyboardShiftMode != WordComposer.CAPS_MODE_AUTO_SHIFTED) return keyboardShiftMode; final int auto = getCurrentAutoCapsState(); if (0 != (auto & TextUtils.CAP_MODE_CHARACTERS)) { return WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED; @@ -1429,6 +1429,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // The following is necessary for the case where the user typed something but didn't // manual pick it and didn't input any separator. mSpaceState = SPACE_STATE_PHANTOM; + } else { + final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor(); + if (Constants.NOT_A_CODE != codePointBeforeCursor + && !Character.isWhitespace(codePointBeforeCursor)) { + mSpaceState = SPACE_STATE_PHANTOM; + } } mConnection.endBatchEdit(); mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode()); @@ -1564,6 +1570,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // We have a TLD (or something that looks like this): make sure we don't add // a space even if currently in phantom mode. mSpaceState = SPACE_STATE_NONE; + // TODO: use getCodePointBeforeCursor instead to improve performance and simplify the code final CharSequence lastOne = mConnection.getTextBeforeCursor(1, 0); if (lastOne != null && lastOne.length() == 1 && lastOne.charAt(0) == Keyboard.CODE_PERIOD) { @@ -2284,6 +2291,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // This is a stopgap solution to avoid leaving a high surrogate alone in a text view. // In the future, we need to deprecate deteleSurroundingText() and have a surrogate // pair-friendly way of deleting characters in InputConnection. + // TODO: use getCodePointBeforeCursor instead to improve performance final CharSequence lastChar = mConnection.getTextBeforeCursor(1, 0); if (!TextUtils.isEmpty(lastChar) && Character.isHighSurrogate(lastChar.charAt(0))) { mConnection.deleteSurroundingText(1, 0); diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index b27db579f..21441369e 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -235,7 +235,14 @@ public final class RichInputConnection { hasSpaceBefore); } + public int getCodePointBeforeCursor() { + if (mCommittedTextBeforeComposingText.length() < 1) return Constants.NOT_A_CODE; + return Character.codePointBefore(mCommittedTextBeforeComposingText, + mCommittedTextBeforeComposingText.length()); + } + public CharSequence getTextBeforeCursor(final int i, final int j) { + // TODO: use mCommittedTextBeforeComposingText if possible to improve performance mIC = mParent.getCurrentInputConnection(); if (null != mIC) return mIC.getTextBeforeCursor(i, j); return null; diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java index e9bf0fac4..4e9fd1968 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java @@ -51,10 +51,11 @@ public final class MoreSuggestions extends Keyboard { super(); } + // TODO: Remove {@link MoreSuggestionsView} argument. public int layout(final SuggestedWords suggestions, final int fromPos, final int maxWidth, final int minWidth, final int maxRow, final MoreSuggestionsView view) { clearKeys(); - final Resources res = view.getContext().getResources(); + final Resources res = view.getResources(); mDivider = res.getDrawable(R.drawable.more_suggestions_divider); mDividerWidth = mDivider.getIntrinsicWidth(); final int padding = (int) res.getDimension( @@ -181,6 +182,7 @@ public final class MoreSuggestions extends Keyboard { load(xmlId, keyboard.mId); mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2; + mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight); final int count = mParams.layout(suggestions, fromPos, maxWidth, minWidth, maxRow, mPaneView); mFromPos = fromPos; diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 9b9a35478..03a2e73d1 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -105,6 +105,10 @@ public final class MoreSuggestionsView extends KeyboardView implements MoreKeysP } } + public void updateKeyboardGeometry(final int keyHeight) { + mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes); + } + @Override public void setKeyboard(Keyboard keyboard) { super.setKeyboard(keyboard); |