Do not set "SuggestionSpan"s for suggestions from the next word predicition

Bug: 6294817
Change-Id: I5010eafa5ba7e947743706adf7e722f4f0cfb415
diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
index 25afef1..a0f48d2 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
@@ -108,6 +108,7 @@
         if (!dictionaryAvailable || TextUtils.isEmpty(pickedWord)
                 || CONSTRUCTOR_SuggestionSpan == null
                 || suggestedWords == null || suggestedWords.size() == 0
+                || suggestedWords.mIsPrediction || suggestedWords.mIsPunctuationSuggestions
                 || OBJ_SUGGESTIONS_MAX_SIZE == null) {
             return pickedWord;
         }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 011b512..fb119da 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -877,7 +877,8 @@
                     false /* hasAutoCorrectionCandidate */,
                     false /* allowsToBeAutoCorrected */,
                     false /* isPunctuationSuggestions */,
-                    false /* isObsoleteSuggestions */);
+                    false /* isObsoleteSuggestions */,
+                    false /* isPrediction */);
             // When in fullscreen mode, show completions generated by the application
             final boolean isAutoCorrection = false;
             setSuggestions(suggestedWords, isAutoCorrection);
@@ -1772,7 +1773,8 @@
                             false /* hasAutoCorrectionCandidate */,
                             false /* allowsToBeAutoCorrected */,
                             false /* isPunctuationSuggestions */,
-                            true /* isObsoleteSuggestions */);
+                            true /* isObsoleteSuggestions */,
+                            false /* isPrediction */);
             showSuggestions(obsoleteSuggestedWords, typedWord);
         }
     }
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 5f9e1bc..55b896f 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -166,7 +166,8 @@
                 false /* hasAutoCorrectionCandidate */,
                 false /* allowsToBeAutoCorrected */,
                 true /* isPunctuationSuggestions */,
-                false /* isObsoleteSuggestions */);
+                false /* isObsoleteSuggestions */,
+                false /* isPrediction */);
     }
 
     private static String createWordSeparators(final String weakSpaceStrippers,
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 112bde6..845df81 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -253,13 +253,12 @@
         SuggestedWordInfo.removeDups(mSuggestions);
 
         return new SuggestedWords(mSuggestions,
-                // TODO: Just assuming the suggestions that came from the bigram prediction are
-                // valid now. Need to assign a correct value for typedWordValid.
-                true /* typedWordValid */,
+                false /* typedWordValid */,
                 false /* hasAutoCorrectionCandidate */,
                 false /* allowsToBeAutoCorrected */,
                 false /* isPunctuationSuggestions */,
-                false /* isObsoleteSuggestions */);
+                false /* isObsoleteSuggestions */,
+                true /* isPrediction */);
     }
 
     // TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
@@ -396,7 +395,8 @@
                 autoCorrectionAvailable /* hasAutoCorrectionCandidate */,
                 allowsToBeAutoCorrected /* allowsToBeAutoCorrected */,
                 false /* isPunctuationSuggestions */,
-                false /* isObsoleteSuggestions */);
+                false /* isObsoleteSuggestions */,
+                false /* isPrediction */);
     }
 
     /**
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 91110d8..497fd3b 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -25,13 +25,14 @@
 
 public class SuggestedWords {
     public static final SuggestedWords EMPTY = new SuggestedWords(
-            new ArrayList<SuggestedWordInfo>(0), false, false, false, false, false);
+            new ArrayList<SuggestedWordInfo>(0), false, false, false, false, false, false);
 
     public final boolean mTypedWordValid;
     public final boolean mHasAutoCorrectionCandidate;
     public final boolean mIsPunctuationSuggestions;
     public final boolean mAllowsToBeAutoCorrected;
     public final boolean mIsObsoleteSuggestions;
+    public final boolean mIsPrediction;
     private final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList;
 
     public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
@@ -39,13 +40,15 @@
             final boolean hasAutoCorrectionCandidate,
             final boolean allowsToBeAutoCorrected,
             final boolean isPunctuationSuggestions,
-            final boolean isObsoleteSuggestions) {
+            final boolean isObsoleteSuggestions,
+            final boolean isPrediction) {
         mSuggestedWordInfoList = suggestedWordInfoList;
         mTypedWordValid = typedWordValid;
         mHasAutoCorrectionCandidate = hasAutoCorrectionCandidate;
         mAllowsToBeAutoCorrected = allowsToBeAutoCorrected;
         mIsPunctuationSuggestions = isPunctuationSuggestions;
         mIsObsoleteSuggestions = isObsoleteSuggestions;
+        mIsPrediction = isPrediction;
     }
 
     public int size() {