aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Dictionary.java
diff options
context:
space:
mode:
authorDavid Faden <dfaden@google.com>2014-08-18 11:00:35 -0700
committerJean Chalard <jchalard@google.com>2014-09-18 17:42:37 +0900
commit0c837daee6236c6d9b47b1477660fef1dc057b2c (patch)
treed6acd848d66928c3c0e6868642edb228b93374e0 /java/src/com/android/inputmethod/latin/Dictionary.java
parent90f06760b917fcd8ce47228c4a541059c0075d72 (diff)
downloadlatinime-0c837daee6236c6d9b47b1477660fef1dc057b2c.tar.gz
latinime-0c837daee6236c6d9b47b1477660fef1dc057b2c.tar.xz
latinime-0c837daee6236c6d9b47b1477660fef1dc057b2c.zip
Add a Dictionary.isUserSpecific method.
As the name suggests, returns true if the Dictionary is of a type that may use user-specific data, e.g., contacts. Cherry-pick of I11e71286c7635f50ace156dcc5308dbe51268d4e Change-Id: I08c3f22f0c34eaa71bbd06594314f3b411658c5c
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Dictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Dictionary.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java
index 2f79c7662..cad9ee7d8 100644
--- a/java/src/com/android/inputmethod/latin/Dictionary.java
+++ b/java/src/com/android/inputmethod/latin/Dictionary.java
@@ -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;
@@ -159,6 +169,14 @@ public abstract class Dictionary {
}
/**
+ * 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.
*/