diff options
author | Parménides GV <parmegv@sdf.org> | 2015-06-01 10:50:02 +0200 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2015-06-01 10:50:02 +0200 |
commit | 21aa11e5e04ffef3111010140cd7336fe181de39 (patch) | |
tree | 6af11a281ce9fd4c8e70863d10093d910751bf66 /app/src/debug/java/se/leap | |
parent | e5e9ac6e43b9cdec0f362711bb33747ab73fc297 (diff) | |
parent | 03973cf7f9b0f8635b6835c548b192eb53a2be35 (diff) |
Merge branch 'feature/Look-for-a-better-solution-to-the-VPN-slider-#6863' into develop
Diffstat (limited to 'app/src/debug/java/se/leap')
-rw-r--r-- | app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java | 19 | ||||
-rw-r--r-- | app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java | 20 |
2 files changed, 17 insertions, 22 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java index aac53a07..2505d37b 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -40,6 +40,7 @@ import se.leap.bitmaskclient.ProviderAPIResultReceiver.Receiver; import se.leap.bitmaskclient.ProviderDetailFragment.ProviderDetailFragmentInterface; import se.leap.bitmaskclient.ProviderListContent.ProviderItem; import se.leap.bitmaskclient.eip.*; +import se.leap.bitmaskclient.userstatus.SessionDialog; /** * Activity that builds and shows the list of known available providers. @@ -97,8 +98,7 @@ public class ConfigurationWizard extends Activity outState.putInt(PROGRESSBAR_NUMBER, mProgressBar.getProgress()); if (progressbar_description != null) outState.putString(PROGRESSBAR_TEXT, progressbar_description.getText().toString()); - if (selected_provider != null) - outState.putParcelable(Provider.KEY, selected_provider); + outState.putParcelable(Provider.KEY, selected_provider); super.onSaveInstanceState(outState); } @@ -125,8 +125,7 @@ public class ConfigurationWizard extends Activity progress = savedInstanceState.getInt(PROGRESSBAR_NUMBER, -1); if (fragment_manager.findFragmentByTag(ProviderDetailFragment.TAG) == null && setting_up_provider) { - if (selected_provider != null) - onItemSelectedUi(); + onItemSelectedUi(); if (progress > 0) mProgressBar.setProgress(progress); } @@ -166,8 +165,7 @@ public class ConfigurationWizard extends Activity } private void setUpProviderAPIResultReceiver() { - providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); - providerAPI_result_receiver.setReceiver(this); + providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this); providerAPI_broadcast_receiver_update = new ProviderAPIBroadcastReceiver_Update(); IntentFilter update_intent_filter = new IntentFilter(ProviderAPI.UPDATE_PROGRESSBAR); @@ -196,8 +194,6 @@ public class ConfigurationWizard extends Activity mProgressBar.incrementProgressBy(1); hideProgressBar(); - setResult(RESULT_OK); - showProviderDetails(); } } else if (resultCode == ProviderAPI.PROVIDER_NOK) { @@ -205,8 +201,6 @@ public class ConfigurationWizard extends Activity preferences.edit().remove(Provider.KEY).apply(); setting_up_provider = false; - setResult(RESULT_CANCELED, mConfigState); - String reason_to_fail = resultData.getString(ProviderAPI.ERRORS); showDownloadFailedDialog(reason_to_fail); } else if (resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) { @@ -214,13 +208,10 @@ public class ConfigurationWizard extends Activity hideProgressBar(); showProviderDetails(); - - 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 // I need this for CW to wait for the About activity to end before going back to Dashboard. @@ -393,7 +384,7 @@ public class ConfigurationWizard extends Activity public void setUpProvider(boolean danger_on) { Intent provider_API_command = new Intent(this, ProviderAPI.class); Bundle parameters = new Bundle(); - parameters.putString(Provider.MAIN_URL, selected_provider.mainUrl().toString()); + parameters.putString(Provider.MAIN_URL, selected_provider.mainUrl().getUrl().toString()); parameters.putBoolean(ProviderItem.DANGER_ON, danger_on); parameters.putString(Provider.CA_CERT_FINGERPRINT, selected_provider.certificatePin()); diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java index 6c57fca2..2d7e13fe 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java @@ -38,6 +38,9 @@ import javax.net.ssl.*; import se.leap.bitmaskclient.ProviderListContent.*; import se.leap.bitmaskclient.eip.*; +import se.leap.bitmaskclient.userstatus.SessionDialog; +import se.leap.bitmaskclient.userstatus.User; +import se.leap.bitmaskclient.userstatus.UserStatus; /** * Implements HTTP api methods used to manage communications with the provider server. @@ -145,7 +148,7 @@ public class ProviderAPI extends IntentService { receiver.send(PROVIDER_NOK, result); } } else if (action.equalsIgnoreCase(SIGN_UP)) { - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP, resources); + UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources); Bundle result = tryToRegister(parameters); if (result.getBoolean(RESULT_KEY)) { receiver.send(SUCCESSFUL_SIGNUP, result); @@ -153,23 +156,24 @@ public class ProviderAPI extends IntentService { receiver.send(FAILED_SIGNUP, result); } } else if (action.equalsIgnoreCase(LOG_IN)) { - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN, resources); + UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources); Bundle result = tryToAuthenticate(parameters); if (result.getBoolean(RESULT_KEY)) { receiver.send(SUCCESSFUL_LOGIN, result); - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN, resources); + UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources); } else { receiver.send(FAILED_LOGIN, result); - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN, resources); + UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources); } } else if (action.equalsIgnoreCase(LOG_OUT)) { - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT, resources); + UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources); if (logOut()) { receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY); - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT, resources); + android.util.Log.d(TAG, "Logged out, notifying user status"); + UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources); } else { receiver.send(LOGOUT_FAILED, Bundle.EMPTY); - UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT, resources); + UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources); } } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) { if (updateVpnCertificate()) { @@ -695,7 +699,7 @@ public class ProviderAPI extends IntentService { String[] pins = new String[] {ca_cert_fingerprint}; try { URL url = new URL(url_string); - HttpsURLConnection connection = PinningHelper.getPinnedHttpsURLConnection(Dashboard.getContext(), pins, url); + HttpsURLConnection connection = PinningHelper.getPinnedHttpsURLConnection(getApplicationContext(), pins, url); connection.setConnectTimeout(seconds_of_timeout * 1000); if (!LeapSRPSession.getToken().isEmpty()) connection.addRequestProperty(LeapSRPSession.AUTHORIZATION_HEADER, "Token token = " + LeapSRPSession.getToken()); |