Merge "Move a memory in the container class (A4)"

main
Jean Chalard 2012-03-08 19:04:56 -08:00 committed by Android (Google) Code Review
commit 2621fe2256
2 changed files with 10 additions and 16 deletions

View File

@ -25,30 +25,21 @@ import java.util.Map;
public class AutoCorrection { public class AutoCorrection {
private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean DBG = LatinImeLogger.sDBG;
private static final String TAG = AutoCorrection.class.getSimpleName(); private static final String TAG = AutoCorrection.class.getSimpleName();
private CharSequence mAutoCorrectionWord;
public void init() { public static CharSequence updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries,
mAutoCorrectionWord = null;
}
public boolean hasAutoCorrection() {
return null != mAutoCorrectionWord;
}
public CharSequence updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores, WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores,
CharSequence typedWord, double autoCorrectionThreshold, int correctionMode, CharSequence typedWord, double autoCorrectionThreshold, int correctionMode,
CharSequence whitelistedWord) { CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
mAutoCorrectionWord = whitelistedWord; return whitelistedWord;
} else if (hasAutoCorrectionForTypedWord( } else if (hasAutoCorrectionForTypedWord(
dictionaries, wordComposer, suggestions, typedWord, correctionMode)) { dictionaries, wordComposer, suggestions, typedWord, correctionMode)) {
mAutoCorrectionWord = typedWord; return typedWord;
} else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, correctionMode, } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, correctionMode,
sortedScores, typedWord, autoCorrectionThreshold)) { sortedScores, typedWord, autoCorrectionThreshold)) {
mAutoCorrectionWord = suggestions.get(0); return suggestions.get(0);
} }
return mAutoCorrectionWord; return null;
} }
public static boolean isValidWord( public static boolean isValidWord(

View File

@ -84,6 +84,7 @@ public class Suggest implements Dictionary.WordCallback {
private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean DBG = LatinImeLogger.sDBG;
private AutoCorrection mAutoCorrection; private AutoCorrection mAutoCorrection;
private boolean mHasAutoCorrection;
private Dictionary mMainDict; private Dictionary mMainDict;
private ContactsDictionary mContactsDict; private ContactsDictionary mContactsDict;
@ -352,9 +353,11 @@ public class Suggest implements Dictionary.WordCallback {
CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized, CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized,
mWhiteListDictionary.getWhitelistedWord(consideredWordString)); mWhiteListDictionary.getWhitelistedWord(consideredWordString));
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer, final CharSequence autoCorrection =
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer,
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode, mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode,
whitelistedWord); whitelistedWord);
mHasAutoCorrection = (null != autoCorrection);
if (whitelistedWord != null) { if (whitelistedWord != null) {
if (mTrailingSingleQuotesCount > 0) { if (mTrailingSingleQuotesCount > 0) {
@ -403,7 +406,7 @@ public class Suggest implements Dictionary.WordCallback {
} }
public boolean hasAutoCorrection() { public boolean hasAutoCorrection() {
return mAutoCorrection.hasAutoCorrection(); return mHasAutoCorrection;
} }
@Override @Override