diff options
author | cyBerta <cyberta@riseup.net> | 2018-06-14 21:12:20 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2018-06-14 21:12:20 +0200 |
commit | 452b42326167b97081bc386dbb8fd800075d1269 (patch) | |
tree | ca14573e065748fe6a2aad5a096c2d713e0c6e39 /app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java | |
parent | dc4e74975afcba8a694ec23666c538dc761277b1 (diff) | |
parent | 117ec679f83e67762552e2c16310a1f57a9b9d88 (diff) |
Merge branch 'mirror_0xacab_master' into #8889_revise_NavigationDrawer
fix merge conflict in NavigationDrawerFragment
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java index aaff9ebc..bfc77261 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java @@ -18,22 +18,20 @@ package se.leap.bitmaskclient; import android.content.Context; import android.content.SharedPreferences; +import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.util.Log; import org.json.JSONException; import org.json.JSONObject; import org.spongycastle.util.encoders.Base64; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; @@ -51,13 +49,10 @@ import java.security.interfaces.RSAPrivateKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; 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 static android.R.attr.name; import static se.leap.bitmaskclient.Constants.ALWAYS_ON_SHOW_DIALOG; import static se.leap.bitmaskclient.Constants.DEFAULT_SHARED_PREFS_BATTERY_SAVER; import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION; @@ -442,4 +437,26 @@ public class ConfigHelper { SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); return preferences.getBoolean(ALWAYS_ON_SHOW_DIALOG, true); } + + public static JSONObject getEipDefinitionFromPreferences(SharedPreferences preferences) { + JSONObject result = new JSONObject(); + try { + String eipDefinitionString = preferences.getString(PROVIDER_EIP_DEFINITION, ""); + if (!eipDefinitionString.isEmpty()) { + result = new JSONObject(eipDefinitionString); + } + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return result; + } + + public static void ensureNotOnMainThread(@NonNull Context context) throws IllegalStateException{ + Looper looper = Looper.myLooper(); + if (looper != null && looper == context.getMainLooper()) { + throw new IllegalStateException( + "calling this from your main thread can lead to deadlock"); + } + } } |