diff options
author | ByteHamster <info@bytehamster.com> | 2022-02-07 21:49:36 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-02-07 21:49:39 +0100 |
commit | 8967fd944abecedcfa323e682cf08c084f0277b5 (patch) | |
tree | 927479b8579e3ed199cf48babe416a46b3fcd493 /core | |
parent | 4a135a5f051fcabc9ae94caf9c0561737e27865f (diff) | |
download | antennapod-8967fd944abecedcfa323e682cf08c084f0277b5.zip |
Make sure that proxy host name does not get null
And if it gets null, just ignore the setting.
Diffstat (limited to 'core')
3 files changed, 5 insertions, 22 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 08daf01e2..74f89a039 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -611,27 +611,22 @@ public class UserPreferences { public static void setProxyConfig(ProxyConfig config) { SharedPreferences.Editor editor = prefs.edit(); editor.putString(PREF_PROXY_TYPE, config.type.name()); - Proxy.Type type = Proxy.Type.valueOf(config.type.name()); - if (type == Proxy.Type.DIRECT) { - editor.apply(); - return; - } - if(TextUtils.isEmpty(config.host)) { + if (TextUtils.isEmpty(config.host)) { editor.remove(PREF_PROXY_HOST); } else { editor.putString(PREF_PROXY_HOST, config.host); } - if(config.port <= 0 || config.port > 65535) { + if (config.port <= 0 || config.port > 65535) { editor.remove(PREF_PROXY_PORT); } else { editor.putInt(PREF_PROXY_PORT, config.port); } - if(TextUtils.isEmpty(config.username)) { + if (TextUtils.isEmpty(config.username)) { editor.remove(PREF_PROXY_USER); } else { editor.putString(PREF_PROXY_USER, config.username); } - if(TextUtils.isEmpty(config.password)) { + if (TextUtils.isEmpty(config.password)) { editor.remove(PREF_PROXY_PASSWORD); } else { editor.putString(PREF_PROXY_PASSWORD, config.password); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java index bca3792b0..b26c57963 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java @@ -118,7 +118,7 @@ public class AntennapodHttpClient { builder.followSslRedirects(true); ProxyConfig config = UserPreferences.getProxyConfig(); - if (config.type != Proxy.Type.DIRECT) { + if (config.type != Proxy.Type.DIRECT && !TextUtils.isEmpty(config.host)) { int port = config.port > 0 ? config.port : ProxyConfig.DEFAULT_PORT; SocketAddress address = InetSocketAddress.createUnresolved(config.host, port); builder.proxy(new Proxy(config.type, address)); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java index 0d59a1b7e..797001e3a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java @@ -14,18 +14,6 @@ public class ProxyConfig { public static final int DEFAULT_PORT = 8080; - public static ProxyConfig direct() { - return new ProxyConfig(Proxy.Type.DIRECT, null, 0, null, null); - } - - public static ProxyConfig http(String host, int port, String username, String password) { - return new ProxyConfig(Proxy.Type.HTTP, host, port, username, password); - } - - public static ProxyConfig socks(String host, int port, String username, String password) { - return new ProxyConfig(Proxy.Type.SOCKS, host, port, username, password); - } - public ProxyConfig(Proxy.Type type, String host, int port, String username, String password) { this.type = type; this.host = host; |