Merge "Quit skipping user history dictionary for gesture."

main
Keisuke Kuroyanagi 2013-09-19 06:16:10 +00:00 committed by Android (Google) Code Review
commit ff493744a3
2 changed files with 18 additions and 14 deletions

View File

@ -311,9 +311,10 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
} }
@Override @Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo, final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
final int sessionId) {
reloadDictionaryIfRequired(); reloadDictionaryIfRequired();
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
final AsyncResultHolder<ArrayList<SuggestedWordInfo>> holder = final AsyncResultHolder<ArrayList<SuggestedWordInfo>> holder =
@ -321,14 +322,16 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
getExecutor(mFilename).executePrioritized(new Runnable() { getExecutor(mFilename).executePrioritized(new Runnable() {
@Override @Override
public void run() { public void run() {
final ArrayList<SuggestedWordInfo> inMemDictSuggestion = final ArrayList<SuggestedWordInfo> inMemDictSuggestion = composer.isBatchMode() ?
mDictionaryWriter.getSuggestions(composer, prevWord, proximityInfo, null : mDictionaryWriter.getSuggestionsWithSessionId(composer, prevWord,
blockOffensiveWords, additionalFeaturesOptions); proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
sessionId);
// TODO: Remove checking mIsUpdatable and use native suggestion. // TODO: Remove checking mIsUpdatable and use native suggestion.
if (mBinaryDictionary != null && !mIsUpdatable) { if (mBinaryDictionary != null && !mIsUpdatable) {
final ArrayList<SuggestedWordInfo> binarySuggestion = final ArrayList<SuggestedWordInfo> binarySuggestion =
mBinaryDictionary.getSuggestions(composer, prevWord, proximityInfo, mBinaryDictionary.getSuggestionsWithSessionId(composer, prevWord,
blockOffensiveWords, additionalFeaturesOptions); proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
sessionId);
if (inMemDictSuggestion == null) { if (inMemDictSuggestion == null) {
holder.set(binarySuggestion); holder.set(binarySuggestion);
} else if (binarySuggestion == null) { } else if (binarySuggestion == null) {
@ -342,10 +345,17 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
} }
} }
}); });
return holder.get(null, TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS); return holder.get(null, TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS);
} }
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords,
additionalFeaturesOptions, 0 /* sessionId */);
}
@Override @Override
public boolean isValidWord(final String word) { public boolean isValidWord(final String word) {
reloadDictionaryIfRequired(); reloadDictionaryIfRequired();

View File

@ -361,12 +361,6 @@ public final class Suggest {
// At second character typed, search the unigrams (scores being affected by bigrams) // At second character typed, search the unigrams (scores being affected by bigrams)
for (final String key : mDictionaries.keySet()) { for (final String key : mDictionaries.keySet()) {
// Skip User history dictionary for lookup
// TODO: The user history dictionary should just override getSuggestionsWithSessionId
// to make sure it doesn't return anything and we should remove this test
if (key.equals(Dictionary.TYPE_USER_HISTORY)) {
continue;
}
final Dictionary dictionary = mDictionaries.get(key); final Dictionary dictionary = mDictionaries.get(key);
suggestionsSet.addAll(dictionary.getSuggestionsWithSessionId(wordComposer, suggestionsSet.addAll(dictionary.getSuggestionsWithSessionId(wordComposer,
prevWordForBigram, proximityInfo, blockOffensiveWords, prevWordForBigram, proximityInfo, blockOffensiveWords,