diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 6 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/StringUtils.java | 11 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 12 |
3 files changed, 15 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 840c1c5c4..c7f647f2a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -161,8 +161,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mPositionalInfoForUserDictPendingAddition = null; private final WordComposer mWordComposer = new WordComposer(); private final RichInputConnection mConnection = new RichInputConnection(this); - private RecapitalizeStatus mRecapitalizeStatus = new RecapitalizeStatus(-1, -1, "", - Locale.getDefault(), ""); // Dummy object that will match no real recapitalize + private RecapitalizeStatus mRecapitalizeStatus = null; // Keep track of the last selection range to decide if we need to show word alternatives private static final int NOT_A_CURSOR_POSITION = -1; @@ -925,7 +924,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // We moved the cursor. If we are touching a word, we need to resume suggestion. mHandler.postResumeSuggestions(); - + // Reset the last recapitalization. + mRecapitalizeStatus = null; mKeyboardSwitcher.updateShiftState(); } mExpectingUpdateSelection = false; diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java index 3ca209d34..7f1e7c619 100644 --- a/java/src/com/android/inputmethod/latin/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/StringUtils.java @@ -282,15 +282,4 @@ public final class StringUtils { } return builder.toString(); } - - public static boolean containsAny(final String string, final String separators) { - final int len = separators.length(); - for (int i = 0; i < len; i = separators.offsetByCodePoints(i, 1)) { - final int separator = separators.codePointAt(i); - if (-1 != string.indexOf(separator)) { - return true; - } - } - return false; - } } diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 5abadf3dc..671d7146b 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -47,6 +47,9 @@ public final class Suggest { // TODO: rename this to CORRECTION_ON public static final int CORRECTION_FULL = 1; + // Close to -2**31 + private static final int SUPPRESS_SUGGEST_THRESHOLD = -2000000000; + public interface SuggestInitializationListener { public void onUpdateMainDictionaryAvailability(boolean isMainDictionaryAvailable); } @@ -340,6 +343,15 @@ public final class Suggest { suggestionsContainer.add(1, rejected); } SuggestedWordInfo.removeDups(suggestionsContainer); + + // For some reason some suggestions with MIN_VALUE are making their way here. + // TODO: Find a more robust way to detect distractors. + for (int i = suggestionsContainer.size() - 1; i >= 0; --i) { + if (suggestionsContainer.get(i).mScore < SUPPRESS_SUGGEST_THRESHOLD) { + suggestionsContainer.remove(i); + } + } + // In the batch input mode, the most relevant suggested word should act as a "typed word" // (typedWordValid=true), not as an "auto correct word" (willAutoCorrect=false). return new SuggestedWords(suggestionsContainer, |