aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-26 09:30:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-24 01:59:00 +0000
commit90759f2ab77e9bb6a47b59e6de89318516a65393 (patch)
treea6efccc32b05556ff81a80a817d0f88e3feec484 /java/src/com/android/inputmethod/latin/Suggest.java
parent8d3d0f3b847359929bc5cfb90aff077c0c9e6854 (diff)
parentb740886aeb47f8f3fb32bca7a7faa13d5756bd74 (diff)
downloadlatinime-90759f2ab77e9bb6a47b59e6de89318516a65393.tar.gz
latinime-90759f2ab77e9bb6a47b59e6de89318516a65393.tar.xz
latinime-90759f2ab77e9bb6a47b59e6de89318516a65393.zip
Merge "[CS4] Remove useless tests and processing"
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