Set neutral suggestions should be called after load settings
Bug: 13058751 Change-Id: Iba49e86b90d595473d91753827d499e551dad45c
This commit is contained in:
parent
f0f4e9fc16
commit
affdd36423
3 changed files with 51 additions and 41 deletions
|
@ -200,13 +200,19 @@ public final class InputAttributes {
|
|||
// Pretty print
|
||||
@Override
|
||||
public String toString() {
|
||||
return "\n mInputTypeNoAutoCorrect = " + mInputTypeNoAutoCorrect
|
||||
+ "\n mIsSettingsSuggestionStripOn = " + mIsSettingsSuggestionStripOn
|
||||
+ "\n mApplicationSpecifiedCompletionOn = " + mApplicationSpecifiedCompletionOn;
|
||||
return String.format(
|
||||
"%s: inputType=0x%08x%s%s%s%s%s targetApp=%s\n", getClass().getSimpleName(),
|
||||
mInputType,
|
||||
(mInputTypeNoAutoCorrect ? " noAutoCorrect" : ""),
|
||||
(mIsPasswordField ? " password" : ""),
|
||||
(mIsSettingsSuggestionStripOn ? " suggestionStrip" : ""),
|
||||
(mApplicationSpecifiedCompletionOn ? " appSpecified" : ""),
|
||||
(mShouldInsertSpacesAutomatically ? " insertSpaces" : ""),
|
||||
mTargetApplicationPackageName);
|
||||
}
|
||||
|
||||
public static boolean inPrivateImeOptions(String packageName, String key,
|
||||
EditorInfo editorInfo) {
|
||||
public static boolean inPrivateImeOptions(final String packageName, final String key,
|
||||
final EditorInfo editorInfo) {
|
||||
if (editorInfo == null) return false;
|
||||
final String findingKey = (packageName != null) ? packageName + "." + key : key;
|
||||
return StringUtils.containsInCommaSplittableText(findingKey, editorInfo.privateImeOptions);
|
||||
|
|
|
@ -781,11 +781,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
if (null != suggest && null != currentLocale && !currentLocale.equals(suggest.mLocale)) {
|
||||
initSuggest();
|
||||
}
|
||||
if (mSuggestionStripView != null) {
|
||||
// This will set the punctuation suggestions if next word suggestion is off;
|
||||
// otherwise it will clear the suggestion strip.
|
||||
setNeutralSuggestionStrip();
|
||||
}
|
||||
|
||||
// Sometimes, while rotating, for some reason the framework tells the app we are not
|
||||
// connected to it and that means we can't refresh the cache. In this case, schedule a
|
||||
|
@ -834,8 +829,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// Space state must be updated before calling updateShiftState
|
||||
switcher.updateShiftState();
|
||||
}
|
||||
setSuggestionStripShownInternal(
|
||||
isSuggestionsStripVisible(), /* needsInputViewShown */ false);
|
||||
// This will set the punctuation suggestions if next word suggestion is off;
|
||||
// otherwise it will clear the suggestion strip.
|
||||
setNeutralSuggestionStripInternal(false /* needsInputViewShown */);
|
||||
|
||||
mHandler.cancelUpdateSuggestionStrip();
|
||||
mHandler.cancelDoubleSpacePeriodTimer();
|
||||
|
@ -1004,7 +1000,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
false /* isObsoleteSuggestions */,
|
||||
false /* isPrediction */);
|
||||
// When in fullscreen mode, show completions generated by the application
|
||||
setSuggestedWords(suggestedWords, true /* shouldShow */);
|
||||
setSuggestedWords(suggestedWords, true /* shouldShow */, true /* needsInputViewShown */);
|
||||
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
||||
ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions);
|
||||
}
|
||||
|
@ -1356,9 +1352,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
|
||||
// TODO[IL]: Define a clear interface for this
|
||||
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
|
||||
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow,
|
||||
final boolean needsInputViewShown) {
|
||||
mInputLogic.setSuggestedWords(suggestedWords);
|
||||
if (mSuggestionStripView != null) {
|
||||
if (mSuggestionStripView == null) {
|
||||
return;
|
||||
}
|
||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||
final boolean showSuggestions;
|
||||
if (SuggestedWords.EMPTY == suggestedWords
|
||||
|
@ -1374,8 +1373,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
|
||||
}
|
||||
mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect);
|
||||
setSuggestionStripShownInternal(shouldShow, true /* needsInputViewShown */);
|
||||
}
|
||||
setSuggestionStripShownInternal(shouldShow, needsInputViewShown);
|
||||
}
|
||||
|
||||
// TODO[IL]: Move this out of LatinIME.
|
||||
|
@ -1463,7 +1461,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
setNeutralSuggestionStrip();
|
||||
} else {
|
||||
mInputLogic.mWordComposer.setAutoCorrection(autoCorrection);
|
||||
setSuggestedWords(suggestedWords, isSuggestionsStripVisible());
|
||||
setSuggestedWords(
|
||||
suggestedWords, isSuggestionsStripVisible(), true /* needsInputViewShown */);
|
||||
}
|
||||
// Cache the auto-correction in accessibility code so we can speak it if the user
|
||||
// touches a key that will insert it.
|
||||
|
@ -1490,13 +1489,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// punctuation suggestions (if it's disabled).
|
||||
@Override
|
||||
public void setNeutralSuggestionStrip() {
|
||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||
if (currentSettings.mBigramPredictionEnabled) {
|
||||
setSuggestedWords(SuggestedWords.EMPTY, isSuggestionsStripVisible());
|
||||
} else {
|
||||
setSuggestedWords(currentSettings.mSpacingAndPunctuations.mSuggestPuncList,
|
||||
isSuggestionsStripVisible());
|
||||
setNeutralSuggestionStripInternal(true /* needsInputViewShown */);
|
||||
}
|
||||
|
||||
private void setNeutralSuggestionStripInternal(final boolean needsInputViewShown) {
|
||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||
final SuggestedWords neutralSuggestions = currentSettings.mBigramPredictionEnabled
|
||||
? SuggestedWords.EMPTY : currentSettings.mSpacingAndPunctuations.mSuggestPuncList;
|
||||
setSuggestedWords(neutralSuggestions, isSuggestionsStripVisible(), needsInputViewShown);
|
||||
}
|
||||
|
||||
// TODO: Make this private
|
||||
|
|
|
@ -233,7 +233,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
return false;
|
||||
}
|
||||
final int width = getWidth();
|
||||
if (width <= 0) return false;
|
||||
if (width <= 0) {
|
||||
return false;
|
||||
}
|
||||
mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, width);
|
||||
mStripVisibilityGroup.showImportantNoticeStrip();
|
||||
mImportantNoticeStrip.setOnClickListener(this);
|
||||
|
@ -429,9 +431,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
protected void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
// Called by the framework when the size is known. Show the important notice if applicable.
|
||||
// This may be overriden by showing suggestions later, if applicable.
|
||||
if (oldw <= 0 && w > 0) {
|
||||
maybeShowImportantNoticeTitle(Settings.getInstance().getCurrent().mInputAttributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue