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

Commit cdabc71c authored by Jean Chalard's avatar Jean Chalard Committed by Android (Google) Code Review
Browse files

Merge "Add a Dictionary.isUserSpecific method."

parents e7c2d1c9 0c837dae
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;

import java.util.ArrayList;
import java.util.Locale;
import java.util.Arrays;
import java.util.HashSet;

/**
 * Abstract base class for a dictionary that can do a fuzzy search for words based on a set of key
@@ -65,6 +67,14 @@ public abstract class Dictionary {
    // The locale for this dictionary. May be null if unknown (phony dictionary for example).
    public final Locale mLocale;

    /**
     * Set out of the dictionary types listed above that are based on data specific to the user,
     * e.g., the user's contacts.
     */
    private static final HashSet<String> sUserSpecificDictionaryTypes =
            new HashSet(Arrays.asList(new String[] { TYPE_USER_TYPED, TYPE_USER, TYPE_CONTACTS,
                    TYPE_USER_HISTORY, TYPE_PERSONALIZATION, TYPE_CONTEXTUAL }));

    public Dictionary(final String dictType, final Locale locale) {
        mDictType = dictType;
        mLocale = locale;
@@ -158,6 +168,14 @@ public abstract class Dictionary {
        return false;
    }

    /**
     * Whether this dictionary is based on data specific to the user, e.g., the user's contacts.
     * @return Whether this dictionary is specific to the user.
     */
    public boolean isUserSpecific() {
        return sUserSpecificDictionaryTypes.contains(mDictType);
    }

    /**
     * Not a true dictionary. A placeholder used to indicate suggestions that don't come from any
     * real dictionary.