From 2e1c94d3f51dc6d667435b2a2bbd81a036d57bae Mon Sep 17 00:00:00 2001 From: akuma Date: Sun, 8 Sep 2019 20:40:29 +0200 Subject: New icon and text for Excluded Apps. Using PreferenceHelper. Test done. --- .../se/leap/bitmaskclient/utils/PreferenceHelper.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java index f5cf590b..9eb4c972 100644 --- a/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java @@ -12,9 +12,11 @@ import org.json.JSONObject; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import de.blinkt.openvpn.VpnProfile; import se.leap.bitmaskclient.Provider; @@ -29,6 +31,7 @@ import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION; import static se.leap.bitmaskclient.Constants.PROVIDER_PRIVATE_KEY; import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE; import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; +import static se.leap.bitmaskclient.Constants.EXCLUDED_APPS; /** * Created by cyberta on 18.03.18. @@ -256,6 +259,21 @@ public class PreferenceHelper { return result; } + public static void setExcludedApps(Context context, Set apps) { + SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); + SharedPreferences.Editor prefsedit = prefs.edit(); + prefsedit.putStringSet(EXCLUDED_APPS, apps); + prefsedit.apply(); + } + + public static Set getExcludedApps(Context context) { + if (context == null) { + return null; + } + SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); + return preferences.getStringSet(EXCLUDED_APPS, new HashSet<>()); + } + public static String getString(Context context, String key, String defValue) { SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); return preferences.getString(key, defValue); @@ -266,4 +284,5 @@ public class PreferenceHelper { preferences.edit().putString(key, value).apply(); } + } -- cgit v1.2.3