diff options
author | Fup Duck <fupduck@sacknagel.com> | 2018-01-23 16:15:43 +0100 |
---|---|---|
committer | Fup Duck <fupduck@sacknagel.com> | 2018-01-23 16:15:43 +0100 |
commit | f18f51aa68bf3443d38163f1bd1d25a45ed14102 (patch) | |
tree | a1c905202584088b41c74e0b6480e3cbc5185c8a | |
parent | 26db3cd2398e0ae80fcc53e7933f2de747c074b4 (diff) | |
parent | 8333bd0ad9a6c4f6b07513d29ec8008e11a246dc (diff) |
Merge branch '8819_config_wizard_design' into 8826_custom_provider
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java | 12 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java | 22 |
2 files changed, 26 insertions, 8 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index cb52eb48..b5040cdc 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -432,15 +432,21 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity int resultCode = intent.getIntExtra(RESULT_CODE, -1); Log.d(TAG, "Broadcast resultCode: " + Integer.toString(resultCode)); + Bundle resultData = intent.getParcelableExtra(RESULT_KEY); + String handledProvider = resultData.getString(Provider.KEY); - if (getProviderName().equalsIgnoreCase(provider.getName()) && - getProviderDomain().equalsIgnoreCase(provider.getDomain())) { + String providerName = getProviderName(handledProvider); + String providerDomain = getProviderDomain(handledProvider); + + if (providerName != null && providerName.equalsIgnoreCase(provider.getName()) && + providerDomain != null && + providerDomain.equalsIgnoreCase(provider.getDomain())) { switch (resultCode) { case PROVIDER_OK: handleProviderSetUp(); break; case PROVIDER_NOK: - handleProviderSetupFailed((Bundle) intent.getParcelableExtra(RESULT_KEY)); + handleProviderSetupFailed(resultData); break; case CORRECTLY_DOWNLOADED_CERTIFICATE: handleCorrectlyDownloadedCertificate(); diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java index 98715c1a..1ad12042 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java @@ -5,7 +5,6 @@ import android.os.Bundle; import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.annotation.StringRes; -import android.support.v4.app.FragmentTransaction; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.AppCompatTextView; import android.view.View; @@ -18,7 +17,6 @@ import org.json.JSONObject; import java.util.Locale; import butterknife.InjectView; -import se.leap.bitmaskclient.userstatus.SessionDialog; import static android.view.View.GONE; import static android.view.View.VISIBLE; @@ -91,13 +89,20 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity { } protected String getProviderName() { + return getProviderName(null); + } + + protected String getProviderName(@Nullable String provider) { + if (provider == null) { + provider = preferences.getString(Provider.KEY, ""); + } try { - JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, "")); + JSONObject providerJson = new JSONObject(provider); String lang = Locale.getDefault().getLanguage(); return providerJson.getJSONObject(Provider.NAME).getString(lang); } catch (JSONException e) { try { - JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, "")); + JSONObject providerJson = new JSONObject(provider); return providerJson.getJSONObject(Provider.NAME).getString("en"); } catch (JSONException e2) { return null; @@ -106,8 +111,15 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity { } protected String getProviderDomain() { + return getProviderDomain(null); + } + + protected String getProviderDomain(@Nullable String provider) { + if (provider == null) { + provider = preferences.getString(Provider.KEY, ""); + } try { - JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, "")); + JSONObject providerJson = new JSONObject(provider); return providerJson.getString(Provider.DOMAIN); } catch (JSONException e) { return null; |