summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorfupduck <fupduck@sacknagel.com>2017-11-21 10:44:40 -0800
committerfupduck <fupduck@sacknagel.com>2017-11-21 10:44:40 -0800
commite9f23cd2ce3038925358a98aff18bddfe8c2280c (patch)
treed29c89cff63eb32d76490ddb4a40b316e6b9103e /app/src/main
parent590f95df8a12c346346a4981c702b9b7793197fb (diff)
parent9320a608c589bab6b8a5d3bc354b22ca8f42bae8 (diff)
Merge branch '8789_IllegalStateExeption' into 'master'
#8789 fix IllegalStateException for failed provider configuring See merge request leap/bitmask_android!18
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java40
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java8
2 files changed, 34 insertions, 14 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
index 1ff0d2de..4f6163bc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
@@ -89,7 +89,9 @@ public abstract class BaseConfigurationWizard extends Activity
final protected static String PROVIDER_NOT_SET = "PROVIDER NOT SET";
final protected static String SETTING_UP_PROVIDER = "PROVIDER GETS SET";
- private static final String SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS = "PROVIDER DETAILS SHOWN";
+ final private static String PENDING_SHOW_PROVIDER_DETAILS = "PROVIDER DETAILS SHOWN";
+ final private static String PENDING_SHOW_FAILED_DIALOG = "SHOW FAILED DIALOG";
+ final private static String REASON_TO_FAIL = "REASON TO FAIL";
final protected static String PROVIDER_SET = "PROVIDER SET";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
@@ -149,7 +151,11 @@ public abstract class BaseConfigurationWizard extends Activity
progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
selected_provider = savedInstanceState.getParcelable(Provider.KEY);
- if (fragment_manager.findFragmentByTag(ProviderDetailFragment.TAG) == null && SETTING_UP_PROVIDER.equals(mConfigState.getAction())) {
+ if (fragment_manager.findFragmentByTag(ProviderDetailFragment.TAG) == null &&
+ (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
+ PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction()) ||
+ PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())
+ )) {
onItemSelectedUi();
}
}
@@ -160,8 +166,10 @@ public abstract class BaseConfigurationWizard extends Activity
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) {
showProgressBar();
adapter.hideAllBut(adapter.indexOf(selected_provider));
- } else if (SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS.equals(mConfigState.getAction())) {
+ } else if (PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction())) {
showProviderDetails();
+ } else if (PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
+ showDownloadFailedDialog(mConfigState.getStringExtra(REASON_TO_FAIL));
}
}
@@ -248,7 +256,8 @@ public abstract class BaseConfigurationWizard extends Activity
@OnItemClick(R.id.provider_list)
void onItemSelected(int position) {
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
- SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS.equals(mConfigState.getAction())) {
+ PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction()) ||
+ PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
return;
}
@@ -266,7 +275,9 @@ public abstract class BaseConfigurationWizard extends Activity
@Override
public void onBackPressed() {
- if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) {
+ if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
+ PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction()) ||
+ PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
stopSettingUpProvider();
} else {
askDashboardToQuitApp();
@@ -357,17 +368,22 @@ public abstract class BaseConfigurationWizard extends Activity
}
/**
- * Once selected a provider, this fragment offers the user to log in,
- * use it anonymously (if possible)
- * or cancel his/her election pressing the back button.
+ * Shows an error dialog, if configuring of a provider failed.
*
* @param reason_to_fail
*/
public void showDownloadFailedDialog(String reason_to_fail) {
- FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG);
+ try {
+ FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG);
+
+ DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
+ newFragment.show(fragment_transaction, DownloadFailedDialog.TAG);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ mConfigState.setAction(PENDING_SHOW_FAILED_DIALOG);
+ mConfigState.putExtra(REASON_TO_FAIL, reason_to_fail);
+ }
- DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
- newFragment.show(fragment_transaction, DownloadFailedDialog.TAG);
}
@@ -380,7 +396,6 @@ public abstract class BaseConfigurationWizard extends Activity
*
*/
public void showProviderDetails() {
- mConfigState.setAction(SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS);
try {
FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(ProviderDetailFragment.TAG);
@@ -388,6 +403,7 @@ public abstract class BaseConfigurationWizard extends Activity
newFragment.show(fragment_transaction, ProviderDetailFragment.TAG);
} catch (IllegalStateException e) {
e.printStackTrace();
+ mConfigState.setAction(PENDING_SHOW_PROVIDER_DETAILS);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index a47b8767..3f1663d0 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -349,8 +349,12 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
}
public void sessionDialog(Bundle resultData) {
- FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG);
- SessionDialog.getInstance(provider, resultData).show(transaction, SessionDialog.TAG);
+ try {
+ FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG);
+ SessionDialog.getInstance(provider, resultData).show(transaction, SessionDialog.TAG);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
}
private void switchProvider() {