Merge "Make AutoCorrection static and non-instantiable (A5)"

main
Jean Chalard 2012-03-08 19:05:30 -08:00 committed by Android (Google) Code Review
commit 23a5e9d1a7
2 changed files with 6 additions and 5 deletions

View File

@ -26,7 +26,11 @@ 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();
public static CharSequence updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries, private AutoCorrection() {
// Purely static class: can't instantiate.
}
public static CharSequence computeAutoCorrectionWord(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) {

View File

@ -83,7 +83,6 @@ public class Suggest implements Dictionary.WordCallback {
private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean DBG = LatinImeLogger.sDBG;
private AutoCorrection mAutoCorrection;
private boolean mHasAutoCorrection; private boolean mHasAutoCorrection;
private Dictionary mMainDict; private Dictionary mMainDict;
@ -125,7 +124,6 @@ public class Suggest implements Dictionary.WordCallback {
private void initWhitelistAndAutocorrectAndPool(final Context context, final Locale locale) { private void initWhitelistAndAutocorrectAndPool(final Context context, final Locale locale) {
mWhiteListDictionary = new WhitelistDictionary(context, locale); mWhiteListDictionary = new WhitelistDictionary(context, locale);
addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_WHITELIST, mWhiteListDictionary); addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_WHITELIST, mWhiteListDictionary);
mAutoCorrection = new AutoCorrection();
StringBuilderPool.ensureCapacity(mPrefMaxSuggestions, getApproxMaxWordLength()); StringBuilderPool.ensureCapacity(mPrefMaxSuggestions, getApproxMaxWordLength());
} }
@ -273,7 +271,6 @@ public class Suggest implements Dictionary.WordCallback {
final WordComposer wordComposer, CharSequence prevWordForBigram, final WordComposer wordComposer, CharSequence prevWordForBigram,
final ProximityInfo proximityInfo, final int correctionMode) { final ProximityInfo proximityInfo, final int correctionMode) {
LatinImeLogger.onStartSuggestion(prevWordForBigram); LatinImeLogger.onStartSuggestion(prevWordForBigram);
mAutoCorrection.init();
mIsFirstCharCapitalized = wordComposer.isFirstCharCapitalized(); mIsFirstCharCapitalized = wordComposer.isFirstCharCapitalized();
mIsAllUpperCase = wordComposer.isAllUpperCase(); mIsAllUpperCase = wordComposer.isAllUpperCase();
mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount(); mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount();
@ -354,7 +351,7 @@ public class Suggest implements Dictionary.WordCallback {
mWhiteListDictionary.getWhitelistedWord(consideredWordString)); mWhiteListDictionary.getWhitelistedWord(consideredWordString));
final CharSequence autoCorrection = final CharSequence autoCorrection =
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer, AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer,
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode, mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode,
whitelistedWord); whitelistedWord);
mHasAutoCorrection = (null != autoCorrection); mHasAutoCorrection = (null != autoCorrection);