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 @@ @@ -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$/src/lightningPlus/res" 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/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/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/res" type="java-test-resource" />

2
app/build.gradle

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

Loading…
Cancel
Save