Merge "Fix touchable region" into honeycomb
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 41646ff..847038f 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1557,10 +1557,11 @@
 
         // Basically, we update the suggestion strip only when suggestion count > 1.  However,
         // there is an exception: We update the suggestion strip whenever typed word's length
-        // is 1, regardless of suggestion count.  Actually, in most cases, suggestion count is 1
-        // when typed word's length is 1, but we do always need to clear the previous state when
-        // the user starts typing a word (i.e. typed word's length == 1).
-        if (typedWord.length() == 1 || builder.size() > 1
+        // is 1 or typed word is found in dictionary, regardless of suggestion count.  Actually,
+        // in most cases, suggestion count is 1 when typed word's length is 1, but we do always
+        // need to clear the previous state when the user starts typing a word (i.e. typed word's
+        // length == 1).
+        if (builder.size() > 1 || typedWord.length() == 1 || typedWordValid
                 || mCandidateView.isShowingAddToDictionaryHint()) {
             builder.setTypedWordValid(typedWordValid).setHasMinimalSuggestion(correctionAvailable);
         } else {
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 4407e5b..f774ce3 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 
 public class SuggestedWords {
@@ -128,10 +129,18 @@
                 SuggestedWords previousSuggestions) {
             mWords.clear();
             mSuggestedWordInfoList.clear();
+            final HashSet<String> alreadySeen = new HashSet<String>();
             addWord(typedWord, null, false);
+            alreadySeen.add(typedWord.toString());
             final int previousSize = previousSuggestions.size();
-            for (int pos = 1; pos < previousSize; pos++)
-                addWord(previousSuggestions.getWord(pos), null, true);
+            for (int pos = 1; pos < previousSize; pos++) {
+                final String prevWord = previousSuggestions.getWord(pos).toString();
+                // Filter out duplicate suggestion.
+                if (!alreadySeen.contains(prevWord)) {
+                    addWord(prevWord, null, true);
+                    alreadySeen.add(prevWord);
+                }
+            }
             mIsCompletions = false;
             mTypedWordValid = false;
             mHasMinimalSuggestion = false;