summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/VPNPreferences.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-07-17 21:07:39 +0200
committerArne Schwabe <arne@rfc2549.org>2012-07-17 21:07:39 +0200
commit1c42c038cfdfb6e58c2938ee55ba6a2680d1afbc (patch)
tree7692eccb100d98b5d77acd6470b4b793424d5bcf /src/de/blinkt/openvpn/VPNPreferences.java
parent7b64dff3e0f514ccc6a347f3aa571c2c42f09e62 (diff)
I really like the action bar, but not using the action bar is even better ;)
Diffstat (limited to 'src/de/blinkt/openvpn/VPNPreferences.java')
-rw-r--r--src/de/blinkt/openvpn/VPNPreferences.java49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/de/blinkt/openvpn/VPNPreferences.java b/src/de/blinkt/openvpn/VPNPreferences.java
index a2c8407c..95f39548 100644
--- a/src/de/blinkt/openvpn/VPNPreferences.java
+++ b/src/de/blinkt/openvpn/VPNPreferences.java
@@ -2,13 +2,18 @@ package de.blinkt.openvpn;
import java.util.List;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.view.Menu;
+import android.view.MenuItem;
public class VPNPreferences extends PreferenceActivity {
private String mProfileUUID;
+ private VpnProfile mProfile;
public VPNPreferences() {
super();
@@ -28,9 +33,9 @@ public class VPNPreferences extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
mProfileUUID = getIntent().getStringExtra(getPackageName() + ".profileUUID");
- VpnProfile profile = ProfileManager.get(this,mProfileUUID);
- if(profile!=null) {
- setTitle(getString(R.string.edit_profile_title, profile.getName()));
+ mProfile = ProfileManager.get(this,mProfileUUID);
+ if(mProfile!=null) {
+ setTitle(getString(R.string.edit_profile_title, mProfile.getName()));
}
super.onCreate(savedInstanceState);
}
@@ -51,5 +56,43 @@ public class VPNPreferences extends PreferenceActivity {
setResult(RESULT_OK, getIntent());
super.onBackPressed();
}
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == R.id.remove_vpn)
+ askProfileRemoval();
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+
+ getMenuInflater().inflate(R.menu.vpnpreferences_menu, menu);
+
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ private void askProfileRemoval() {
+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
+ dialog.setTitle("Confirm deletion");
+ dialog.setMessage(getString(R.string.remove_vpn_query, mProfile.mName));
+
+ dialog.setPositiveButton(android.R.string.yes,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ removeProfile(mProfile);
+ }
+
+ });
+ dialog.setNegativeButton(android.R.string.no,null);
+ dialog.create().show();
+ }
+
+ protected void removeProfile(VpnProfile profile) {
+ ProfileManager.getInstance(this).removeProfile(this,profile);
+ setResult(VPNProfileList.RESULT_VPN_DELETED);
+ finish();
+ }
}