Merge "Move a memory in the container class (A4)"
commit
2621fe2256
|
@ -25,30 +25,21 @@ import java.util.Map;
|
|||
public class AutoCorrection {
|
||||
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||
private static final String TAG = AutoCorrection.class.getSimpleName();
|
||||
private CharSequence mAutoCorrectionWord;
|
||||
|
||||
public void init() {
|
||||
mAutoCorrectionWord = null;
|
||||
}
|
||||
|
||||
public boolean hasAutoCorrection() {
|
||||
return null != mAutoCorrectionWord;
|
||||
}
|
||||
|
||||
public CharSequence updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries,
|
||||
public static CharSequence updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries,
|
||||
WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores,
|
||||
CharSequence typedWord, double autoCorrectionThreshold, int correctionMode,
|
||||
CharSequence whitelistedWord) {
|
||||
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
|
||||
mAutoCorrectionWord = whitelistedWord;
|
||||
return whitelistedWord;
|
||||
} else if (hasAutoCorrectionForTypedWord(
|
||||
dictionaries, wordComposer, suggestions, typedWord, correctionMode)) {
|
||||
mAutoCorrectionWord = typedWord;
|
||||
return typedWord;
|
||||
} else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, correctionMode,
|
||||
sortedScores, typedWord, autoCorrectionThreshold)) {
|
||||
mAutoCorrectionWord = suggestions.get(0);
|
||||
return suggestions.get(0);
|
||||
}
|
||||
return mAutoCorrectionWord;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isValidWord(
|
||||
|
|
|
@ -84,6 +84,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||
|
||||
private AutoCorrection mAutoCorrection;
|
||||
private boolean mHasAutoCorrection;
|
||||
|
||||
private Dictionary mMainDict;
|
||||
private ContactsDictionary mContactsDict;
|
||||
|
@ -352,9 +353,11 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized,
|
||||
mWhiteListDictionary.getWhitelistedWord(consideredWordString));
|
||||
|
||||
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer,
|
||||
final CharSequence autoCorrection =
|
||||
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer,
|
||||
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode,
|
||||
whitelistedWord);
|
||||
mHasAutoCorrection = (null != autoCorrection);
|
||||
|
||||
if (whitelistedWord != null) {
|
||||
if (mTrailingSingleQuotesCount > 0) {
|
||||
|
@ -403,7 +406,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
}
|
||||
|
||||
public boolean hasAutoCorrection() {
|
||||
return mAutoCorrection.hasAutoCorrection();
|
||||
return mHasAutoCorrection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue