Browse Source

Fixed errors with ProxyUtils

master
Anthony Restaino 10 years ago
parent
commit
aa21657875
  1. 4
      app/app.iml
  2. 2
      app/build.gradle
  3. 37
      app/src/LightningPlus/java/acr/browser/lightning/utils/ProxyUtils.java

4
app/app.iml

@ -52,9 +52,9 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/lightningPlus/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/lightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/aidl" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/res" type="java-test-resource" />

2
app/build.gradle

@ -51,4 +51,6 @@ dependencies {
// Only Lightning Plus needs the proxy libraries // Only Lightning Plus needs the proxy libraries
lightningPlusCompile 'net.i2p.android:client:0.7' lightningPlusCompile 'net.i2p.android:client:0.7'
lightningPlusCompile(project(':libnetcipher')) lightningPlusCompile(project(':libnetcipher'))
// git submodule foreach git reset --hard
// git submodule update --remote
} }

37
app/src/LightningPlus/java/acr/browser/lightning/utils/ProxyUtils.java

@ -3,6 +3,7 @@ package acr.browser.lightning.utils;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Build;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.Log; import android.util.Log;
@ -12,8 +13,8 @@ import acr.browser.lightning.R;
import acr.browser.lightning.activity.BrowserApp; import acr.browser.lightning.activity.BrowserApp;
import acr.browser.lightning.constant.Constants; import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
import info.guardianproject.onionkit.ui.OrbotHelper; import info.guardianproject.netcipher.proxy.OrbotHelper;
import info.guardianproject.onionkit.web.WebkitProxy; import info.guardianproject.netcipher.web.WebkitProxy;
/** /**
* 6/4/2015 Anthony Restaino * 6/4/2015 Anthony Restaino
@ -45,8 +46,7 @@ public class ProxyUtils {
public void checkForProxy(final Activity activity) { public void checkForProxy(final Activity activity) {
boolean useProxy = mPreferences.getUseProxy(); boolean useProxy = mPreferences.getUseProxy();
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext()); final boolean orbotInstalled = OrbotHelper.isOrbotInstalled(activity);
final boolean orbotInstalled = oh.isOrbotInstalled();
boolean orbotChecked = mPreferences.getCheckedForTor(); boolean orbotChecked = mPreferences.getCheckedForTor();
boolean orbot = orbotInstalled && !orbotChecked; boolean orbot = orbotInstalled && !orbotChecked;
@ -116,10 +116,8 @@ public class ProxyUtils {
return; return;
case Constants.PROXY_ORBOT: case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext()); if (!OrbotHelper.isOrbotRunning(activity))
if (!oh.isOrbotRunning()) { OrbotHelper.requestShowOrbotStart(activity);
oh.requestOrbotStart(activity);
}
host = "localhost"; host = "localhost";
port = 8118; port = 8118;
break; break;
@ -139,8 +137,7 @@ public class ProxyUtils {
} }
try { try {
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), null, host, port);
host, port);
} catch (Exception e) { } catch (Exception e) {
Log.d(Constants.TAG, "error enabling web proxying", e); Log.d(Constants.TAG, "error enabling web proxying", e);
} }
@ -165,11 +162,18 @@ public class ProxyUtils {
if (mPreferences.getUseProxy()) { if (mPreferences.getUseProxy()) {
initializeProxy(activity); initializeProxy(activity);
} else { } else {
try { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
WebkitProxy.resetProxy(BrowserApp.class.getName(), try {
activity.getApplicationContext()); WebkitProxy.resetProxy(BrowserApp.class.getName(), activity.getApplicationContext());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}
} else {
try {
WebkitProxy.resetLollipopProxy(BrowserApp.class.getName(), activity.getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
} }
mI2PProxyInitialized = false; mI2PProxyInitialized = false;
} }
@ -197,8 +201,7 @@ public class ProxyUtils {
public int setProxyChoice(int choice, Activity activity) { public int setProxyChoice(int choice, Activity activity) {
switch (choice) { switch (choice) {
case Constants.PROXY_ORBOT: case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext()); if (!OrbotHelper.isOrbotInstalled(activity)) {
if (!oh.isOrbotInstalled()) {
choice = Constants.NO_PROXY; choice = Constants.NO_PROXY;
Utils.showToast(activity, activity.getResources().getString(R.string.install_orbot)); Utils.showToast(activity, activity.getResources().getString(R.string.install_orbot));
} }

Loading…
Cancel
Save