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 /app | |
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 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java | 42 |
1 files changed, 17 insertions, 25 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 ad2ed3499..2c3c44b1d 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -148,32 +148,24 @@ public class ProxyDialog { } private void setProxyConfig() { - String type = (String) spType.getSelectedItem(); - ProxyConfig proxy; - if (Proxy.Type.valueOf(type) == Proxy.Type.DIRECT) { - proxy = ProxyConfig.direct(); - } else { - String host = etHost.getText().toString(); - String port = etPort.getText().toString(); - String username = etUsername.getText().toString(); - if (TextUtils.isEmpty(username)) { - username = null; - } - String password = etPassword.getText().toString(); - if (TextUtils.isEmpty(password)) { - password = null; - } - int portValue = 0; - if (!TextUtils.isEmpty(port)) { - portValue = Integer.parseInt(port); - } - if (Proxy.Type.valueOf(type) == Proxy.Type.SOCKS) { - proxy = ProxyConfig.socks(host, portValue, username, password); - } else { - proxy = ProxyConfig.http(host, portValue, username, password); - } + final String type = (String) spType.getSelectedItem(); + final Proxy.Type typeEnum = Proxy.Type.valueOf(type); + final String host = etHost.getText().toString(); + final String port = etPort.getText().toString(); + + String username = etUsername.getText().toString(); + if (TextUtils.isEmpty(username)) { + username = null; + } + String password = etPassword.getText().toString(); + if (TextUtils.isEmpty(password)) { + password = null; + } + int portValue = 0; + if (!TextUtils.isEmpty(port)) { + portValue = Integer.parseInt(port); } - UserPreferences.setProxyConfig(proxy); + UserPreferences.setProxyConfig(new ProxyConfig(typeEnum, host, portValue, username, password)); } private final TextWatcher requireTestOnChange = new TextWatcher() { |