aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-11-21 22:49:50 +0900
committerJean Chalard <jchalard@google.com>2014-11-26 18:43:22 +0900
commit56577461d63ad3618598ceddfb9a73b797917061 (patch)
tree642c032ac1003d2447345fafa311adf30ef25381 /java/src/com/android/inputmethod/latin/SuggestedWords.java
parente752aab70dc15c993a65d7db8314a72bb9e0f8b2 (diff)
downloadlatinime-56577461d63ad3618598ceddfb9a73b797917061.tar.gz
latinime-56577461d63ad3618598ceddfb9a73b797917061.tar.xz
latinime-56577461d63ad3618598ceddfb9a73b797917061.zip
Allow whitelist changes when no close word
When there isn't a close word in another language of the current multi-language set, we allow whitelist entries to take force even if we are not confident in the current language. Bug: 18063142 Bug: 18130489 Bug: 18132240 Bug: 18136721 Bug: 18200415 Change-Id: I044674ba7b70aa86ab2a48d2e4d53a1c8007b62c
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java37
1 files changed, 7 insertions, 30 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index cbf48f0c0..390b311e2 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -356,53 +356,30 @@ public class SuggestedWords {
}
// This will always remove the higher index if a duplicate is found.
- // Returns null if the typed word is not found. Always return the dictionary for the
- // highest suggestion matching the locale if found, otherwise return the dictionary for
- // the highest suggestion.
- @Nullable
- public static Dictionary removeDupsAndReturnSourceOfTypedWord(
- @Nullable final String typedWord,
- @Nullable final Locale preferredLocale,
+ public static void removeDups(@Nullable final String typedWord,
@Nonnull ArrayList<SuggestedWordInfo> candidates) {
if (candidates.isEmpty()) {
- return null;
+ return;
}
- final Dictionary sourceDictionaryOfTypedWord;
if (!TextUtils.isEmpty(typedWord)) {
- sourceDictionaryOfTypedWord =
- removeSuggestedWordInfoFromListAndReturnSourceDictionary(typedWord,
- preferredLocale, candidates, -1 /* startIndexExclusive */);
- } else {
- sourceDictionaryOfTypedWord = null;
+ removeSuggestedWordInfoFromList(typedWord, candidates, -1 /* startIndexExclusive */);
}
for (int i = 0; i < candidates.size(); ++i) {
- removeSuggestedWordInfoFromListAndReturnSourceDictionary(candidates.get(i).mWord,
- null /* preferredLocale */, candidates, i /* startIndexExclusive */);
+ removeSuggestedWordInfoFromList(candidates.get(i).mWord, candidates,
+ i /* startIndexExclusive */);
}
- return sourceDictionaryOfTypedWord;
}
- @Nullable
- private static Dictionary removeSuggestedWordInfoFromListAndReturnSourceDictionary(
- @Nonnull final String word, @Nullable final Locale preferredLocale,
- @Nonnull final ArrayList<SuggestedWordInfo> candidates,
+ private static void removeSuggestedWordInfoFromList(
+ @Nonnull final String word, @Nonnull final ArrayList<SuggestedWordInfo> candidates,
final int startIndexExclusive) {
- Dictionary sourceDictionaryOfTypedWord = null;
for (int i = startIndexExclusive + 1; i < candidates.size(); ++i) {
final SuggestedWordInfo previous = candidates.get(i);
if (word.equals(previous.mWord)) {
- if (null == sourceDictionaryOfTypedWord
- || (null != preferredLocale
- && preferredLocale.equals(previous.mSourceDict.mLocale))) {
- if (Dictionary.TYPE_USER_HISTORY != previous.mSourceDict.mDictType) {
- sourceDictionaryOfTypedWord = previous.mSourceDict;
- }
- }
candidates.remove(i);
--i;
}
}
- return sourceDictionaryOfTypedWord;
}
}