Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c6693a2 authored by Jean Chalard's avatar Jean Chalard
Browse files

Refactoring for whitelist (A83)

Avoid special casing the whitelist dictionary by having it implement
the interface it pretends it implements

Change-Id: I8b873cb0f3fe13cefd32c8cb756a25c8ae16a2b4
parent fb6eeeb3
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -194,9 +194,6 @@ public class Suggest {
            }
            // At second character typed, search the unigrams (scores being affected by bigrams)
            for (final String key : mDictionaries.keySet()) {
                // Skip WhitelistDictionary to lookup
                if (key.equals(Dictionary.TYPE_WHITELIST))
                    continue;
                final Dictionary dictionary = mDictionaries.get(key);
                suggestionsSet.addAll(dictionary.getWords(
                        wordComposerForLookup, prevWordForBigram, proximityInfo));
+11 −0
Original line number Diff line number Diff line
@@ -22,8 +22,11 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;

import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;

@@ -88,6 +91,14 @@ public class WhitelistDictionary extends ExpandableDictionary {
        return null;
    }

    @Override
    public ArrayList<SuggestedWordInfo> getWords(final WordComposer composer,
            final CharSequence prevWord, final ProximityInfo proximityInfo) {
        // Whitelist does not supply suggestions (actually it should not even implement the
        // Dictionary interface, as it responds to none of it, but it does for legacy reasons)
        return null;
    }

    // See LatinIME#updateSuggestions. This breaks in the (queer) case that the whitelist
    // lists that word a should autocorrect to word b, and word c would autocorrect to
    // an upper-cased version of a. In this case, the way this return value is used would