From 5e7a4193e57e042658a9f519811740fd2ce21be9 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 15 May 2013 18:35:00 +0200 Subject: [PATCH] android: Clear error only when the user explicitly dismisses the dialog The previous code worked fine on rotation changes as the fragment is destroyed and recreated causing onCreate to be called, which restores the saved error state. But if the user switches to a different application and then back this is not the case. The dialog still gets dismissed (as we have to do so to avoid nasty exceptions on rotation changes) but since that implicitly cleared the error state the UI was never fully restored. --- .../strongswan/android/ui/VpnStateFragment.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java b/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java index 738ed111f..6aec7e784 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java +++ b/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Tobias Brunner + * Copyright (C) 2012-2013 Tobias Brunner * Copyright (C) 2012 Giuliano Grassi * Copyright (C) 2012 Ralf Sager * Hochschule fuer Technik Rapperswil @@ -305,6 +305,12 @@ public class VpnStateFragment extends Fragment implements VpnStateListener } } + private void clearError() + { + mError = ErrorState.NO_ERROR; + updateView(); + } + private void showConnectDialog(String profile, String gateway) { mProgressDialog = new ProgressDialog(getActivity()); @@ -345,6 +351,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener @Override public void onClick(DialogInterface dialog, int which) { + clearError(); dialog.dismiss(); Intent logIntent = new Intent(getActivity(), LogActivity.class); startActivity(logIntent); @@ -354,16 +361,15 @@ public class VpnStateFragment extends Fragment implements VpnStateListener @Override public void onClick(DialogInterface dialog, int id) { + clearError(); dialog.dismiss(); } }).create(); mErrorDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) - { /* clear the error */ - mError = ErrorState.NO_ERROR; + { mErrorDialog = null; - updateView(); } }); mErrorDialog.show();