Fix logic to show suggestions

Bug: 15531465
Change-Id: Ic7fe5743ad3767cdaed699e5e2d1ebcaa75e22c2
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 35966bb..8b671a9 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1336,9 +1336,12 @@
         final SettingsValues currentSettingsValues = mSettings.getCurrent();
         final boolean shouldShowImportantNotice =
                 ImportantNoticeUtils.shouldShowImportantNotice(this);
+        final boolean shouldShowSuggestionCandidates =
+                currentSettingsValues.mInputAttributes.mShouldShowSuggestions
+                && currentSettingsValues.isCurrentOrientationAllowingSuggestionsPerUserSettings();
         final boolean shouldShowSuggestionsStripUnlessPassword = shouldShowImportantNotice
                 || currentSettingsValues.mShowsVoiceInputKey
-                || currentSettingsValues.isSuggestionsRequested()
+                || shouldShowSuggestionCandidates
                 || currentSettingsValues.isApplicationSpecifiedCompletionsOn();
         final boolean shouldShowSuggestionsStrip = shouldShowSuggestionsStripUnlessPassword
                 && !currentSettingsValues.mInputAttributes.mIsPasswordField;
@@ -1353,14 +1356,16 @@
         final boolean noSuggestionsToShow = (SuggestedWords.EMPTY == suggestedWords)
                 || suggestedWords.isPunctuationSuggestions()
                 || isEmptyApplicationSpecifiedCompletions;
-        final boolean isShowingImportantNotice;
         if (shouldShowImportantNotice && noSuggestionsToShow) {
-            isShowingImportantNotice = mSuggestionStripView.maybeShowImportantNoticeTitle();
-        } else {
-            isShowingImportantNotice = false;
+            if (mSuggestionStripView.maybeShowImportantNoticeTitle()) {
+                return;
+            }
         }
 
-        if (currentSettingsValues.isSuggestionsRequested() && !isShowingImportantNotice) {
+        if (currentSettingsValues.isCurrentOrientationAllowingSuggestionsPerUserSettings()
+                // We should clear suggestions if there is no suggestion to show.
+                || noSuggestionsToShow
+                || currentSettingsValues.isApplicationSpecifiedCompletionsOn()) {
             mSuggestionStripView.setSuggestions(suggestedWords,
                     SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
         }
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index 389d9a8..4410401 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -85,6 +85,7 @@
     public final int mKeyPreviewPopupDismissDelay;
     private final boolean mAutoCorrectEnabled;
     public final float mAutoCorrectionThreshold;
+    // TODO: Rename this to mAutoCorrectionEnabledPerUserSettings.
     public final boolean mAutoCorrectionEnabled;
     public final int mSuggestionVisibility;
     public final int mDisplayOrientation;
@@ -193,6 +194,7 @@
         return mInputAttributes.mApplicationSpecifiedCompletionOn;
     }
 
+    // TODO: Rename this to needsToLookupSuggestions().
     public boolean isSuggestionsRequested() {
         return mInputAttributes.mShouldShowSuggestions
                 && (mAutoCorrectionEnabled