diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-09-30 23:23:35 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-09-30 23:23:35 +0200 |
commit | 90bf5121a8fc56cf309aed59a9bbd163492df81c (patch) | |
tree | 47d95d3cf57a9fe9bb7363e0d12a007a33d7f403 /src/de/blinkt/openvpn | |
parent | 4de7b0c3db7ae6435f7860e31b28af346fe1a79e (diff) |
Fix deleting a VPN profile from a preference fragment on mobile phones. (closes issue #94)
Diffstat (limited to 'src/de/blinkt/openvpn')
-rw-r--r-- | src/de/blinkt/openvpn/VPNPreferences.java | 57 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VpnProfile.java | 2 |
2 files changed, 45 insertions, 14 deletions
diff --git a/src/de/blinkt/openvpn/VPNPreferences.java b/src/de/blinkt/openvpn/VPNPreferences.java index 4bb89b6..549afa2 100644 --- a/src/de/blinkt/openvpn/VPNPreferences.java +++ b/src/de/blinkt/openvpn/VPNPreferences.java @@ -4,6 +4,7 @@ import java.util.List; import android.app.AlertDialog; import android.content.DialogInterface; +import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; import android.view.Menu; @@ -17,25 +18,52 @@ public class VPNPreferences extends PreferenceActivity { public VPNPreferences() { super(); - + } - - + + @Override protected void onStop() { super.onStop(); }; - + @Override protected void onSaveInstanceState(Bundle outState) { outState.putString(getIntent().getStringExtra(getPackageName() + ".profileUUID"),mProfileUUID); super.onSaveInstanceState(outState); } - - - + + @Override + protected void onResume() { + super.onResume(); + Intent intent = getIntent(); + + + if(intent!=null) { + String profileUUID = intent.getStringExtra(getPackageName() + ".profileUUID"); + if(profileUUID==null) { + Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); + profileUUID = initialArguments.getString(getPackageName() + ".profileUUID"); + } + if(profileUUID!=null){ + + mProfileUUID = profileUUID; + mProfile = ProfileManager.get(this,mProfileUUID); + + } + } + // When a profile is deleted from a category fragment in hadset mod we need to finish + // this activity as well when returning + if (mProfile==null || mProfile.profileDleted) { + setResult(VPNProfileList.RESULT_VPN_DELETED); + finish(); + } + + + } + @Override protected void onCreate(Bundle savedInstanceState) { mProfileUUID = getIntent().getStringExtra(getPackageName() + ".profileUUID"); @@ -44,15 +72,15 @@ public class VPNPreferences extends PreferenceActivity { if(savedUUID!=null) mProfileUUID=savedUUID; } - + mProfile = ProfileManager.get(this,mProfileUUID); if(mProfile!=null) { setTitle(getString(R.string.edit_profile_title, mProfile.getName())); } super.onCreate(savedInstanceState); } - - + + @Override public void onBuildHeaders(List<Header> target) { loadHeadersFromResource(R.xml.vpn_headers, target); @@ -62,7 +90,7 @@ public class VPNPreferences extends PreferenceActivity { header.fragmentArguments.putString(getPackageName() + ".profileUUID",mProfileUUID); } } - + @Override public void onBackPressed() { setResult(RESULT_OK, getIntent()); @@ -75,7 +103,7 @@ public class VPNPreferences extends PreferenceActivity { askProfileRemoval(); return super.onOptionsItemSelected(item); } - + @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -83,7 +111,7 @@ public class VPNPreferences extends PreferenceActivity { return super.onCreateOptionsMenu(menu); } - + private void askProfileRemoval() { AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle("Confirm deletion"); @@ -100,11 +128,12 @@ public class VPNPreferences extends PreferenceActivity { 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(); + } } diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 4ac138d..392202b 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -52,6 +52,8 @@ public class VpnProfile implements Serializable{ protected transient String mTransientPW=null; protected transient String mTransientPCKS12PW=null; private transient PrivateKey mPrivateKey; + protected boolean profileDleted=false; + public static String DEFAULT_DNS1="131.234.137.23"; public static String DEFAULT_DNS2="131.234.137.24"; |