packages/apps/Settings
Revisão | 09cda9cfaf658d85a5316cf6f07d5f8c038a942e (tree) |
---|---|
Hora | 2009-08-03 17:26:47 |
Autor | Hung-ying Tyan <tyanh@goog...> |
Commiter | Hung-ying Tyan |
Add VPN connection lost dialog.
@@ -1847,6 +1847,7 @@ found in the list of installed applications.</string> | ||
1847 | 1847 | <string name="vpn_confirm_add_profile_cancellation">Are you sure you don\'t want to create this profile?</string> |
1848 | 1848 | <string name="vpn_confirm_edit_profile_cancellation">Are you sure you want to discard the changes made to this profile?</string> |
1849 | 1849 | <string name="vpn_confirm_reconnect">Unable to connect to the network. Do you want to try again?</string> |
1850 | + <string name="vpn_reconnect_from_lost">Connection lost. Do you want to connect again?</string> | |
1850 | 1851 | <string name="vpn_unknown_server_dialog_msg">Server name cannot be resolved. Do you want to check your server name setting?</string> |
1851 | 1852 | <string name="vpn_challenge_error_dialog_msg">Challenge error. Do you want to check your secret setting?</string> |
1852 | 1853 | <string name="vpn_secret_not_set_dialog_msg">One or more secrets are missing in this VPN configuration. Do you want to check your secret setting?</string> |
@@ -111,6 +111,7 @@ public class VpnSettings extends PreferenceActivity implements | ||
111 | 111 | private static final int DIALOG_SECRET_NOT_SET = 5; |
112 | 112 | private static final int DIALOG_CHALLENGE_ERROR = 6; |
113 | 113 | private static final int DIALOG_REMOTE_HUNG_UP_ERROR = 7; |
114 | + private static final int DIALOG_CONNECTION_LOST = 8; | |
114 | 115 | |
115 | 116 | private static final int NO_ERROR = 0; |
116 | 117 |
@@ -218,6 +219,9 @@ public class VpnSettings extends PreferenceActivity implements | ||
218 | 219 | case DIALOG_SECRET_NOT_SET: |
219 | 220 | return createSecretNotSetDialog(); |
220 | 221 | |
222 | + case DIALOG_CONNECTION_LOST: | |
223 | + return createConnectionLostDialog(); | |
224 | + | |
221 | 225 | default: |
222 | 226 | return super.onCreateDialog(id); |
223 | 227 | } |
@@ -227,7 +231,7 @@ public class VpnSettings extends PreferenceActivity implements | ||
227 | 231 | return new AlertDialog.Builder(this) |
228 | 232 | .setView(mConnectingActor.createConnectView()) |
229 | 233 | .setTitle(String.format(getString(R.string.vpn_connect_to), |
230 | - mConnectingActor.getProfile().getName())) | |
234 | + mActiveProfile.getName())) | |
231 | 235 | .setPositiveButton(getString(R.string.vpn_connect_button), |
232 | 236 | this) |
233 | 237 | .setNegativeButton(getString(android.R.string.cancel), |
@@ -277,8 +281,7 @@ public class VpnSettings extends PreferenceActivity implements | ||
277 | 281 | .setPositiveButton(R.string.vpn_yes_button, |
278 | 282 | new DialogInterface.OnClickListener() { |
279 | 283 | public void onClick(DialogInterface dialog, int w) { |
280 | - VpnProfile p = mConnectingActor.getProfile(); | |
281 | - startVpnEditor(p); | |
284 | + startVpnEditor(mActiveProfile); | |
282 | 285 | } |
283 | 286 | }) |
284 | 287 | .create(); |
@@ -289,13 +292,19 @@ public class VpnSettings extends PreferenceActivity implements | ||
289 | 292 | .setPositiveButton(R.string.vpn_yes_button, |
290 | 293 | new DialogInterface.OnClickListener() { |
291 | 294 | public void onClick(DialogInterface dialog, int w) { |
292 | - VpnProfile p = mConnectingActor.getProfile(); | |
295 | + VpnProfile p = mActiveProfile; | |
293 | 296 | onIdle(); |
294 | 297 | startVpnEditor(p); |
295 | 298 | } |
296 | 299 | }); |
297 | 300 | } |
298 | 301 | |
302 | + private Dialog createConnectionLostDialog() { | |
303 | + return createCommonDialogBuilder() | |
304 | + .setMessage(R.string.vpn_reconnect_from_lost) | |
305 | + .create(); | |
306 | + } | |
307 | + | |
299 | 308 | private AlertDialog.Builder createCommonDialogBuilder() { |
300 | 309 | return new AlertDialog.Builder(this) |
301 | 310 | .setTitle(android.R.string.dialog_alert_title) |
@@ -303,7 +312,7 @@ public class VpnSettings extends PreferenceActivity implements | ||
303 | 312 | .setPositiveButton(R.string.vpn_yes_button, |
304 | 313 | new DialogInterface.OnClickListener() { |
305 | 314 | public void onClick(DialogInterface dialog, int w) { |
306 | - connectOrDisconnect(mConnectingActor.getProfile()); | |
315 | + connectOrDisconnect(mActiveProfile); | |
307 | 316 | } |
308 | 317 | }) |
309 | 318 | .setNegativeButton(R.string.vpn_no_button, |
@@ -442,7 +451,7 @@ public class VpnSettings extends PreferenceActivity implements | ||
442 | 451 | Dialog d = (Dialog) dialog; |
443 | 452 | String error = mConnectingActor.validateInputs(d); |
444 | 453 | if (error == null) { |
445 | - changeState(mConnectingActor.getProfile(), VpnState.CONNECTING); | |
454 | + changeState(mActiveProfile, VpnState.CONNECTING); | |
446 | 455 | mConnectingActor.connect(d); |
447 | 456 | removeDialog(DIALOG_CONNECT); |
448 | 457 | return; |
@@ -760,6 +769,10 @@ public class VpnSettings extends PreferenceActivity implements | ||
760 | 769 | showDialog(DIALOG_UNKNOWN_SERVER); |
761 | 770 | break; |
762 | 771 | |
772 | + case VpnManager.VPN_ERROR_CONNECTION_LOST: | |
773 | + showDialog(DIALOG_CONNECTION_LOST); | |
774 | + break; | |
775 | + | |
763 | 776 | default: |
764 | 777 | showDialog(DIALOG_RECONNECT); |
765 | 778 | break; |