diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java index 94923caf..d99f96fa 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java @@ -262,7 +262,7 @@ public class AppSettings { } @SuppressLint("CommitPrefEdits") - public void setProxyEnabled(boolean enabled) { + public void setProxyHttpEnabled(boolean enabled) { //commit instead of apply because the app is likely to be killed before apply is called. prefApp.edit().putBoolean(context.getString(R.string.pref_key__http_proxy_enabled), enabled).commit(); } @@ -272,7 +272,7 @@ public class AppSettings { * * @return whether proxy is enabled or not */ - public boolean isProxyEnabled() { + public boolean isProxyHttpEnabled() { return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false); } @@ -281,7 +281,7 @@ public class AppSettings { * * @return proxy host */ - public String getProxyHost() { + public String getProxyHttpHost() { return getString(prefApp, R.string.pref_key__http_proxy_host, ""); } @@ -294,8 +294,14 @@ public class AppSettings { * * @return proxy port */ - public int getProxyPort() { - return getInt(prefApp, R.string.pref_key__http_proxy_port, 0); + public int getProxyHttpPort() { + try { + return getInt(prefApp, R.string.pref_key__http_proxy_port, 0); + } catch(Exception _anything){ + //TODO: Backward Compatibility for older versions. REMOVE after App v1.7.0 + setInt(prefApp, R.string.pref_key__http_proxy_port, 0); + return 0; + } } public void setProxyHttpPort(int value) { @@ -303,7 +309,7 @@ public class AppSettings { } public ProxyHandler.ProxySettings getProxySettings() { - return new ProxyHandler.ProxySettings(isProxyEnabled(), getProxyHost(), getProxyPort()); + return new ProxyHandler.ProxySettings(isProxyHttpEnabled(), getProxyHttpHost(), getProxyHttpPort()); } public boolean isIntellihideToolbars() { @@ -457,4 +463,4 @@ public class AppSettings { public void setExtendedNotifications(boolean b) { setBool(prefApp, R.string.pref_key__extended_notifications, b); } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/ProxyHandler.java b/app/src/main/java/com/github/dfa/diaspora_android/util/ProxyHandler.java index d3ab9711..160d36ad 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/ProxyHandler.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/ProxyHandler.java @@ -58,14 +58,14 @@ public class ProxyHandler { StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy(); StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(tmp); - if (appSettings.isProxyEnabled()) { + if (appSettings.isProxyHttpEnabled()) { //Update NetCipher - NetCipher.setProxy(appSettings.getProxyHost(), appSettings.getProxyPort()); + NetCipher.setProxy(appSettings.getProxyHttpHost(), appSettings.getProxyHttpPort()); //Update webviews for (WebView wv : webViews) { if (wv != null) { try { - WebkitProxy.setProxy(MainActivity.class.getName(), context.getApplicationContext(), wv, appSettings.getProxyHost(), appSettings.getProxyPort()); + WebkitProxy.setProxy(MainActivity.class.getName(), context.getApplicationContext(), wv, appSettings.getProxyHttpHost(), appSettings.getProxyHttpPort()); } catch (Exception e) { e.printStackTrace(); } @@ -89,10 +89,10 @@ public class ProxyHandler { StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy(); StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(tmp); - if (appSettings.isProxyEnabled()) { + if (appSettings.isProxyHttpEnabled()) { if (wv != null) { try { - WebkitProxy.setProxy(MainActivity.class.getName(), context.getApplicationContext(), wv, appSettings.getProxyHost(), appSettings.getProxyPort()); + WebkitProxy.setProxy(MainActivity.class.getName(), context.getApplicationContext(), wv, appSettings.getProxyHttpHost(), appSettings.getProxyHttpPort()); } catch (Exception e) { e.printStackTrace(); }