diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-11-20 15:47:54 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-11-21 18:57:41 +0100 |
commit | 8c0b32d892e45b5317d3ebd90ee3e7e39824ca9d (patch) | |
tree | 77c2373436b3624cb7d40ccb8be10635d8d98f4b /src/frontends | |
parent | 50b048983c051d359465e572b6b0f97f122b542e (diff) | |
download | strongswan-8c0b32d892e45b5317d3ebd90ee3e7e39824ca9d.tar.bz2 strongswan-8c0b32d892e45b5317d3ebd90ee3e7e39824ca9d.tar.xz |
android: Hide previous dialogs when handling a new connection attempt
Diffstat (limited to 'src/frontends')
-rw-r--r-- | src/frontends/android/src/org/strongswan/android/ui/MainActivity.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/frontends/android/src/org/strongswan/android/ui/MainActivity.java b/src/frontends/android/src/org/strongswan/android/ui/MainActivity.java index 2fd00efc9..50f83b2b4 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/MainActivity.java +++ b/src/frontends/android/src/org/strongswan/android/ui/MainActivity.java @@ -32,6 +32,9 @@ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.app.DialogFragment; +import android.app.Fragment; +import android.app.FragmentManager; +import android.app.FragmentTransaction; import android.app.Service; import android.content.ActivityNotFoundException; import android.content.ComponentName; @@ -215,6 +218,10 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen profileInfo.putBoolean(PROFILE_REQUIRES_PASSWORD, profile.getVpnType().getRequiresUsernamePassword()); profileInfo.putString(PROFILE_NAME, profile.getName()); + removeFragmentByTag("ConfirmationDialog"); + removeFragmentByTag("LoginDialog"); + removeFragmentByTag("ErrorDialog"); + if (mService != null && mService.getState() == State.CONNECTED) { profileInfo.putBoolean(PROFILE_RECONNECT, mService.getProfile().getId() == profile.getId()); @@ -298,6 +305,21 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen } /** + * Dismiss dialog if shown + */ + public void removeFragmentByTag(String tag) + { + FragmentManager fm = getFragmentManager(); + Fragment login = fm.findFragmentByTag(tag); + if (login != null) + { + FragmentTransaction ft = fm.beginTransaction(); + ft.remove(login); + ft.commit(); + } + } + + /** * Class that displays a confirmation dialog if a VPN profile is already connected * and then initiates the selected VPN profile if the user confirms the dialog. */ |