Merge "Cleanup"

This commit is contained in:
Jean Chalard 2011-12-14 01:50:25 -08:00 committed by Android (Google) Code Review
commit 9750165c9a

View file

@ -1602,7 +1602,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled
&& !mInputTypeNoAutoCorrect; && !mInputTypeNoAutoCorrect;
if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) {
final boolean didAutoCorrect = commitCurrentAutoCorrection(primaryCode, ic); commitCurrentAutoCorrection(primaryCode, ic);
} else { } else {
commitTyped(ic); commitTyped(ic);
} }
@ -1859,7 +1859,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
setSuggestionStripShown(isSuggestionsStripVisible()); setSuggestionStripShown(isSuggestionsStripVisible());
} }
private boolean commitCurrentAutoCorrection(final int separatorCode, final InputConnection ic) { private void commitCurrentAutoCorrection(final int separatorCodePoint,
final InputConnection ic) {
// Complete any pending suggestions query first // Complete any pending suggestions query first
if (mHandler.hasPendingUpdateSuggestions()) { if (mHandler.hasPendingUpdateSuggestions()) {
mHandler.cancelUpdateSuggestions(); mHandler.cancelUpdateSuggestions();
@ -1872,7 +1873,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
throw new RuntimeException("We have an auto-correction but the typed word " throw new RuntimeException("We have an auto-correction but the typed word "
+ "is empty? Impossible! I must commit suicide."); + "is empty? Impossible! I must commit suicide.");
} }
Utils.Stats.onAutoCorrection(typedWord, autoCorrection.toString(), separatorCode); Utils.Stats.onAutoCorrection(typedWord, autoCorrection.toString(), separatorCodePoint);
mExpectingUpdateSelection = true; mExpectingUpdateSelection = true;
commitBestWord(autoCorrection); commitBestWord(autoCorrection);
if (!autoCorrection.equals(typedWord)) { if (!autoCorrection.equals(typedWord)) {
@ -1881,15 +1882,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Add the word to the user unigram dictionary if it's not a known word // Add the word to the user unigram dictionary if it's not a known word
addToUserUnigramAndBigramDictionaries(autoCorrection, addToUserUnigramAndBigramDictionaries(autoCorrection,
UserUnigramDictionary.FREQUENCY_FOR_TYPED); UserUnigramDictionary.FREQUENCY_FOR_TYPED);
if (!typedWord.equals(autoCorrection)) { if (!typedWord.equals(autoCorrection) && null != ic) {
// This will make the correction flash for a short while as a visual clue // This will make the correction flash for a short while as a visual clue
// to the user that auto-correction happened. // to the user that auto-correction happened.
InputConnectionCompatUtils.commitCorrection(ic, InputConnectionCompatUtils.commitCorrection(ic,
mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection); mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
} }
return true;
} }
return false;
} }
@Override @Override