summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/de/blinkt/openvpn/VpnProfile.java23
-rw-r--r--main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java15
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java31
-rw-r--r--main/src/main/res/drawable-hdpi/ic_content_copy_white_24dp.pngbin0 -> 287 bytes
-rw-r--r--main/src/main/res/drawable-hdpi/ic_menu_copy_holo_dark.pngbin0 -> 186 bytes
-rw-r--r--main/src/main/res/drawable-hdpi/ic_menu_copy_holo_light.pngbin0 -> 199 bytes
-rw-r--r--main/src/main/res/drawable-mdpi/ic_content_copy_white_24dp.pngbin0 -> 216 bytes
-rw-r--r--main/src/main/res/drawable-mdpi/ic_menu_copy_holo_dark.pngbin0 -> 162 bytes
-rw-r--r--main/src/main/res/drawable-mdpi/ic_menu_copy_holo_light.pngbin0 -> 161 bytes
-rw-r--r--main/src/main/res/drawable-xhdpi/ic_content_copy_white_24dp.pngbin0 -> 330 bytes
-rw-r--r--main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_dark.pngbin0 -> 261 bytes
-rw-r--r--main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_light.pngbin0 -> 252 bytes
-rw-r--r--main/src/main/res/drawable-xxhdpi/ic_content_copy_white_24dp.pngbin0 -> 436 bytes
-rw-r--r--main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_dark.pngbin0 -> 1272 bytes
-rw-r--r--main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_light.pngbin0 -> 1279 bytes
-rw-r--r--main/src/main/res/drawable-xxxhdpi/ic_content_copy_white_24dp.pngbin0 -> 522 bytes
-rw-r--r--main/src/main/res/menu/vpnpreferences_menu.xml9
-rw-r--r--main/src/main/res/values-v21/refs.xml1
-rw-r--r--main/src/main/res/values/refs.xml2
-rwxr-xr-xmain/src/main/res/values/strings.xml2
20 files changed, 72 insertions, 11 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
index c8cf7ac8..fbc1dfff 100644
--- a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -55,7 +55,7 @@ import de.blinkt.openvpn.core.VPNLaunchHelper;
import de.blinkt.openvpn.core.VpnStatus;
import de.blinkt.openvpn.core.X509Utils;
-public class VpnProfile implements Serializable {
+public class VpnProfile implements Serializable, Cloneable {
// Note that this class cannot be moved to core where it belongs since
// the profile loading depends on it being here
// The Serializable documentation mentions that class name change are possible
@@ -667,6 +667,27 @@ public class VpnProfile implements Serializable {
}
}
+ @Override
+ protected VpnProfile clone() throws CloneNotSupportedException {
+ VpnProfile copy = (VpnProfile) super.clone();
+ copy.mUuid = UUID.randomUUID();
+ copy.mConnections = mConnections.clone();
+ copy.mAllowedAppsVpn = (HashSet<String>) mAllowedAppsVpn.clone();
+ return copy;
+ }
+
+ public VpnProfile copy(String name) {
+ try {
+ VpnProfile copy = (VpnProfile) clone();
+ copy.mName = name;
+ return copy;
+
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
class NoCertReturnedException extends Exception {
public NoCertReturnedException (String msg) {
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java b/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java
index 2ef0dcce..c8f34519 100644
--- a/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java
+++ b/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java
@@ -9,6 +9,7 @@ import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
@@ -17,6 +18,8 @@ import android.preference.PreferenceActivity;
import android.support.v4n.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
+import android.widget.EditText;
+import android.widget.Toast;
import de.blinkt.openvpn.R;
import de.blinkt.openvpn.VpnProfile;
@@ -181,11 +184,19 @@ public class VPNPreferences extends Activity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if(item.getItemId() == R.id.remove_vpn)
+ if (item.getItemId() == R.id.remove_vpn)
askProfileRemoval();
- return super.onOptionsItemSelected(item);
+ if (item.getItemId() == R.id.duplicate_vpn) {
+ Intent data = new Intent();
+ data.putExtra(VpnProfile.EXTRA_PROFILEUUID, mProfileUUID);
+ setResult(VPNProfileList.RESULT_VPN_DUPLICATE, data);
+ finish();
+ }
+
+ return super.onOptionsItemSelected(item);
}
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
index d13d1ca6..5bd552f8 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
@@ -37,6 +37,7 @@ import java.util.TreeSet;
public class VPNProfileList extends ListFragment {
public final static int RESULT_VPN_DELETED = Activity.RESULT_FIRST_USER;
+ public final static int RESULT_VPN_DUPLICATE = Activity.RESULT_FIRST_USER +1 ;
private static final int MENU_ADD_PROFILE = Menu.FIRST;
@@ -204,7 +205,7 @@ public class VPNProfileList extends ListFragment {
public boolean onOptionsItemSelected(MenuItem item) {
final int itemId = item.getItemId();
if (itemId == MENU_ADD_PROFILE) {
- onAddProfileClicked();
+ onAddOrDuplicateProfile(null);
return true;
} else if (itemId == MENU_IMPORT_PROFILE) {
boolean startOldFileDialog=true;
@@ -242,15 +243,19 @@ public class VPNProfileList extends ListFragment {
- private void onAddProfileClicked() {
+ private void onAddOrDuplicateProfile(final VpnProfile mCopyProfile) {
Context context = getActivity();
if (context != null) {
final EditText entry = new EditText(context);
entry.setSingleLine();
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
- dialog.setTitle(R.string.menu_add_profile);
- dialog.setMessage(R.string.add_profile_name_prompt);
+ if (mCopyProfile == null)
+ dialog.setTitle(R.string.menu_add_profile);
+ else
+ dialog.setTitle(context.getString(R.string.duplicate_profile_title, mCopyProfile.mName));
+
+ dialog.setMessage(R.string.add_profile_name_prompt);
dialog.setView(entry);
@@ -260,7 +265,12 @@ public class VPNProfileList extends ListFragment {
public void onClick(DialogInterface dialog, int which) {
String name = entry.getText().toString();
if (getPM().getProfileByName(name)==null) {
- VpnProfile profile = new VpnProfile(name);
+ VpnProfile profile;
+ if (mCopyProfile!=null)
+ profile= mCopyProfile.copy(name);
+ else
+ profile = new VpnProfile(name);
+
addProfile(profile);
editVPN(profile);
} else {
@@ -295,11 +305,18 @@ public class VPNProfileList extends ListFragment {
if(resultCode == RESULT_VPN_DELETED){
if(mArrayadapter != null && mEditProfile !=null)
mArrayadapter.remove(mEditProfile);
- }
+ } else if (resultCode == RESULT_VPN_DUPLICATE && data != null) {
+ String profileUUID = data.getStringExtra(VpnProfile.EXTRA_PROFILEUUID);
+ VpnProfile profile = ProfileManager.get(getActivity(), profileUUID);
+ if (profile != null)
+ onAddOrDuplicateProfile(profile);
+ }
+
- if(resultCode != Activity.RESULT_OK)
+ if(resultCode != Activity.RESULT_OK)
return;
+
if (requestCode == START_VPN_CONFIG) {
String configuredVPN = data.getStringExtra(VpnProfile.EXTRA_PROFILEUUID);
diff --git a/main/src/main/res/drawable-hdpi/ic_content_copy_white_24dp.png b/main/src/main/res/drawable-hdpi/ic_content_copy_white_24dp.png
new file mode 100644
index 00000000..03b1aac4
--- /dev/null
+++ b/main/src/main/res/drawable-hdpi/ic_content_copy_white_24dp.png
Binary files differ
diff --git a/main/src/main/res/drawable-hdpi/ic_menu_copy_holo_dark.png b/main/src/main/res/drawable-hdpi/ic_menu_copy_holo_dark.png
new file mode 100644
index 00000000..d37d0a31
--- /dev/null
+++ b/main/src/main/res/drawable-hdpi/ic_menu_copy_holo_dark.png
Binary files differ
diff --git a/main/src/main/res/drawable-hdpi/ic_menu_copy_holo_light.png b/main/src/main/res/drawable-hdpi/ic_menu_copy_holo_light.png
new file mode 100644
index 00000000..0dd8865f
--- /dev/null
+++ b/main/src/main/res/drawable-hdpi/ic_menu_copy_holo_light.png
Binary files differ
diff --git a/main/src/main/res/drawable-mdpi/ic_content_copy_white_24dp.png b/main/src/main/res/drawable-mdpi/ic_content_copy_white_24dp.png
new file mode 100644
index 00000000..6aa238c5
--- /dev/null
+++ b/main/src/main/res/drawable-mdpi/ic_content_copy_white_24dp.png
Binary files differ
diff --git a/main/src/main/res/drawable-mdpi/ic_menu_copy_holo_dark.png b/main/src/main/res/drawable-mdpi/ic_menu_copy_holo_dark.png
new file mode 100644
index 00000000..97e8ac1b
--- /dev/null
+++ b/main/src/main/res/drawable-mdpi/ic_menu_copy_holo_dark.png
Binary files differ
diff --git a/main/src/main/res/drawable-mdpi/ic_menu_copy_holo_light.png b/main/src/main/res/drawable-mdpi/ic_menu_copy_holo_light.png
new file mode 100644
index 00000000..74cb920f
--- /dev/null
+++ b/main/src/main/res/drawable-mdpi/ic_menu_copy_holo_light.png
Binary files differ
diff --git a/main/src/main/res/drawable-xhdpi/ic_content_copy_white_24dp.png b/main/src/main/res/drawable-xhdpi/ic_content_copy_white_24dp.png
new file mode 100644
index 00000000..04a0cc94
--- /dev/null
+++ b/main/src/main/res/drawable-xhdpi/ic_content_copy_white_24dp.png
Binary files differ
diff --git a/main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_dark.png b/main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_dark.png
new file mode 100644
index 00000000..ba883aec
--- /dev/null
+++ b/main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_dark.png
Binary files differ
diff --git a/main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_light.png b/main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_light.png
new file mode 100644
index 00000000..364b1692
--- /dev/null
+++ b/main/src/main/res/drawable-xhdpi/ic_menu_copy_holo_light.png
Binary files differ
diff --git a/main/src/main/res/drawable-xxhdpi/ic_content_copy_white_24dp.png b/main/src/main/res/drawable-xxhdpi/ic_content_copy_white_24dp.png
new file mode 100644
index 00000000..5fc17a4d
--- /dev/null
+++ b/main/src/main/res/drawable-xxhdpi/ic_content_copy_white_24dp.png
Binary files differ
diff --git a/main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_dark.png b/main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_dark.png
new file mode 100644
index 00000000..9dd56eff
--- /dev/null
+++ b/main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_dark.png
Binary files differ
diff --git a/main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_light.png b/main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_light.png
new file mode 100644
index 00000000..91043c9d
--- /dev/null
+++ b/main/src/main/res/drawable-xxhdpi/ic_menu_copy_holo_light.png
Binary files differ
diff --git a/main/src/main/res/drawable-xxxhdpi/ic_content_copy_white_24dp.png b/main/src/main/res/drawable-xxxhdpi/ic_content_copy_white_24dp.png
new file mode 100644
index 00000000..557c64f7
--- /dev/null
+++ b/main/src/main/res/drawable-xxxhdpi/ic_content_copy_white_24dp.png
Binary files differ
diff --git a/main/src/main/res/menu/vpnpreferences_menu.xml b/main/src/main/res/menu/vpnpreferences_menu.xml
index 3be376ce..d8fe2a49 100644
--- a/main/src/main/res/menu/vpnpreferences_menu.xml
+++ b/main/src/main/res/menu/vpnpreferences_menu.xml
@@ -11,5 +11,12 @@
android:icon="@drawable/ic_menu_delete"
android:showAsAction="withText|ifRoom"
android:title="@string/remove_vpn"/>
-
+
+ <item
+ android:id="@+id/duplicate_vpn"
+ android:alphabeticShortcut="c"
+ android:icon="@drawable/ic_menu_copy"
+ android:showAsAction="withText|ifRoom"
+ android:title="Duplicate VPN" />
+
</menu> \ No newline at end of file
diff --git a/main/src/main/res/values-v21/refs.xml b/main/src/main/res/values-v21/refs.xml
index 70918ab9..44be98e9 100644
--- a/main/src/main/res/values-v21/refs.xml
+++ b/main/src/main/res/values-v21/refs.xml
@@ -10,6 +10,7 @@
<drawable name="ic_menu_save">@drawable/ic_check_white_24dp</drawable>
<drawable name="ic_menu_view">@drawable/ic_filter_list_white_24dp</drawable>
<drawable name="ic_menu_delete">@drawable/ic_delete_white_24dp</drawable>
+ <drawable name="ic_menu_copy">@drawable/ic_content_copy_white_24dp</drawable>
<drawable name="ic_menu_delete_grey">@drawable/ic_delete_grey600_24dp</drawable>
<drawable name="ic_menu_edit">@drawable/ic_edit_white_24dp</drawable>
diff --git a/main/src/main/res/values/refs.xml b/main/src/main/res/values/refs.xml
index 937b5110..0d2bfce1 100644
--- a/main/src/main/res/values/refs.xml
+++ b/main/src/main/res/values/refs.xml
@@ -18,5 +18,7 @@
<drawable name="ic_menu_add_grey">@android:drawable/ic_menu_add</drawable>
<drawable name="ic_menu_import_grey">@drawable/ic_menu_archive</drawable>
<drawable name="ic_menu_delete_grey">@android:drawable/ic_menu_delete</drawable>
+ <drawable name="ic_menu_copy">@drawable/ic_menu_copy_holo_light</drawable>
+
</resources> \ No newline at end of file
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
index b692541d..09fab42f 100755
--- a/main/src/main/res/values/strings.xml
+++ b/main/src/main/res/values/strings.xml
@@ -346,5 +346,7 @@
<string name="payload_options">Payload options</string>
<string name="tls_settings">TLS Settings</string>
<string name="no_remote_defined">No remote defined</string>
+ <string name="duplicate_vpn">Duplicate VPN profile</string>
+ <string name="duplicate_profile_title">Duplicating profile: %s</string>
</resources>