diff options
author | Arne Schwabe <arne@rfc2549.org> | 2019-08-02 12:50:57 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2019-08-05 16:01:34 +0200 |
commit | 32b080261845c7508581f9c452d48ffd2401c450 (patch) | |
tree | 76d194fedd0ec9e9250a96b4157aa32b3eead627 /main/src/ui/java/de/blinkt/openvpn/views/DefaultVPNListPreference.java | |
parent | f72ab87b31044eb5df3a8b6ed802208444d226e3 (diff) |
Add skeleton build variant
Diffstat (limited to 'main/src/ui/java/de/blinkt/openvpn/views/DefaultVPNListPreference.java')
-rw-r--r-- | main/src/ui/java/de/blinkt/openvpn/views/DefaultVPNListPreference.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/main/src/ui/java/de/blinkt/openvpn/views/DefaultVPNListPreference.java b/main/src/ui/java/de/blinkt/openvpn/views/DefaultVPNListPreference.java new file mode 100644 index 00000000..e8328f5c --- /dev/null +++ b/main/src/ui/java/de/blinkt/openvpn/views/DefaultVPNListPreference.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012-2018 Arne Schwabe + * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt + */ + +package de.blinkt.openvpn.views; + +import android.content.Context; +import android.preference.ListPreference; +import android.util.AttributeSet; +import de.blinkt.openvpn.VpnProfile; +import de.blinkt.openvpn.core.ProfileManager; + +import java.util.Collection; + +public class DefaultVPNListPreference extends ListPreference { + public DefaultVPNListPreference(Context context, AttributeSet attrs) { + super(context, attrs); + setVPNs(context); + } + + private void setVPNs(Context c) { + ProfileManager pm = ProfileManager.getInstance(c); + Collection<VpnProfile> profiles = pm.getProfiles(); + CharSequence[] entries = new CharSequence[profiles.size()]; + CharSequence[] entryValues = new CharSequence[profiles.size()];; + + int i=0; + for (VpnProfile p: profiles) + { + entries[i]=p.getName(); + entryValues[i]=p.getUUIDString(); + i++; + } + + setEntries(entries); + setEntryValues(entryValues); + } +} |