Fix the retry the vpn connection issue.

Fix the issue of vpn connection retry if back button is pressed
and the profile state is still in connecting.

bug: 3278489
Change-Id: I8b51fdd65b2fdd8cbe4fb43afd916f1966b77b67
This commit is contained in:
Chung-yih Wang
2010-12-13 17:18:43 +08:00
parent eab1186a74
commit 844c54d11e

View File

@@ -216,23 +216,27 @@ public class VpnSettings extends SettingsPreferenceFragment
} }
} }
private Dialog createConnectDialog() { private class ConnectDialog extends AlertDialog {
final Activity activity = getActivity(); public ConnectDialog(Context context) {
return new AlertDialog.Builder(activity) super(context);
.setView(mConnectingActor.createConnectView()) setTitle(String.format(getString(R.string.vpn_connect_to),
.setTitle(String.format(activity.getString(R.string.vpn_connect_to), mActiveProfile.getName()));
mActiveProfile.getName())) setButton(DialogInterface.BUTTON_POSITIVE,
.setPositiveButton(activity.getString(R.string.vpn_connect_button), getString(R.string.vpn_connect_button),
this) VpnSettings.this);
.setNegativeButton(activity.getString(android.R.string.cancel), setButton(DialogInterface.BUTTON_NEGATIVE,
this) getString(android.R.string.cancel),
.setOnCancelListener(new DialogInterface.OnCancelListener() { VpnSettings.this);
public void onCancel(DialogInterface dialog) { setView(mConnectingActor.createConnectView());
removeDialog(DIALOG_CONNECT);
changeState(mActiveProfile, VpnState.IDLE);
} }
}) public void onBackPressed() {
.create(); changeState(mActiveProfile, VpnState.IDLE);
super.onBackPressed();
}
}
private Dialog createConnectDialog() {
return new ConnectDialog(getActivity());
} }
private Dialog createReconnectDialog(int id) { private Dialog createReconnectDialog(int id) {