From 3e7c843d7b6886ba3d3a815d44a5e4ee7d6524d4 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Tue, 18 Oct 2016 21:15:54 +0200 Subject: [PATCH 1/2] Update gradle and fix proxy port bug --- .../com/github/dfa/diaspora_android/data/AppSettings.java | 7 +------ build.gradle | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) 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 6c50b176..e76071a0 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 @@ -271,12 +271,7 @@ public class AppSettings { * @return proxy port */ public int getProxyPort() { - try { - return Integer.parseInt(getString(prefApp, R.string.pref_key__http_proxy_port, "0")); - } catch (Exception e) { - setString(prefApp, R.string.pref_key__http_proxy_port, "0"); - return 0; - } + return getInt(prefApp, R.string.pref_key__http_proxy_port, 0); } public void setProxyHttpPort(int value) { diff --git a/build.gradle b/build.gradle index 54903cde..d4c9c424 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.android.tools.build:gradle:2.2.1' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong From 2f5aa1e0e7b31d4ae1f5f7e95e4e9a3cd219cb64 Mon Sep 17 00:00:00 2001 From: Gregor Santner Date: Sat, 22 Oct 2016 16:01:45 +0200 Subject: [PATCH 2/2] backward compatibility - proxy --- .../dfa/diaspora_android/data/AppSettings.java | 18 ++++++++++++------ .../diaspora_android/util/ProxyHandler.java | 10 +++++----- build.gradle | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) 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 e76071a0..ab9fbb73 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 @@ -223,7 +223,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(); } @@ -233,7 +233,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); } @@ -257,7 +257,7 @@ public class AppSettings { * * @return proxy host */ - public String getProxyHost() { + public String getProxyHttpHost() { return getString(prefApp, R.string.pref_key__http_proxy_host, ""); } @@ -270,8 +270,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) { @@ -279,7 +285,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() { 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(); } diff --git a/build.gradle b/build.gradle index d4c9c424..901b3834 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong