android: Use the same tag string for all dialogs in MainActivity

This commit is contained in:
Tobias Brunner 2012-11-20 16:06:39 +01:00
parent 8c0b32d892
commit 73d0fb0a66

View File

@ -62,6 +62,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
private static final String PROFILE_NAME = "org.strongswan.android.MainActivity.PROFILE_NAME"; private static final String PROFILE_NAME = "org.strongswan.android.MainActivity.PROFILE_NAME";
private static final String PROFILE_REQUIRES_PASSWORD = "org.strongswan.android.MainActivity.REQUIRES_PASSWORD"; private static final String PROFILE_REQUIRES_PASSWORD = "org.strongswan.android.MainActivity.REQUIRES_PASSWORD";
private static final String PROFILE_RECONNECT = "org.strongswan.android.MainActivity.RECONNECT"; private static final String PROFILE_RECONNECT = "org.strongswan.android.MainActivity.RECONNECT";
private static final String DIALOG_TAG = "Dialog";
private Bundle mProfileInfo; private Bundle mProfileInfo;
private VpnStateService mService; private VpnStateService mService;
@ -218,9 +219,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
profileInfo.putBoolean(PROFILE_REQUIRES_PASSWORD, profile.getVpnType().getRequiresUsernamePassword()); profileInfo.putBoolean(PROFILE_REQUIRES_PASSWORD, profile.getVpnType().getRequiresUsernamePassword());
profileInfo.putString(PROFILE_NAME, profile.getName()); profileInfo.putString(PROFILE_NAME, profile.getName());
removeFragmentByTag("ConfirmationDialog"); removeFragmentByTag(DIALOG_TAG);
removeFragmentByTag("LoginDialog");
removeFragmentByTag("ErrorDialog");
if (mService != null && mService.getState() == State.CONNECTED) if (mService != null && mService.getState() == State.CONNECTED)
{ {
@ -228,7 +227,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
ConfirmationDialog dialog = new ConfirmationDialog(); ConfirmationDialog dialog = new ConfirmationDialog();
dialog.setArguments(profileInfo); dialog.setArguments(profileInfo);
dialog.show(this.getFragmentManager(), "ConfirmationDialog"); dialog.show(this.getFragmentManager(), DIALOG_TAG);
return; return;
} }
startVpnProfile(profileInfo); startVpnProfile(profileInfo);
@ -245,7 +244,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
{ {
LoginDialog login = new LoginDialog(); LoginDialog login = new LoginDialog();
login.setArguments(profileInfo); login.setArguments(profileInfo);
login.show(getFragmentManager(), "LoginDialog"); login.show(getFragmentManager(), DIALOG_TAG);
return; return;
} }
prepareVpnService(profileInfo); prepareVpnService(profileInfo);
@ -417,7 +416,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
bundle.putInt(ERROR_MESSAGE_ID, messageId); bundle.putInt(ERROR_MESSAGE_ID, messageId);
VpnNotSupportedError dialog = new VpnNotSupportedError(); VpnNotSupportedError dialog = new VpnNotSupportedError();
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(activity.getFragmentManager(), "ErrorDialog"); dialog.show(activity.getFragmentManager(), DIALOG_TAG);
} }
@Override @Override