mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 12:22:08 +01:00
backward compatibility - proxy
This commit is contained in:
parent
3e7c843d7b
commit
2f5aa1e0e7
3 changed files with 18 additions and 12 deletions
|
@ -223,7 +223,7 @@ public class AppSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("CommitPrefEdits")
|
@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.
|
//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();
|
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
|
* @return whether proxy is enabled or not
|
||||||
*/
|
*/
|
||||||
public boolean isProxyEnabled() {
|
public boolean isProxyHttpEnabled() {
|
||||||
return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false);
|
return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ public class AppSettings {
|
||||||
*
|
*
|
||||||
* @return proxy host
|
* @return proxy host
|
||||||
*/
|
*/
|
||||||
public String getProxyHost() {
|
public String getProxyHttpHost() {
|
||||||
return getString(prefApp, R.string.pref_key__http_proxy_host, "");
|
return getString(prefApp, R.string.pref_key__http_proxy_host, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,8 +270,14 @@ public class AppSettings {
|
||||||
*
|
*
|
||||||
* @return proxy port
|
* @return proxy port
|
||||||
*/
|
*/
|
||||||
public int getProxyPort() {
|
public int getProxyHttpPort() {
|
||||||
return getInt(prefApp, R.string.pref_key__http_proxy_port, 0);
|
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) {
|
public void setProxyHttpPort(int value) {
|
||||||
|
@ -279,7 +285,7 @@ public class AppSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProxyHandler.ProxySettings getProxySettings() {
|
public ProxyHandler.ProxySettings getProxySettings() {
|
||||||
return new ProxyHandler.ProxySettings(isProxyEnabled(), getProxyHost(), getProxyPort());
|
return new ProxyHandler.ProxySettings(isProxyHttpEnabled(), getProxyHttpHost(), getProxyHttpPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIntellihideToolbars() {
|
public boolean isIntellihideToolbars() {
|
||||||
|
|
|
@ -58,14 +58,14 @@ public class ProxyHandler {
|
||||||
StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
|
StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
|
||||||
StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||||
StrictMode.setThreadPolicy(tmp);
|
StrictMode.setThreadPolicy(tmp);
|
||||||
if (appSettings.isProxyEnabled()) {
|
if (appSettings.isProxyHttpEnabled()) {
|
||||||
//Update NetCipher
|
//Update NetCipher
|
||||||
NetCipher.setProxy(appSettings.getProxyHost(), appSettings.getProxyPort());
|
NetCipher.setProxy(appSettings.getProxyHttpHost(), appSettings.getProxyHttpPort());
|
||||||
//Update webviews
|
//Update webviews
|
||||||
for (WebView wv : webViews) {
|
for (WebView wv : webViews) {
|
||||||
if (wv != null) {
|
if (wv != null) {
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -89,10 +89,10 @@ public class ProxyHandler {
|
||||||
StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
|
StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
|
||||||
StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||||
StrictMode.setThreadPolicy(tmp);
|
StrictMode.setThreadPolicy(tmp);
|
||||||
if (appSettings.isProxyEnabled()) {
|
if (appSettings.isProxyHttpEnabled()) {
|
||||||
if (wv != null) {
|
if (wv != null) {
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
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'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
Loading…
Reference in a new issue