summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-01-16 18:31:37 +0100
committerFup Duck <fupduck@sacknagel.com>2018-01-16 18:31:37 +0100
commitdf1e68c672de71633e99234360ea92d77e67a86d (patch)
tree5ee4dbf0e5b7d9a346423fa4e7c499d7950d551d /app/src/main/java/se/leap
parent4f536f457da8bb7ab0316f6de7703437ad0ce58f (diff)
corretly handle dialog on orientation change
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
index 64ea4779..d0868437 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
@@ -118,6 +118,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
//TODO: add some states (values for progressbarText) about ongoing setup or remove that field
private boolean isActivityShowing;
+ private String reasonToFail;
public abstract void retrySetUpProvider();
@@ -140,6 +141,13 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
outState.putString(PROGRESSBAR_TEXT, progressbarDescription.getText().toString());
outState.putString(ACTIVITY_STATE, mConfigState.getAction());
outState.putParcelable(Provider.KEY, selectedProvider);
+
+ DialogFragment dialogFragment = (DialogFragment) fragmentManager.findFragmentByTag(DownloadFailedDialog.TAG);
+ if (dialogFragment != null) {
+ outState.putString(REASON_TO_FAIL, reasonToFail);
+ dialogFragment.dismiss();
+ }
+
super.onSaveInstanceState(outState);
}
@@ -160,9 +168,15 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
}
private void restoreState(Bundle savedInstanceState) {
+
selectedProvider = savedInstanceState.getParcelable(Provider.KEY);
mConfigState.setAction(savedInstanceState.getString(ACTIVITY_STATE, PROVIDER_NOT_SET));
+ reasonToFail = savedInstanceState.getString(REASON_TO_FAIL);
+ if(reasonToFail != null) {
+ showDownloadFailedDialog();
+ }
+
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())
) {
@@ -180,9 +194,8 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
showProgressBar();
adapter.hideAllBut(adapter.indexOf(selectedProvider));
checkProviderSetUp();
- showDownloadFailedDialog(null);
} else if (PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
- showDownloadFailedDialog(mConfigState.getStringExtra(REASON_TO_FAIL));
+ showDownloadFailedDialog();
} else if (SHOWING_PROVIDER_DETAILS.equals(mConfigState.getAction())) {
cancelAndShowAllProviders();
}
@@ -259,8 +272,8 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
setResult(RESULT_CANCELED, mConfigState);
- String reasonToFail = resultData.getString(ERRORS);
- showDownloadFailedDialog(reasonToFail);
+ reasonToFail = resultData.getString(ERRORS);
+ showDownloadFailedDialog();
}
void handleCorrectlyDownloadedCertificate() {
@@ -418,10 +431,8 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
/**
* Shows an error dialog, if configuring of a provider failed.
- *
- * @param reasonToFail - the reason it has failed
*/
- public void showDownloadFailedDialog(String reasonToFail) {
+ public void showDownloadFailedDialog() {
try {
FragmentTransaction fragmentTransaction = fragmentManager.removePreviousFragment(DownloadFailedDialog.TAG);
DialogFragment newFragment;