diff options
author | 2012-06-28 16:54:53 +0900 | |
---|---|---|
committer | 2012-06-29 15:12:51 +0900 | |
commit | 074c90af98487f94bac26d9463020e883b26f358 (patch) | |
tree | 9097bc0351859ecbd8ebe0612e2bf6996007c87a /java/src | |
parent | 1333579b4b4f392c73409b9a3fbfb428a0f8a9ed (diff) | |
download | latinime-074c90af98487f94bac26d9463020e883b26f358.tar.gz latinime-074c90af98487f94bac26d9463020e883b26f358.tar.xz latinime-074c90af98487f94bac26d9463020e883b26f358.zip |
Inline a method (A14)
The new code is worse than the old one, but this is a necessary
step to make things prettier.
Change-Id: If6e8a139bb85e6920c749743c78792a22a8acb45
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/AutoCorrection.java | 22 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 15 |
2 files changed, 14 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java index 4ae12145c..91e1dddec 100644 --- a/java/src/com/android/inputmethod/latin/AutoCorrection.java +++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java @@ -31,22 +31,6 @@ public class AutoCorrection { // Purely static class: can't instantiate. } - public static CharSequence computeAutoCorrectionWord( - final ConcurrentHashMap<String, Dictionary> dictionaries, - final WordComposer wordComposer, SuggestedWordInfo suggestion, - final CharSequence consideredWord, final float autoCorrectionThreshold, - final CharSequence whitelistedWord) { - if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { - return whitelistedWord; - } else if (shouldAutoCorrectToSelf(dictionaries, consideredWord)) { - return consideredWord; - } else if (hasAutoCorrectionForBinaryDictionary(suggestion, - consideredWord, autoCorrectionThreshold)) { - return suggestion.mWord; - } - return null; - } - public static boolean isValidWord(final ConcurrentHashMap<String, Dictionary> dictionaries, CharSequence word, boolean ignoreCase) { if (TextUtils.isEmpty(word)) { @@ -104,18 +88,18 @@ public class AutoCorrection { return !isValidWord(dictionaries, word, ignoreCase); } - private static boolean hasAutoCorrectionForWhitelistedWord(CharSequence whiteListedWord) { + static public boolean hasAutoCorrectionForWhitelistedWord(CharSequence whiteListedWord) { return whiteListedWord != null; } - private static boolean shouldAutoCorrectToSelf( + public static boolean shouldAutoCorrectToSelf( final ConcurrentHashMap<String, Dictionary> dictionaries, final CharSequence consideredWord) { if (TextUtils.isEmpty(consideredWord)) return false; return !allowsToBeAutoCorrected(dictionaries, consideredWord, false); } - private static boolean hasAutoCorrectionForBinaryDictionary(SuggestedWordInfo suggestion, + public static boolean hasAutoCorrectionForBinaryDictionary(SuggestedWordInfo suggestion, CharSequence consideredWord, float autoCorrectionThreshold) { if (null != suggestion) { //final int autoCorrectionSuggestionScore = sortedScores[0]; diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 2d388e180..195c19b4d 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -230,10 +230,17 @@ public class Suggest { if (isCorrectionEnabled) { final SuggestedWordInfo bestSuggestion = suggestionsSet.isEmpty() ? null : suggestionsSet.first(); - final CharSequence autoCorrection = - AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer, - bestSuggestion, consideredWord, mAutoCorrectionThreshold, - whitelistedWord); + final CharSequence autoCorrection; + if (AutoCorrection.hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { + autoCorrection = whitelistedWord; + } else if (AutoCorrection.shouldAutoCorrectToSelf(mDictionaries, consideredWord)) { + autoCorrection = consideredWord; + } else if (AutoCorrection.hasAutoCorrectionForBinaryDictionary(bestSuggestion, + consideredWord, mAutoCorrectionThreshold)) { + autoCorrection = bestSuggestion.mWord; + } else { + autoCorrection = null; + } hasAutoCorrection = (null != autoCorrection); } else { hasAutoCorrection = false; |