Some users requests something like that to use different server IPs.
Interestingly, it's actually also possible to configure multiple
hostnames/IPs, separated by commas, as server address in the profile, which
are then tried one after another.
It's also useful when testing stuff to quickly compare the behavior with
some setting changed between two otherwise identical profiles.
/*
- * Copyright (C) 2012-2018 Tobias Brunner
+ * Copyright (C) 2012-2019 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager
* HSR Hochschule fuer Technik Rapperswil
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.UUID;
public class VpnProfileListFragment extends Fragment
{
private final MultiChoiceModeListener mVpnProfileSelected = new MultiChoiceModeListener() {
private MenuItem mEditProfile;
+ private MenuItem mCopyProfile;
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu)
{
mEditProfile.setEnabled(mSelected.size() == 1);
+ mCopyProfile.setEnabled(mEditProfile.isEnabled());
return true;
}
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.profile_list_context, menu);
mEditProfile = menu.findItem(R.id.edit_profile);
+ mCopyProfile = menu.findItem(R.id.copy_profile);
mode.setTitle(R.string.select_profiles);
return true;
}
startActivityForResult(connectionIntent, EDIT_REQUEST);
break;
}
+ case R.id.copy_profile:
+ {
+ int position = mSelected.iterator().next();
+ VpnProfile profile = (VpnProfile)mListView.getItemAtPosition(position);
+ profile = profile.clone();
+ profile.setUUID(UUID.randomUUID());
+ profile.setName(String.format(getString(R.string.copied_name), profile.getName()));
+ mDataSource.insertProfile(profile);
+
+ Intent intent = new Intent(Constants.VPN_PROFILES_CHANGED);
+ intent.putExtra(Constants.VPN_PROFILES_SINGLE, profile.getId());
+ LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent);
+
+ Intent connectionIntent = new Intent(getActivity(), VpnProfileDetailActivity.class);
+ connectionIntent.putExtra(VpnProfileDataSource.KEY_ID, profile.getId());
+ startActivityForResult(connectionIntent, EDIT_REQUEST);
+ break;
+ }
case R.id.delete_profile:
{
ArrayList<VpnProfile> profiles = new ArrayList<>();
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Tobias Brunner
+ Copyright (C) 2012-2019 Tobias Brunner
HSR Hochschule fuer Technik Rapperswil
This program is free software; you can redistribute it and/or modify it
<item android:id="@+id/edit_profile"
android:title="@string/edit_profile" />
+ <item android:id="@+id/copy_profile"
+ android:title="@string/copy_profile" />
+
<item android:id="@+id/delete_profile"
android:title="@string/delete_profile" />
<string name="no_profiles">Keine VPN Profile vorhanden.</string>
<string name="add_profile">Profil hinzufügen</string>
<string name="edit_profile">Bearbeiten</string>
+ <string name="copy_profile">Kopieren</string>
+ <string name="copied_name">%1$s (Kopie)</string>
<string name="delete_profile">Löschen</string>
<string name="select_profiles">Profile auswählen</string>
<string name="profiles_deleted">Ausgewählte Profile gelöscht</string>
<string name="no_profiles">Brak profilu VPN</string>
<string name="add_profile">Dodaj profil VPN</string>
<string name="edit_profile">Edytuj</string>
+ <string name="copy_profile">Copy</string>
+ <string name="copied_name">%1$s (Copy)</string>
<string name="delete_profile">Usuń</string>
<string name="select_profiles">Wybierz profile</string>
<string name="profiles_deleted">Wybrane profile usunięte</string>
<string name="no_profiles">VPN профили не обнаружены.</string>
<string name="add_profile">Добавить VPN профиль</string>
<string name="edit_profile">Редактировать</string>
+ <string name="copy_profile">Copy</string>
+ <string name="copied_name">%1$s (Copy)</string>
<string name="delete_profile">Удалить</string>
<string name="select_profiles">Выбрать профили</string>
<string name="profiles_deleted">Выбранные профили удалены</string>
<string name="no_profiles">Немає VPN профілів</string>
<string name="add_profile">Додати VPN профіль</string>
<string name="edit_profile">Редагувати</string>
+ <string name="copy_profile">Copy</string>
+ <string name="copied_name">%1$s (Copy)</string>
<string name="delete_profile">Видалити</string>
<string name="select_profiles">Обрати профіль</string>
<string name="profiles_deleted">Обрані профілі видалено</string>
<string name="no_profiles">无配置.</string>
<string name="add_profile">添加VPN配置</string>
<string name="edit_profile">编辑</string>
+ <string name="copy_profile">Copy</string>
+ <string name="copied_name">%1$s (Copy)</string>
<string name="delete_profile">删除</string>
<string name="select_profiles">选择配置</string>
<string name="profiles_deleted">所选配置已删除</string>
<string name="no_profiles">沒有設定檔</string>
<string name="add_profile">新增VPN設定檔</string>
<string name="edit_profile">編輯</string>
+ <string name="copy_profile">Copy</string>
+ <string name="copied_name">%1$s (Copy)</string>
<string name="delete_profile">刪除</string>
<string name="select_profiles">選擇設定檔</string>
<string name="profiles_deleted">選擇的設定檔已經刪除</string>
<string name="no_profiles">No VPN profiles.</string>
<string name="add_profile">Add VPN profile</string>
<string name="edit_profile">Edit</string>
+ <string name="copy_profile">Copy</string>
+ <string name="copied_name">%1$s (Copy)</string>
<string name="delete_profile">Delete</string>
<string name="select_profiles">Select profiles</string>
<string name="profiles_deleted">Selected profiles deleted</string>