From 2312c1954f86b5fd3b8e5099da814ad73e5a5e26 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Tue, 18 Feb 2014 11:48:00 +0900 Subject: [PATCH] Cosmetic fixes Change-Id: I6c755565ba7689357d02d26cc0e92a93031953e8 --- .../android/inputmethod/latin/LatinIME.java | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index a73870211..d922ef6eb 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -979,7 +979,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } } - if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) return; + if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) { + return; + } if (applicationSpecifiedCompletions == null) { setNeutralSuggestionStrip(); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { @@ -993,27 +995,25 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final ArrayList 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 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } // 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 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } // 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 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen 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 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } 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 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen 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