Merge "Cleanup, part 3 (C3)"

This commit is contained in:
Jean Chalard 2012-06-19 09:24:00 -07:00 committed by Android (Google) Code Review
commit bd765d3355
3 changed files with 7 additions and 8 deletions

View file

@ -1928,7 +1928,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
final SuggestedWords suggestedWords; final SuggestedWords suggestedWords;
if (mCurrentSettings.mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) { if (mCurrentSettings.isCorrectionOn()) {
final CharSequence prevWord = mConnection.getThisWord(mCurrentSettings.mWordSeparators); final CharSequence prevWord = mConnection.getThisWord(mCurrentSettings.mWordSeparators);
if (!TextUtils.isEmpty(prevWord)) { if (!TextUtils.isEmpty(prevWord)) {
suggestedWords = mSuggest.getBigramPredictions(prevWord); suggestedWords = mSuggest.getBigramPredictions(prevWord);

View file

@ -209,7 +209,6 @@ public class SettingsValues {
private int createCorrectionMode() { private int createCorrectionMode() {
final boolean shouldAutoCorrect = mAutoCorrectEnabled final boolean shouldAutoCorrect = mAutoCorrectEnabled
&& !mInputAttributes.mInputTypeNoAutoCorrect; && !mInputAttributes.mInputTypeNoAutoCorrect;
if (shouldAutoCorrect) return Suggest.CORRECTION_FULL_BIGRAM;
return shouldAutoCorrect ? Suggest.CORRECTION_FULL : Suggest.CORRECTION_NONE; return shouldAutoCorrect ? Suggest.CORRECTION_FULL : Suggest.CORRECTION_NONE;
} }
@ -244,8 +243,7 @@ public class SettingsValues {
} }
public boolean isCorrectionOn() { public boolean isCorrectionOn() {
return mCorrectionMode == Suggest.CORRECTION_FULL return mCorrectionMode == Suggest.CORRECTION_FULL;
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM;
} }
public boolean isSuggestionStripVisibleInOrientation(final int orientation) { public boolean isSuggestionStripVisibleInOrientation(final int orientation) {

View file

@ -39,9 +39,10 @@ public class Suggest implements Dictionary.WordCallback {
public static final int APPROX_MAX_WORD_LENGTH = 32; public static final int APPROX_MAX_WORD_LENGTH = 32;
// TODO: rename this to CORRECTION_OFF
public static final int CORRECTION_NONE = 0; public static final int CORRECTION_NONE = 0;
// TODO: rename this to CORRECTION_ON
public static final int CORRECTION_FULL = 1; public static final int CORRECTION_FULL = 1;
public static final int CORRECTION_FULL_BIGRAM = 2;
// It seems the following values are only used for logging. // It seems the following values are only used for logging.
public static final int DIC_USER_TYPED = 0; public static final int DIC_USER_TYPED = 0;
@ -266,7 +267,7 @@ public class Suggest implements Dictionary.WordCallback {
LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED, Dictionary.UNIGRAM); LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED, Dictionary.UNIGRAM);
mConsideredWord = consideredWord; mConsideredWord = consideredWord;
if (wordComposer.size() <= 1 && (correctionMode == CORRECTION_FULL_BIGRAM)) { if (wordComposer.size() <= 1 && (correctionMode == CORRECTION_FULL)) {
// At first character typed, search only the bigrams // At first character typed, search only the bigrams
mBigramSuggestions = new ArrayList<SuggestedWordInfo>(PREF_MAX_BIGRAMS); mBigramSuggestions = new ArrayList<SuggestedWordInfo>(PREF_MAX_BIGRAMS);
@ -323,7 +324,7 @@ public class Suggest implements Dictionary.WordCallback {
mIsFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWord)); mIsFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWord));
final boolean hasAutoCorrection; final boolean hasAutoCorrection;
if (CORRECTION_FULL == correctionMode || CORRECTION_FULL_BIGRAM == correctionMode) { if (CORRECTION_FULL == correctionMode) {
final CharSequence autoCorrection = final CharSequence autoCorrection =
AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer, AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer,
mSuggestions, consideredWord, mAutoCorrectionThreshold, mSuggestions, consideredWord, mAutoCorrectionThreshold,
@ -373,7 +374,7 @@ public class Suggest implements Dictionary.WordCallback {
&& hasMainDictionary(); && hasMainDictionary();
boolean autoCorrectionAvailable = hasAutoCorrection; boolean autoCorrectionAvailable = hasAutoCorrection;
if (correctionMode == CORRECTION_FULL || correctionMode == CORRECTION_FULL_BIGRAM) { if (correctionMode == CORRECTION_FULL) {
autoCorrectionAvailable |= !allowsToBeAutoCorrected; autoCorrectionAvailable |= !allowsToBeAutoCorrected;
} }
// Don't auto-correct words with multiple capital letter // Don't auto-correct words with multiple capital letter