diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java | 14 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java | 22 |
2 files changed, 26 insertions, 10 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 0726a785..375ef038 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -116,8 +116,6 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity @Override protected void onSaveInstanceState(@NotNull Bundle outState) { - //if (progressbarDescription != null) - // outState.putString(PROGRESSBAR_TEXT, progressbarDescription.getText().toString()); outState.putString(ACTIVITY_STATE, mConfigState.getAction()); outState.putParcelable(Provider.KEY, provider); @@ -447,15 +445,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; |