From a5a2f3e3c77ebf2e1bb74b08c8587c15b9711ac8 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Sun, 14 Apr 2013 21:53:16 +0900 Subject: [PATCH] Remove gesture suggestions with an INT_MIN score Bug: 7980115 Change-Id: I8de31068992aec712eaad132857d9dc61f28e30a --- java/src/com/android/inputmethod/latin/Suggest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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,