From 19dc9e690fd974eb4a951ccdf4a74bee17da4e8f Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Wed, 22 Jul 2009 05:44:39 +0800 Subject: Implement the Back button handler to save a VPN. --- src/com/android/settings/vpn/VpnEditor.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/vpn/VpnEditor.java b/src/com/android/settings/vpn/VpnEditor.java index 1d419ea..b4dc2b6 100644 --- a/src/com/android/settings/vpn/VpnEditor.java +++ b/src/com/android/settings/vpn/VpnEditor.java @@ -31,6 +31,7 @@ import android.os.Parcelable; import android.preference.PreferenceActivity; import android.preference.PreferenceGroup; import android.text.TextUtils; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -85,10 +86,9 @@ public class VpnEditor extends PreferenceActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_SAVE: - if (validateAndSetResult()) { - finish(); - } + if (validateAndSetResult()) finish(); return true; + case MENU_CANCEL: showCancellationConfirmDialog(); return true; @@ -96,6 +96,16 @@ public class VpnEditor extends PreferenceActivity { return super.onOptionsItemSelected(item); } + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + switch (keyCode) { + case KeyEvent.KEYCODE_BACK: + if (validateAndSetResult()) finish(); + return true; + } + return super.onKeyDown(keyCode, event); + } + private void initViewFor(VpnProfile profile) { setTitle(profile); mProfileEditor.loadPreferencesTo(getPreferenceScreen()); -- cgit v1.1