mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
Added Set<String> support for SettingsHelper and sharedPreferences
This commit is contained in:
parent
4853c1572d
commit
ea9d39c265
@ -1,5 +1,8 @@
|
||||
package awais.instagrabber.utils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class Constants {
|
||||
// string prefs
|
||||
public static final String FOLDER_PATH = "custom_path";
|
||||
@ -9,6 +12,8 @@ public final class Constants {
|
||||
public static final String APP_THEME = "app_theme_v19";
|
||||
public static final String APP_LANGUAGE = "app_language_v19";
|
||||
public static final String STORY_SORT = "story_sort";
|
||||
// set string prefs
|
||||
public static final String KEYWORD_FILTERS = "keyword_filters";
|
||||
// int prefs, do not export
|
||||
public static final String PREV_INSTALL_VERSION = "prevVersion";
|
||||
public static final String BROWSER_UA_CODE = "browser_ua_code";
|
||||
|
@ -8,6 +8,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringDef;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_ENABLE_DM_AUTO_REFRESH;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_ENABLE_DM_AUTO_REFRESH_FREQ_UNIT;
|
||||
@ -38,6 +41,7 @@ import static awais.instagrabber.utils.Constants.MUTED_VIDEOS;
|
||||
import static awais.instagrabber.utils.Constants.PREF_DARK_THEME;
|
||||
import static awais.instagrabber.utils.Constants.PREF_EMOJI_VARIANTS;
|
||||
import static awais.instagrabber.utils.Constants.PREF_HASHTAG_POSTS_LAYOUT;
|
||||
import static awais.instagrabber.utils.Constants.KEYWORD_FILTERS;
|
||||
import static awais.instagrabber.utils.Constants.PREF_LIGHT_THEME;
|
||||
import static awais.instagrabber.utils.Constants.PREF_LIKED_POSTS_LAYOUT;
|
||||
import static awais.instagrabber.utils.Constants.PREF_LOCATION_POSTS_LAYOUT;
|
||||
@ -68,6 +72,12 @@ public final class SettingsHelper {
|
||||
return stringDefault;
|
||||
}
|
||||
|
||||
public Set<String> getStringSet(@StringSetSettings final String key) {
|
||||
final Set<String> stringSetDefault = new HashSet<>();
|
||||
if (sharedPreferences != null) return sharedPreferences.getStringSet(key, stringSetDefault);
|
||||
return stringSetDefault;
|
||||
}
|
||||
|
||||
public int getInteger(@IntegerSettings final String key) {
|
||||
final int integerDefault = getIntegerDefault(key);
|
||||
if (sharedPreferences != null) return sharedPreferences.getInt(key, integerDefault);
|
||||
@ -122,6 +132,10 @@ public final class SettingsHelper {
|
||||
if (sharedPreferences != null) sharedPreferences.edit().putString(key, val).apply();
|
||||
}
|
||||
|
||||
public void putStringSet(@StringSetSettings final String key, final Set<String> val) {
|
||||
if (sharedPreferences != null) sharedPreferences.edit().putStringSet(key, val).apply();
|
||||
}
|
||||
|
||||
public void putInteger(@IntegerSettings final String key, final int val) {
|
||||
if (sharedPreferences != null) sharedPreferences.edit().putInt(key, val).apply();
|
||||
}
|
||||
@ -146,4 +160,7 @@ public final class SettingsHelper {
|
||||
|
||||
@StringDef({PREV_INSTALL_VERSION, BROWSER_UA_CODE, APP_UA_CODE, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER})
|
||||
public @interface IntegerSettings {}
|
||||
|
||||
@StringDef({KEYWORD_FILTERS})
|
||||
public @interface StringSetSettings {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user