X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FOrbotProxyHelper.java;h=8d0e408262fc8d993b3660466d3a1d1bd654c7e8;hb=f7ad9e2325cd19f0571e569ff160f2fffac5c5a5;hp=97b2f9d7c183446eae92bc470e72bd1a674d61bc;hpb=ae2ee09aa7a2afc19f5603c9bc021f98888d7b78;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java index 97b2f9d7..8d0e4082 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2016 Soren Stoutner . + * Copyright 2016-2017 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -39,6 +39,7 @@ import java.lang.reflect.Method; public class OrbotProxyHelper { public static void setProxy(Context privacyBrowserContext, Activity parentActivity, String proxyHost, String proxyPort) { + // Set the proxy values System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); @@ -82,6 +83,21 @@ public class OrbotProxyHelper { try { // Check to see if Orbot is installed. PackageManager packageManager = privacyBrowserContext.getPackageManager(); packageManager.getPackageInfo("org.torproject.android", PackageManager.GET_ACTIVITIES); + + // Ask Orbot to connect if its current status is not "ON". + if (!MainWebView.orbotStatus.equals("ON")) { + // Request Orbot to start. + Intent orbotIntent = new Intent("org.torproject.android.intent.action.START"); + + // Send the intent to the Orbot package. + orbotIntent.setPackage("org.torproject.android"); + + // Request a status response be sent back to this package. + orbotIntent.putExtra("org.torproject.android.intent.extra.PACKAGE_NAME", privacyBrowserContext.getPackageName()); + + // Make it so. + privacyBrowserContext.sendBroadcast(orbotIntent); + } } catch (PackageManager.NameNotFoundException exception){ // If an exception is thrown, Orbot is not installed. // Build an `AlertDialog`. `R.style.LightAlertDialog` formats the color of the button text. AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(parentActivity, R.style.LightAlertDialog); @@ -98,7 +114,7 @@ public class OrbotProxyHelper { alertDialog.show(); } } else { // Otherwise set the default grey `appBar` background. - MainWebView.appBar.setBackgroundDrawable(ContextCompat.getDrawable(privacyBrowserContext, R.color.grey_100)); + MainWebView.appBar.setBackgroundDrawable(ContextCompat.getDrawable(privacyBrowserContext, R.color.gray_100)); } } }