From 8967fd944abecedcfa323e682cf08c084f0277b5 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 7 Feb 2022 21:49:36 +0100 Subject: Make sure that proxy host name does not get null And if it gets null, just ignore the setting. --- .../de/danoeh/antennapod/dialog/ProxyDialog.java | 42 +++++++++------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'app') 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() { -- cgit v1.2.3