From 84d3b5f6967c0bac2a740627386ff92b6e283b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 3 Jul 2013 18:02:36 +0200 Subject: 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). --- src/se/leap/leapclient/ConfigHelper.java | 3 ++- src/se/leap/leapclient/ConfigurationWizard.java | 14 +++++++++++++- src/se/leap/leapclient/ProviderDetailFragment.java | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/se/leap') 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() { -- cgit v1.2.3