/**
- * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
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);
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")) {
+ Intent orbotIntent = new Intent("org.torproject.android.intent.action.START");
+ orbotIntent.setPackage("org.torproject.android");
+ 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);