diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index a738702..d922ef6 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -979,7 +979,9 @@
                 }
             }
         }
-        if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) return;
+        if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) {
+            return;
+        }
         if (applicationSpecifiedCompletions == null) {
             setNeutralSuggestionStrip();
             if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
@@ -993,27 +995,25 @@
         final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
                 SuggestedWords.getFromApplicationSpecifiedCompletions(
                         applicationSpecifiedCompletions);
-        final SuggestedWords suggestedWords = new SuggestedWords(
-                applicationSuggestedWords, null /* rawSuggestions */,
-                false /* typedWordValid */,
-                false /* willAutoCorrect */,
-                false /* isObsoleteSuggestions */,
-                false /* isPrediction */);
-        // When in fullscreen mode, show completions generated by the application
-        setSuggestedWords(suggestedWords, true /* shouldShow */, true /* needsInputViewShown */);
+        final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords,
+                null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */,
+                false /* isObsoleteSuggestions */, false /* isPrediction */);
+        // When in fullscreen mode, show completions generated by the application forcibly
+        setSuggestedWords(suggestedWords, true /* isSuggestionStripVisible */,
+                true /* needsInputViewShown */);
         if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
             ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions);
         }
     }
 
-    private void setSuggestionStripShownInternal(final boolean shown,
+    private void setSuggestionStripShownInternal(final boolean isSuggestionStripVisible,
             final boolean needsInputViewShown) {
         // TODO: Modify this if we support suggestions with hard keyboard
         if (!onEvaluateInputViewShown() || null == mSuggestionStripView) {
             return;
         }
         final boolean inputViewShown = mKeyboardSwitcher.isShowingMainKeyboardOrEmojiPalettes();
-        final boolean shouldShowSuggestions = shown
+        final boolean shouldShowSuggestions = isSuggestionStripVisible
                 && (needsInputViewShown ? inputViewShown : true);
         if (shouldShowSuggestions) {
             mSuggestionStripView.setVisibility(View.VISIBLE);
@@ -1317,20 +1317,27 @@
     }
 
     // TODO[IL]: Define a clear interface for this
-    public boolean isSuggestionsStripVisible() {
+    public boolean isSuggestionStripVisible() {
         final SettingsValues currentSettings = mSettings.getCurrent();
-        if (mSuggestionStripView == null)
+        if (mSuggestionStripView == null) {
             return false;
-        if (mSuggestionStripView.isShowingAddToDictionaryHint())
+        }
+        if (mSuggestionStripView.isShowingAddToDictionaryHint()) {
             return true;
-        if (null == currentSettings)
+        }
+        if (null == currentSettings) {
             return false;
-        if (ImportantNoticeUtils.shouldShowImportantNotice(this, currentSettings.mInputAttributes))
+        }
+        if (ImportantNoticeUtils.shouldShowImportantNotice(this,
+                currentSettings.mInputAttributes)) {
             return true;
-        if (!currentSettings.isSuggestionStripVisible())
+        }
+        if (!currentSettings.isSuggestionStripVisible()) {
             return false;
-        if (currentSettings.isApplicationSpecifiedCompletionsOn())
+        }
+        if (currentSettings.isApplicationSpecifiedCompletionsOn()) {
             return true;
+        }
         return currentSettings.isSuggestionsRequested();
     }
 
@@ -1352,8 +1359,8 @@
     }
 
     // TODO[IL]: Define a clear interface for this
-    public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow,
-            final boolean needsInputViewShown) {
+    public void setSuggestedWords(final SuggestedWords suggestedWords,
+            final boolean isSuggestionStripVisible, final boolean needsInputViewShown) {
         mInputLogic.setSuggestedWords(suggestedWords);
         if (mSuggestionStripView == null) {
             return;
@@ -1373,7 +1380,7 @@
                     SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
         }
         mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect);
-        setSuggestionStripShownInternal(shouldShow, needsInputViewShown);
+        setSuggestionStripShownInternal(isSuggestionStripVisible, needsInputViewShown);
     }
 
     // TODO[IL]: Move this out of LatinIME.
@@ -1462,7 +1469,7 @@
         } else {
             mInputLogic.mWordComposer.setAutoCorrection(autoCorrection);
             setSuggestedWords(
-                    suggestedWords, isSuggestionsStripVisible(), true /* needsInputViewShown */);
+                    suggestedWords, isSuggestionStripVisible(), true /* needsInputViewShown */);
         }
         // Cache the auto-correction in accessibility code so we can speak it if the user
         // touches a key that will insert it.
@@ -1496,7 +1503,7 @@
         final SettingsValues currentSettings = mSettings.getCurrent();
         final SuggestedWords neutralSuggestions = currentSettings.mBigramPredictionEnabled
                 ? SuggestedWords.EMPTY : currentSettings.mSpacingAndPunctuations.mSuggestPuncList;
-        setSuggestedWords(neutralSuggestions, isSuggestionsStripVisible(), needsInputViewShown);
+        setSuggestedWords(neutralSuggestions, isSuggestionStripVisible(), needsInputViewShown);
     }
 
     // TODO: Make this private
