summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient/ConfigurationWizard.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-01-16 20:55:37 +0100
committerParménides GV <parmegv@sdf.org>2014-03-29 01:48:39 +0100
commitad0bc03af6b2010281e2cf31ae041c459dedc6a5 (patch)
tree2d388c9a9ba0e460a1346c66b20f867568a6baba /src/se/leap/bitmaskclient/ConfigurationWizard.java
parent40c58015378ca9f9b7e8ad060eacf51eaaf00057 (diff)
Back button while setting up a provider works
It stops the process, you can restart it as usual, but if you press back again you quit the app because there is no chosen provider.
Diffstat (limited to 'src/se/leap/bitmaskclient/ConfigurationWizard.java')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index 1c5f6048..1c0c1ad2 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -84,9 +84,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
public ProviderAPIResultReceiver providerAPI_result_receiver;
- private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
+ private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
- private static SharedPreferences preferences;
+ private static SharedPreferences preferences;
+ private static boolean setting_up_provider = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -159,6 +160,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
mProgressBar.setVisibility(ProgressBar.GONE);
progressbar_description.setVisibility(TextView.GONE);
setResult(RESULT_OK);
+ setting_up_provider = false;
showProviderDetails(getCurrentFocus());
}
} else if(resultCode == ProviderAPI.PROVIDER_NOK) {
@@ -166,8 +168,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
String reason_to_fail = resultData.getString(ProviderAPI.ERRORS);
showDownloadFailedDialog(getCurrentFocus(), reason_to_fail);
mProgressBar.setVisibility(ProgressBar.GONE);
- progressbar_description.setVisibility(TextView.GONE);
- preferences.edit().remove(Provider.KEY).commit();
+ progressbar_description.setVisibility(TextView.GONE);
+ preferences.edit().remove(Provider.KEY).commit();
+ setting_up_provider = false;
setResult(RESULT_CANCELED, mConfigState);
}
else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
@@ -212,19 +215,28 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
@Override
public void onBackPressed() {
- try {
- boolean is_provider_set_up = new JSONObject(preferences.getString(Provider.KEY, "no provider")) != null ? true : false;
- boolean is_provider_set_up_truly = new JSONObject(preferences.getString(Provider.KEY, "no provider")).length() != 0 ? true : false;
- if(!is_provider_set_up || !is_provider_set_up_truly) {
- askDashboardToQuitApp();
- } else {
- setResult(RESULT_OK);
- }
- } catch (JSONException e) {
- askDashboardToQuitApp();
- }
+ if(setting_up_provider) {
+ ProviderAPI.stop();
+ mProgressBar.setVisibility(ProgressBar.GONE);
+ mProgressBar.setProgress(0);
+ progressbar_description.setVisibility(TextView.GONE);
+ getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().remove(Provider.KEY).commit();
+ } else {
+ try {
+ boolean is_provider_set_up = new JSONObject(preferences.getString(Provider.KEY, "no provider")) != null ? true : false;
+ boolean is_provider_set_up_truly = new JSONObject(preferences.getString(Provider.KEY, "no provider")).length() != 0 ? true : false;
+ if(!is_provider_set_up || !is_provider_set_up_truly) {
+ askDashboardToQuitApp();
+ } else {
+ setResult(RESULT_OK);
+ }
+ } catch (JSONException e) {
+ askDashboardToQuitApp();
+ }
+ }
+ setting_up_provider = false;
super.onBackPressed();
- }
+ }
private void askDashboardToQuitApp() {
Intent ask_quit = new Intent();
@@ -448,9 +460,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
provider_API_command.setAction(ProviderAPI.SET_UP_PROVIDER);
provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
- startService(provider_API_command);
+ startService(provider_API_command);
+ setting_up_provider = true;
}
public void retrySetUpProvider() {
@@ -466,7 +479,6 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
startService(provider_API_command);
}
}
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.configuration_wizard_activity, menu);