aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-14 01:42:17 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-12-14 01:42:17 -0800
commit64361bd66d2d764bd5fb6486e9b9de5a3f2fb240 (patch)
tree8d519e5a1b226343240737a3c03cb0b79b76347d /java/src
parent676917dea2595d7bbc1f24a44034a4254a1884fa (diff)
parent1c6cf26c3705e845418a29718c034598b52293cc (diff)
downloadlatinime-64361bd66d2d764bd5fb6486e9b9de5a3f2fb240.tar.gz
latinime-64361bd66d2d764bd5fb6486e9b9de5a3f2fb240.tar.xz
latinime-64361bd66d2d764bd5fb6486e9b9de5a3f2fb240.zip
Merge "Move some code inside a function to simplify flow"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 9633e665a..fdbc9d8e2 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1602,17 +1602,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled
&& !mInputTypeNoAutoCorrect;
if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) {
- final boolean pickedDefaultSuggestion = pickDefaultSuggestion(primaryCode);
- if (pickedDefaultSuggestion) {
- final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
- final String typedWord = mWordComposer.getTypedWord();
- if (!typedWord.equals(autoCorrection)) {
- // This will make the correction flash for a short while as a visual clue
- // to the user that auto-correction happened.
- InputConnectionCompatUtils.commitCorrection(ic,
- mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
- }
- }
+ final boolean didAutoCorrect = commitCurrentAutoCorrection(primaryCode, ic);
} else {
commitTyped(ic);
}
@@ -1869,7 +1859,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
setSuggestionStripShown(isSuggestionsStripVisible());
}
- private boolean pickDefaultSuggestion(int separatorCode) {
+ private boolean commitCurrentAutoCorrection(final int separatorCode, final InputConnection ic) {
// Complete any pending suggestions query first
if (mHandler.hasPendingUpdateSuggestions()) {
mHandler.cancelUpdateSuggestions();
@@ -1891,6 +1881,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Add the word to the user unigram dictionary if it's not a known word
addToUserUnigramAndBigramDictionaries(autoCorrection,
UserUnigramDictionary.FREQUENCY_FOR_TYPED);
+ if (!typedWord.equals(autoCorrection)) {
+ // This will make the correction flash for a short while as a visual clue
+ // to the user that auto-correction happened.
+ InputConnectionCompatUtils.commitCorrection(ic,
+ mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
+ }
return true;
}
return false;