summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java3
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java14
-rw-r--r--src/se/leap/leapclient/ProviderDetailFragment.java3
3 files changed, 18 insertions, 2 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 10b3edf4..007db95c 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -178,7 +178,8 @@ public class ConfigHelper {
public static JSONObject getJsonFromSharedPref(String shared_preferences_key) throws JSONException {
JSONObject content = null;
if ( checkSharedPrefs() ) {
- content = new JSONObject( shared_preferences.getString(shared_preferences_key, "") );
+ String json_string = shared_preferences.getString(shared_preferences_key, "");
+ content = new JSONObject(json_string);
}
return content;
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index 23220e79..d12fdc77 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -154,10 +154,22 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
@Override
public void onBackPressed() {
+ try {
+ if(ConfigHelper.getJsonFromSharedPref(ConfigHelper.PROVIDER_KEY) == null || ConfigHelper.getJsonFromSharedPref(ConfigHelper.PROVIDER_KEY).length() == 0) {
+ askDashboardToQuitApp();
+ } else {
+ setResult(RESULT_OK);
+ }
+ } catch (JSONException e) {
+ askDashboardToQuitApp();
+ }
+ super.onBackPressed();
+ }
+
+ private void askDashboardToQuitApp() {
Intent ask_quit = new Intent();
ask_quit.putExtra(ConfigHelper.QUIT, ConfigHelper.QUIT);
setResult(RESULT_CANCELED, ask_quit);
- super.onBackPressed();
}
private ProviderItem getProvider(String id) {
diff --git a/src/se/leap/leapclient/ProviderDetailFragment.java b/src/se/leap/leapclient/ProviderDetailFragment.java
index 0b707d3e..a788594f 100644
--- a/src/se/leap/leapclient/ProviderDetailFragment.java
+++ b/src/se/leap/leapclient/ProviderDetailFragment.java
@@ -79,6 +79,9 @@ public class ProviderDetailFragment extends DialogFragment {
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
ConfigHelper.removeFromSharedPref(ConfigHelper.PROVIDER_KEY);
+ ConfigHelper.removeFromSharedPref(ConfigHelper.DANGER_ON);
+ ConfigHelper.removeFromSharedPref(ConfigHelper.ALLOWED_ANON);
+ ConfigHelper.removeFromSharedPref(ConfigHelper.EIP_SERVICE_KEY);
}
public static DialogFragment newInstance() {