summaryrefslogtreecommitdiff
path: root/app/src/debug
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-03-13 15:46:15 +0100
committerParménides GV <parmegv@sdf.org>2015-03-13 15:46:15 +0100
commitf476425c42a08e92ecb0cea99908e9b8d635fa69 (patch)
tree66eda60eaed4bce6e25e3107b16907c4601b875e /app/src/debug
parentc5124635b8272d08538889c1a9edfafe4acaf759 (diff)
parentb9120adba28b5d691375ece5a919357e54e86a7f (diff)
Merge branch 'bug/Switching-orientation-doesn't-restore-previous-UI-#6780' into develop
Diffstat (limited to 'app/src/debug')
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java16
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java102
2 files changed, 65 insertions, 53 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 27984147..ed2a063c 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -95,7 +95,6 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
outState.putString(PROGRESSBAR_TEXT, progressbar_description.getText().toString());
if(selected_provider != null)
outState.putParcelable(Provider.KEY, selected_provider);
- outState.putParcelable(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
super.onSaveInstanceState(outState);
}
@@ -112,7 +111,6 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
if(savedInstanceState != null)
restoreState(savedInstanceState);
- else
setUpProviderAPIResultReceiver();
}
@@ -121,8 +119,14 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
provider_name = savedInstanceState.getString(Provider.NAME, "");
selected_provider = savedInstanceState.getParcelable(Provider.KEY);
progress = savedInstanceState.getInt(PROGRESSBAR_NUMBER, -1);
- providerAPI_result_receiver = savedInstanceState.getParcelable(ProviderAPI.RECEIVER_KEY);
- providerAPI_result_receiver.setReceiver(this);
+
+ if(fragment_manager.findFragmentByTag(ProviderDetailFragment.TAG) == null && setting_up_provider) {
+ if (selected_provider != null)
+ onItemSelectedUi(selected_provider);
+ if (progress > 0)
+ mProgressBar.setProgress(progress);
+ }
+
}
@Override
@@ -211,7 +215,8 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
setResult(RESULT_OK);
} else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
hideProgressBar();
-
+ cancelSettingUpProvider();
+ Toast.makeText(getApplicationContext(), R.string.provider_problem, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
} else if(resultCode == AboutActivity.VIEWED) {
// Do nothing, right now
@@ -356,6 +361,7 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
DialogFragment newFragment = ProviderDetailFragment.newInstance();
newFragment.show(fragment_transaction, ProviderDetailFragment.TAG);
+ setting_up_provider = false;
}
}
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
index 0650f0ad..9ce0e99f 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -49,8 +49,8 @@ public class ProviderAPI extends IntentService {
TAG = ProviderAPI.class.getSimpleName(),
SET_UP_PROVIDER = "setUpProvider",
DOWNLOAD_NEW_PROVIDER_DOTJSON = "downloadNewProviderDotJSON",
- SRP_REGISTER = "srpRegister",
- SRP_AUTH = "srpAuth",
+ SIGN_UP = "srpRegister",
+ LOG_IN = "srpAuth",
LOG_OUT = "logOut",
DOWNLOAD_CERTIFICATE = "downloadUserAuthedCertificate",
PARAMETERS = "parameters",
@@ -118,11 +118,11 @@ public class ProviderAPI extends IntentService {
return "{ \"" + ERRORS + "\" : \""+getResources().getString(toast_string_id)+"\" }";
}
- @Override
- protected void onHandleIntent(Intent command) {
- final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY);
- String action = command.getAction();
- Bundle parameters = command.getBundleExtra(PARAMETERS);
+ @Override
+ protected void onHandleIntent(Intent command) {
+ final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY);
+ String action = command.getAction();
+ Bundle parameters = command.getBundleExtra(PARAMETERS);
if(provider_api_url == null) {
try {
JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "no provider"));
@@ -133,42 +133,48 @@ public class ProviderAPI extends IntentService {
}
}
- if(action.equalsIgnoreCase(SET_UP_PROVIDER)) {
- Bundle result = setUpProvider(parameters);
- if(go_ahead) {
- if(result.getBoolean(RESULT_KEY)) {
- receiver.send(PROVIDER_OK, result);
- } else {
- receiver.send(PROVIDER_NOK, result);
- }
- }
- } else if (action.equalsIgnoreCase(SRP_REGISTER)) {
- Bundle session_id_bundle = tryToRegister(parameters);
- if(session_id_bundle.getBoolean(RESULT_KEY)) {
- receiver.send(SUCCESSFUL_SIGNUP, session_id_bundle);
- } else {
- receiver.send(FAILED_SIGNUP, session_id_bundle);
- }
- } else if (action.equalsIgnoreCase(SRP_AUTH)) {
- Bundle session_id_bundle = tryToAuthenticate(parameters);
- if(session_id_bundle.getBoolean(RESULT_KEY)) {
- receiver.send(SUCCESSFUL_LOGIN, session_id_bundle);
- } else {
- receiver.send(FAILED_LOGIN, session_id_bundle);
- }
- } else if (action.equalsIgnoreCase(LOG_OUT)) {
- if(logOut()) {
- receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
- } else {
- receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
- }
- } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
- if(updateVpnCertificate()) {
- receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
- } else {
- receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
- }
- } else if(action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) {
+ if(action.equalsIgnoreCase(SET_UP_PROVIDER)) {
+ Bundle result = setUpProvider(parameters);
+ if(go_ahead) {
+ if(result.getBoolean(RESULT_KEY)) {
+ receiver.send(PROVIDER_OK, result);
+ } else {
+ receiver.send(PROVIDER_NOK, result);
+ }
+ }
+ } else if (action.equalsIgnoreCase(SIGN_UP)) {
+ Bundle result = tryToRegister(parameters);
+ if(result.getBoolean(RESULT_KEY)) {
+ receiver.send(SUCCESSFUL_SIGNUP, result);
+ } else {
+ receiver.send(FAILED_SIGNUP, result);
+ }
+ } else if (action.equalsIgnoreCase(LOG_IN)) {
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN);
+ Bundle result = tryToAuthenticate(parameters);
+ if(result.getBoolean(RESULT_KEY)) {
+ receiver.send(SUCCESSFUL_LOGIN, result);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN);
+ } else {
+ receiver.send(FAILED_LOGIN, result);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN);
+ }
+ } else if (action.equalsIgnoreCase(LOG_OUT)) {
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT);
+ if(logOut()) {
+ receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT);
+ } else {
+ receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT);
+ }
+ } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
+ if(updateVpnCertificate()) {
+ receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
+ } else {
+ receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
+ }
+ } else if(action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) {
Bundle result = getAndSetEipServiceJson();
if(result.getBoolean(RESULT_KEY)) {
receiver.send(CORRECTLY_DOWNLOADED_EIP_SERVICE, result);
@@ -176,13 +182,13 @@ public class ProviderAPI extends IntentService {
receiver.send(INCORRECTLY_DOWNLOADED_EIP_SERVICE, result);
}
}
- }
+ }
private Bundle tryToRegister(Bundle task) {
Bundle result = new Bundle();
int progress = 0;
- String username = task.getString(SessionDialog.USERNAME);
+ String username = User.userName();
String password = task.getString(SessionDialog.PASSWORD);
if(validUserLoginData(username, password)) {
@@ -231,8 +237,8 @@ public class ProviderAPI extends IntentService {
private Bundle tryToAuthenticate(Bundle task) {
Bundle result = new Bundle();
int progress = 0;
-
- String username = task.getString(SessionDialog.USERNAME);
+
+ String username = User.userName();
String password = task.getString(SessionDialog.PASSWORD);
if(validUserLoginData(username, password)) {
result = authenticate(username, password);
@@ -675,7 +681,7 @@ public class ProviderAPI extends IntentService {
String json_file_content = "";
URL provider_url = null;
- int seconds_of_timeout = 1;
+ int seconds_of_timeout = 2;
try {
provider_url = new URL(string_url);
URLConnection url_connection = provider_url.openConnection();