mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-28 18:48:09 +00:00
replace persistent HashSet singleton with simple switch
This commit is contained in:
parent
631ab60eb9
commit
a566e4d8a2
1 changed files with 14 additions and 17 deletions
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
package helium314.keyboard.latin;
|
package helium314.keyboard.latin;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import helium314.keyboard.latin.SuggestedWords.SuggestedWordInfo;
|
import helium314.keyboard.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import helium314.keyboard.latin.common.ComposedData;
|
import helium314.keyboard.latin.common.ComposedData;
|
||||||
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion;
|
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for a dictionary that can do a fuzzy search for words based on a set of key
|
* Abstract base class for a dictionary that can do a fuzzy search for words based on a set of key
|
||||||
* strokes.
|
* strokes.
|
||||||
|
@ -52,21 +52,12 @@ public abstract class Dictionary {
|
||||||
public static final String TYPE_USER = "user";
|
public static final String TYPE_USER = "user";
|
||||||
// User history dictionary internal to LatinIME.
|
// User history dictionary internal to LatinIME.
|
||||||
public static final String TYPE_USER_HISTORY = "history";
|
public static final String TYPE_USER_HISTORY = "history";
|
||||||
|
@NonNull
|
||||||
public final String mDictType;
|
public final String mDictType;
|
||||||
// The locale for this dictionary. May be null if unknown (phony dictionary for example).
|
// The locale for this dictionary. May be null if unknown (phony dictionary for example).
|
||||||
public final Locale mLocale;
|
public final Locale mLocale;
|
||||||
|
|
||||||
/**
|
public Dictionary(@NonNull final String dictType, final Locale locale) {
|
||||||
* 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(
|
|
||||||
TYPE_USER_TYPED,
|
|
||||||
TYPE_USER,
|
|
||||||
TYPE_CONTACTS,
|
|
||||||
TYPE_USER_HISTORY));
|
|
||||||
|
|
||||||
public Dictionary(final String dictType, final Locale locale) {
|
|
||||||
mDictType = dictType;
|
mDictType = dictType;
|
||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +169,13 @@ public abstract class Dictionary {
|
||||||
* @return Whether this dictionary is specific to the user.
|
* @return Whether this dictionary is specific to the user.
|
||||||
*/
|
*/
|
||||||
public boolean isUserSpecific() {
|
public boolean isUserSpecific() {
|
||||||
return sUserSpecificDictionaryTypes.contains(mDictType);
|
return switch (mDictType) {
|
||||||
|
case TYPE_USER_TYPED,
|
||||||
|
TYPE_USER,
|
||||||
|
TYPE_CONTACTS,
|
||||||
|
TYPE_USER_HISTORY -> true;
|
||||||
|
default -> false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue