summaryrefslogtreecommitdiff
path: root/src/se
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-07-03 18:02:36 +0200
committerSean Leonard <meanderingcode@aetherislands.net>2013-07-12 14:27:01 -0600
commit84d3b5f6967c0bac2a740627386ff92b6e283b16 (patch)
tree0b30e1136dfbe3a367627cf1cc011f1f6d1fe0b3 /src/se
parent99a4d94564635f0223d447bc9bcf081cadd8ff36 (diff)
ConfigurationWizard backstack and exit behavior.
Feature #3023 first solution. I don't like to tell anything to the user when s/he wants to exit pressing the back button. I assume s/he is saying: "Wanna go out!!" I've implemented the behaviour written in UI Rev II. If a user selects a new provider when coming back from Switch Provider, the previous provider is forgotten and we assume s/he wants to change of provider but he is not sure to which. That means that previous provider configuration will be removed (that means there is no provider selected and Dashboard will not be launched before a new provider is selected).
Diffstat (limited to 'src/se')
-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() {