diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-08-11 10:19:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-11 10:19:52 +0200 |
commit | 3ceb99d2e242244ab62f5ed4edc09ff416f2d965 (patch) | |
tree | 455f6bd857fb1628b7b4ac85e1dccaa9974d86f0 /app/src/main/java/de/danoeh/antennapod | |
parent | 1348169d888836f241d4fe1de036c496c6d58a8e (diff) | |
parent | c47ceb7f73372f7ce9d605383a32e5b8ec9fe85b (diff) | |
download | AntennaPod-3ceb99d2e242244ab62f5ed4edc09ff416f2d965.zip |
Merge pull request #3303 from rezanejati/develop
Add socks proxy in network settings
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java index 8f2629b43..c1008a380 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.dialog; import android.app.Dialog; import android.content.Context; import android.content.res.TypedArray; +import android.os.Build; import android.support.v4.content.ContextCompat; import android.text.Editable; import android.text.TextUtils; @@ -23,6 +24,8 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.SocketAddress; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.R; @@ -92,7 +95,11 @@ public class ProxyDialog { if(!TextUtils.isEmpty(port)) { portValue = Integer.valueOf(port); } - proxy = ProxyConfig.http(host, portValue, username, password); + if (Proxy.Type.valueOf(type) == Proxy.Type.SOCKS) { + proxy = ProxyConfig.socks(host, portValue, username, password); + } else { + proxy = ProxyConfig.http(host, portValue, username, password); + } } UserPreferences.setProxyConfig(proxy); AntennapodHttpClient.reinit(); @@ -103,7 +110,13 @@ public class ProxyDialog { .build(); View view = dialog.getCustomView(); spType = view.findViewById(R.id.spType); - String[] types = { Proxy.Type.DIRECT.name(), Proxy.Type.HTTP.name() }; + + List<String> types= new ArrayList<>(); + types.add(Proxy.Type.DIRECT.name()); + types.add(Proxy.Type.HTTP.name()); + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + types.add(Proxy.Type.SOCKS.name()); + } ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, types); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |