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.java46
1 files changed, 26 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 47ec40f99..98bdef606 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -242,7 +242,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public final UIHandler mHandler = new UIHandler(this);
public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> {
- private static final int MSG_UPDATE_SUGGESTIONS = 0;
private static final int MSG_UPDATE_SHIFT_STATE = 1;
private static final int MSG_VOICE_RESULTS = 2;
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 3;
@@ -250,6 +249,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private static final int MSG_SPACE_TYPED = 5;
private static final int MSG_SET_BIGRAM_PREDICTIONS = 6;
private static final int MSG_PENDING_IMS_CALLBACK = 7;
+ private static final int MSG_UPDATE_SUGGESTIONS = 8;
private int mDelayBeforeFadeoutLanguageOnSpacebar;
private int mDelayUpdateSuggestions;
@@ -979,7 +979,10 @@ 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();
+ final boolean isAutoCorrection = Utils.willAutoCorrect(words);
+ setSuggestions(words, isAutoCorrection);
+ setAutoCorrectionIndicator(isAutoCorrection);
// 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());
@@ -1712,22 +1715,23 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
public void clearSuggestions() {
- setSuggestions(SuggestedWords.EMPTY);
+ setSuggestions(SuggestedWords.EMPTY, false);
+ setAutoCorrectionIndicator(false);
}
- public void setSuggestions(SuggestedWords words) {
+ public void setSuggestions(final SuggestedWords words, final boolean isAutoCorrection) {
if (mSuggestionsView != null) {
mSuggestionsView.setSuggestions(words);
- mKeyboardSwitcher.onAutoCorrectionStateChanged(
- words.hasWordAboveAutoCorrectionScoreThreshold());
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(isAutoCorrection);
}
+ }
+ 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,26 @@ 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);
+ final boolean isAutoCorrection = Utils.willAutoCorrect(suggestedWords);
+ setSuggestions(suggestedWords, isAutoCorrection);
+ setAutoCorrectionIndicator(isAutoCorrection);
setSuggestionStripShown(isSuggestionsStripVisible());
}
@@ -2021,7 +2026,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
public void setPunctuationSuggestions() {
- setSuggestions(mSettingsValues.mSuggestPuncList);
+ setSuggestions(mSettingsValues.mSuggestPuncList, false);
+ setAutoCorrectionIndicator(false);
setSuggestionStripShown(isSuggestionsStripVisible());
}