+ // Set the homepage, search, and proxy options.
+ if (proxyThroughOrbot) { // Set the Tor options.
+ // Set `torHomepageString` as `homepage`.
+ homepage = torHomepageString;
+
+ // If formattedUrlString is null assign the homepage to it.
+ if (formattedUrlString == null) {
+ formattedUrlString = homepage;
+ }
+
+ // Set JavaScript disabled search.
+ if (torJavaScriptDisabledSearchString.equals("Custom URL")) { // Get the custom URL string.
+ javaScriptDisabledSearchURL = torJavaScriptDisabledSearchCustomURLString;
+ } else { // Use the string from the pre-built list.
+ javaScriptDisabledSearchURL = torJavaScriptDisabledSearchString;
+ }
+
+ // Set JavaScript enabled search.
+ if (torJavaScriptEnabledSearchString.equals("Custom URL")) { // Get the custom URL string.
+ javaScriptEnabledSearchURL = torJavaScriptEnabledSearchCustomURLString;
+ } else { // Use the string from the pre-built list.
+ javaScriptEnabledSearchURL = torJavaScriptEnabledSearchString;
+ }
+
+ // Set the proxy. `this` refers to the current activity where an `AlertDialog` might be displayed.
+ OrbotProxyHelper.setProxy(getApplicationContext(), this, "localhost", "8118");
+
+ // Display a message to the user if we are waiting on Orbot.
+ if (!orbotStatus.equals("ON")) {
+ // Save `formattedUrlString` in `pendingUrl`.
+ pendingUrl = formattedUrlString;
+
+ // Load a waiting page. `null` specifies no encoding, which defaults to ASCII.
+ mainWebView.loadData(waitingForOrbotHTMLString, "text/html", null);
+ }
+ } else { // Set the non-Tor options.
+ // Set `homepageString` as `homepage`.
+ homepage = homepageString;
+
+ // If formattedUrlString is null assign the homepage to it.
+ if (formattedUrlString == null) {
+ formattedUrlString = homepage;
+ }
+
+ // Set JavaScript disabled search.
+ if (javaScriptDisabledSearchString.equals("Custom URL")) { // Get the custom URL string.
+ javaScriptDisabledSearchURL = javaScriptDisabledSearchCustomURLString;
+ } else { // Use the string from the pre-built list.
+ javaScriptDisabledSearchURL = javaScriptDisabledSearchString;
+ }
+
+ // Set JavaScript enabled search.
+ if (javaScriptEnabledSearchString.equals("Custom URL")) { // Get the custom URL string.
+ javaScriptEnabledSearchURL = javaScriptEnabledSearchCustomURLString;
+ } else { // Use the string from the pre-built list.
+ javaScriptEnabledSearchURL = javaScriptEnabledSearchString;
+ }
+
+ // Reset the proxy to default. The host is `""` and the port is `"0"`.
+ OrbotProxyHelper.setProxy(getApplicationContext(), this, "", "0");
+
+ // Reset `pendingUrl` if we are currently waiting for Orbot to connect.
+ if (!pendingUrl.isEmpty()) {
+ formattedUrlString = pendingUrl;
+ pendingUrl = "";
+ }
+ }
+
+ // Set swipe to refresh.