aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-19 16:27:04 +0900
committerJean Chalard <jchalard@google.com>2014-06-26 18:26:08 +0900
commitb740886aeb47f8f3fb32bca7a7faa13d5756bd74 (patch)
tree01488a65f38d1369a1973dae395566a095d9a53f /java/src/com/android/inputmethod/latin/Suggest.java
parent5961f2dfaca123e8e6f2fab33fb9d23d8b4c98fc (diff)
downloadlatinime-b740886aeb47f8f3fb32bca7a7faa13d5756bd74.tar.gz
latinime-b740886aeb47f8f3fb32bca7a7faa13d5756bd74.tar.xz
latinime-b740886aeb47f8f3fb32bca7a7faa13d5756bd74.zip
[CS4] Remove useless tests and processing
Since we have a de-duped and transformed collection, we can just read from it instead of computing it separately. Bug: 13238601 Change-Id: I0aa4b0d91d3b350f9449e13658bfb587fc538764
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java31
1 files changed, 9 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 9d03e8a43..2a56861b4 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -123,21 +123,15 @@ public final class Suggest {
suggestionsContainer.set(i, transformedWordInfo);
}
}
- SuggestedWordInfo.removeDups(typedWord, suggestionsContainer);
+ final boolean didRemoveTypedWord =
+ SuggestedWordInfo.removeDups(typedWord, suggestionsContainer);
- // If resumed, then we don't want to upcase everything: resuming on a fully-capitalized
- // words is rarely done to switch to another fully-capitalized word, but usually to a
- // normal, non-capitalized suggestion.
- final String firstSuggestion;
final String whitelistedWord;
- if (suggestionResults.isEmpty()) {
+ if (suggestionsContainer.isEmpty()) {
whitelistedWord = firstSuggestion = null;
} else {
- final SuggestedWordInfo firstSuggestedWordInfo = getTransformedSuggestedWordInfo(
- suggestionResults.first(), suggestionResults.mLocale,
- shouldMakeSuggestionsAllUpperCase, isOnlyFirstCharCapitalized,
- trailingSingleQuotesCount);
- firstSuggestion = firstSuggestedWordInfo.mWord;
+ final SuggestedWordInfo firstSuggestedWordInfo = suggestionsContainer.get(0);
+ final String firstSuggestion = firstSuggestedWordInfo.mWord;
if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) {
whitelistedWord = null;
} else {
@@ -145,17 +139,10 @@ public final class Suggest {
}
}
- // We allow auto-correction if we have a whitelisted word, or if the word is not a valid
- // word of more than 1 char, except if the first suggestion is the same as the typed string
- // because in this case if it's strong enough to auto-correct that will mistakenly designate
- // the second candidate for auto-correction.
- // TODO: stop relying on indices to find where is the auto-correction in the suggested
- // words, and correct this test.
- final boolean allowsToBeAutoCorrected = (null != whitelistedWord
- && !whitelistedWord.equals(typedWord))
- || (consideredWord.length() > 1 && !mDictionaryFacilitator.isValidWord(
- consideredWord, isOnlyFirstCharCapitalized)
- && !typedWord.equals(firstSuggestion));
+ // We allow auto-correction if we have a whitelisted word, or if the word had more than
+ // one char and was not suggested.
+ final boolean allowsToBeAutoCorrected = (null != whitelistedWord)
+ || (consideredWord.length() > 1 && !didRemoveTypedWord);
final boolean hasAutoCorrection;
// TODO: using isCorrectionEnabled here is not very good. It's probably useless, because