aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 953d87beb..211b69a44 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 InputMethodServiceCompatWrapper implements Keyboar
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);
// When in fullscreen mode, show completions generated by the application
- setSuggestions(builder.build());
+ final SuggestedWords words = builder.build();
+ setSuggestions(words);
+ setAutoCorrectionIndicator(Utils.willAutoCorrect(words));
// TODO: is this the right thing to do? What should we auto-correct to in
// this case? This says to keep whatever the user typed.
mWordComposer.setAutoCorrection(mWordComposer.getTypedWord());
@@ -1713,21 +1715,23 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void clearSuggestions() {
setSuggestions(SuggestedWords.EMPTY);
+ setAutoCorrectionIndicator(false);
}
- public void setSuggestions(SuggestedWords words) {
+ public void setSuggestions(final SuggestedWords words) {
if (mSuggestionsView != null) {
mSuggestionsView.setSuggestions(words);
mKeyboardSwitcher.onAutoCorrectionStateChanged(
words.hasWordAboveAutoCorrectionScoreThreshold());
}
+ }
+ private void setAutoCorrectionIndicator(final boolean newAutoCorrectionIndicator) {
// Put a blue underline to a word in TextView which will be auto-corrected.
final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
final boolean oldAutoCorrectionIndicator =
mComposingStateManager.isAutoCorrectionIndicatorOn();
- final boolean newAutoCorrectionIndicator = Utils.willAutoCorrect(words);
if (oldAutoCorrectionIndicator != newAutoCorrectionIndicator) {
mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator);
if (DEBUG) {
@@ -1738,9 +1742,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
throw new RuntimeException("Couldn't flip the indicator!");
}
}
- final CharSequence textWithUnderline =
- getTextWithUnderline(mWordComposer.getTypedWord());
- if (!TextUtils.isEmpty(textWithUnderline)) {
+ if (mWordComposer.isComposingWord()) {
+ final CharSequence textWithUnderline =
+ getTextWithUnderline(mWordComposer.getTypedWord());
ic.setComposingText(textWithUnderline, 1);
}
}
@@ -1830,25 +1834,25 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
showSuggestions(builder.build(), typedWord);
}
- public void showSuggestions(SuggestedWords suggestedWords, CharSequence typedWord) {
+ public void showSuggestions(final SuggestedWords suggestedWords, final CharSequence typedWord) {
final boolean shouldBlockAutoCorrectionBySafetyNet =
Utils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords, mSuggest);
if (shouldBlockAutoCorrectionBySafetyNet) {
suggestedWords.setShouldBlockAutoCorrection();
}
- setSuggestions(suggestedWords);
+ final CharSequence autoCorrection;
if (suggestedWords.size() > 0) {
- if (shouldBlockAutoCorrectionBySafetyNet) {
- mWordComposer.setAutoCorrection(typedWord);
- } else if (suggestedWords.hasAutoCorrectionWord()) {
- mWordComposer.setAutoCorrection(suggestedWords.getWord(1));
+ if (!shouldBlockAutoCorrectionBySafetyNet && suggestedWords.hasAutoCorrectionWord()) {
+ autoCorrection = suggestedWords.getWord(1);
} else {
- mWordComposer.setAutoCorrection(typedWord);
+ autoCorrection = typedWord;
}
} else {
- // TODO: replace with mWordComposer.deleteAutoCorrection()?
- mWordComposer.setAutoCorrection(null);
+ autoCorrection = null;
}
+ mWordComposer.setAutoCorrection(autoCorrection);
+ setSuggestions(suggestedWords);
+ setAutoCorrectionIndicator(Utils.willAutoCorrect(suggestedWords));
setSuggestionStripShown(isSuggestionsStripVisible());
}
@@ -2022,6 +2026,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void setPunctuationSuggestions() {
setSuggestions(mSettingsValues.mSuggestPuncList);
+ setAutoCorrectionIndicator(false);
setSuggestionStripShown(isSuggestionsStripVisible());
}