aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java10
-rw-r--r--java/src/com/android/inputmethod/latin/StringUtils.java11
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java12
3 files changed, 17 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index bd3acab92..6cc220614 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;
@@ -995,8 +995,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
}
}
if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) return;
- mApplicationSpecifiedCompletions =
- CompletionInfoUtils.removeNulls(applicationSpecifiedCompletions);
if (applicationSpecifiedCompletions == null) {
clearSuggestionStrip();
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
@@ -1004,6 +1002,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
}
return;
}
+ mApplicationSpecifiedCompletions =
+ CompletionInfoUtils.removeNulls(applicationSpecifiedCompletions);
final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
SuggestedWords.getFromApplicationSpecifiedCompletions(
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,