Patches to Privacy Browser that were never accepted upstream due to my refusal of the CLA
Here are the commit IDs of the upstream re-implementations: | |
bead4e5c91f6d706559d923d9555a2b52c95b76d | |
59ce7ee862a672c569637f873af95e13b619906f | |
826776d415157b99701dd19d2713a60db6fefe2c | |
b36f8bd357e28072bd7c810bb3ae47e4e0b20acc |
From d16c617c10d4013b4ffc5ccdb2b3e7034f586e85 Mon Sep 17 00:00:00 2001 | |
From: Tad <tad@spotco.us> | |
Date: Sun, 28 Aug 2016 22:46:49 -0400 | |
Subject: [PATCH] Add two new search engines | |
--- | |
app/src/main/res/values-de/strings.xml | 4 ++++ | |
app/src/main/res/values/strings.xml | 8 ++++++++ | |
2 files changed, 12 insertions(+) | |
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml | |
index 4ee7ccd..9ada3af 100644 | |
--- a/app/src/main/res/values-de/strings.xml | |
+++ b/app/src/main/res/values-de/strings.xml | |
@@ -151,18 +151,22 @@ | |
<string name="javascript_disabled_search">Suchmaschine bei deaktiviertem JavaScript</string> | |
<string-array name="javascript_disabled_search_entries"> | |
<item>DuckDuckGo</item> | |
+ <item>StartPage</item> | |
<item>Google</item> | |
<item>Bing</item> | |
<item>Yahoo</item> | |
+ <item>Qwant</item> | |
<item>Eigene</item> | |
</string-array> | |
<string name="javascript_disabled_search_custom_url">Suchmaschinen-URL bei deaktiviertem JavaScript</string> | |
<string name="javascript_enabled_search">Suchmaschine bei aktiviertem JavaScript</string> | |
<string-array name="javascript_enabled_search_entries"> | |
<item>DuckDuckGo</item> | |
+ <item>StartPage</item> | |
<item>Google</item> | |
<item>Bing</item> | |
<item>Yahoo</item> | |
+ <item>Qwant</item> | |
<item>Eigene</item> | |
</string-array> | |
<string name="javascript_enabled_search_custom_url">Suchmaschinen-URL bei aktivertem JavaScript</string> | |
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml | |
index 32c7bb3..15f656c 100644 | |
--- a/app/src/main/res/values/strings.xml | |
+++ b/app/src/main/res/values/strings.xml | |
@@ -199,32 +199,40 @@ | |
<string name="javascript_disabled_search">JavaScript-disabled search</string> | |
<string-array name="javascript_disabled_search_entries"> | |
<item>DuckDuckGo</item> | |
+ <item>StartPage</item> | |
<item>Google</item> | |
<item>Bing</item> | |
<item>Yahoo</item> | |
+ <item>Qwant</item> | |
<item>Custom</item> | |
</string-array> | |
<string-array name="javascript_disabled_search_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. --> | |
<item>https://duckduckgo.com/html/?q=</item> | |
+ <item>https://startpage.com/do/search?query=</item> | |
<item>https://www.google.com/search?q=</item> | |
<item>https://www.bing.com/search?q=</item> | |
<item>https://search.yahoo.com/mobile/s?nojs=1&p=</item> | |
+ <item>https://lite.qwant.com/?t=web&q=</item> | |
<item>Custom URL</item> <!-- This item must not be translated into other languages because it is referenced in code. It is never displayed on the screen. --> | |
</string-array> | |
<string name="javascript_disabled_search_custom_url">JavaScript-disabled search custom URL</string> | |
<string name="javascript_enabled_search">JavaScript-enabled search</string> | |
<string-array name="javascript_enabled_search_entries"> | |
<item>DuckDuckGo</item> | |
+ <item>StartPage</item> | |
<item>Google</item> | |
<item>Bing</item> | |
<item>Yahoo</item> | |
+ <item>Qwant</item> | |
<item>Custom</item> | |
</string-array> | |
<string-array name="javascript_enabled_search_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. --> | |
<item>https://duckduckgo.com/?q=</item> | |
+ <item>https://startpage.com/do/search?query=</item> | |
<item>https://www.google.com/search?q=</item> | |
<item>https://www.bing.com/search?q=</item> | |
<item>https://search.yahoo.com/mobile/s?p=</item> | |
+ <item>https://www.qwant.com/?t=web&q=</item> | |
<item>Custom URL</item> <!-- This item must not be translated into other languages because it is referenced in code. It is never displayed on the screen. --> | |
</string-array> | |
<string name="javascript_enabled_search_custom_url">JavaScript-enabled search custom URL</string> | |
-- | |
2.9.3 | |
From 1c8449fa94530b8ec16cde3cc6ff106096a9f709 Mon Sep 17 00:00:00 2001 | |
From: Tad <tad@spotco.us> | |
Date: Sun, 28 Aug 2016 22:53:13 -0400 | |
Subject: [PATCH] Add two user agents | |
--- | |
app/src/main/res/values-de/strings.xml | 2 ++ | |
app/src/main/res/values/strings.xml | 4 ++++ | |
2 files changed, 6 insertions(+) | |
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml | |
index 9ada3af..3c8688a 100644 | |
--- a/app/src/main/res/values-de/strings.xml | |
+++ b/app/src/main/res/values-de/strings.xml | |
@@ -137,6 +137,7 @@ | |
<item>Privacy Browser 1.0</item> | |
<item>Firefox 46 auf Android 6.0.1</item> | |
<item>Chrome 50 auf Android 6.0.1</item> | |
+ <item>Safari auf iOS 9.2</item> | |
<item>Firefox 46 auf Linux</item> | |
<item>Chromium 50 auf Linux</item> | |
<item>Konqueror 4.14 auf Linux</item> | |
@@ -144,6 +145,7 @@ | |
<item>Chrome 50 auf Windows 10</item> | |
<item>Internet Explorer 11 auf Windows 10</item> | |
<item>Edge 13 auf Windows 10</item> | |
+ <item>Safari auf Mac OS 10.11</item> | |
<item>Eigener</item> | |
</string-array> | |
<string name="custom_user_agent">Eigener User Agent</string> | |
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml | |
index 15f656c..bb9e981 100644 | |
--- a/app/src/main/res/values/strings.xml | |
+++ b/app/src/main/res/values/strings.xml | |
@@ -171,6 +171,7 @@ | |
<item>Privacy Browser 1.0</item> | |
<item>Firefox 46 on Android 6.0.1</item> | |
<item>Chrome 50 on Android 6.0.1</item> | |
+ <item>Safari on iOS 9.2</item> | |
<item>Firefox 46 on Linux</item> | |
<item>Chromium 50 on Linux</item> | |
<item>Konqueror 4.14 on Linux</item> | |
@@ -178,6 +179,7 @@ | |
<item>Chrome 50 on Windows 10</item> | |
<item>Internet Explorer 11 on Windows 10</item> | |
<item>Edge 13 on Windows 10</item> | |
+ <item>Safari on Mac OS 10.11</item> | |
<item>Custom</item> | |
</string-array> | |
<string-array name="user_agent_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. --> | |
@@ -185,6 +187,7 @@ | |
<item>PrivacyBrowser/1.0</item> | |
<item>Mozilla/5.0 (Android 6.0.1; Mobile; rv:46.0) Gecko/46.0 Firefox/46.0</item> | |
<item>Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MHC19Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.89 Mobile Safari/537.36</item> | |
+ <item>Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13C75 Safari/601.1</item> | |
<item>Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0</item> | |
<item>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36</item> | |
<item>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.21 (KHTML, like Gecko) konqueror/4.14.14 Safari/537.21</item> | |
@@ -192,6 +195,7 @@ | |
<item>Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36</item> | |
<item>Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko</item> | |
<item>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586</item> | |
+ <item>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.32 (KHTML, like Gecko) Version/8.1 Safari/601.1.32</item> | |
<item>Custom user agent</item> <!-- This item must not be translated into other languages because it is referenced in code. It is never displayed on the screen. --> | |
</string-array> | |
<string name="custom_user_agent">Custom user agent</string> | |
-- | |
2.9.3 | |
From 32b62f30c7c7b9a6d62184cbae8c1f9a7722def5 Mon Sep 17 00:00:00 2001 | |
From: Tad <tad@spotco.us> | |
Date: Sun, 28 Aug 2016 23:21:41 -0400 | |
Subject: [PATCH] Add do not track option | |
--- | |
.../java/com/stoutner/privacybrowser/MainWebViewActivity.java | 7 +++++++ | |
.../main/java/com/stoutner/privacybrowser/SettingsFragment.java | 9 +++++++++ | |
app/src/main/res/values/strings.xml | 2 ++ | |
app/src/main/res/xml/preferences.xml | 6 ++++++ | |
4 files changed, 24 insertions(+) | |
diff --git a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java | |
index 0a824a1..328c21f 100644 | |
--- a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java | |
+++ b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java | |
@@ -107,6 +107,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
// `saveFormDataEnabled` is public static so it can be accessed from `SettingsFragment`. It is also used in `onCreate()`, `onCreateOptionsMenu()`, and `onOptionsItemSelected()`. | |
public static boolean saveFormDataEnabled; | |
+ // 'doNotTrackEnabled' is public static so it can be accessed from `SettingsFragment`. It is also used in `onCreate()`. | |
+ public static boolean doNotTrackEnabled; | |
+ | |
// `javaScriptDisabledSearchURL` is public static so it can be accessed from `SettingsFragment`. It is also used in `onCreate()` and `loadURLFromTextBox()`. | |
public static String javaScriptDisabledSearchURL; | |
@@ -394,6 +397,10 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
saveFormDataEnabled = savedPreferences.getBoolean("save_form_data_enabled", false); | |
mainWebView.getSettings().setSaveFormData(saveFormDataEnabled); | |
+ // Set the do not track initial status. The default is false. | |
+ doNotTrackEnabled = savedPreferences.getBoolean("do_not_track_enabled", false); | |
+ customHeaders.put("DNT", (doNotTrackEnabled) ? "1" : "0"); | |
+ | |
// Set the user agent initial status. | |
String userAgentString = savedPreferences.getString("user_agent", "Default user agent"); | |
switch (userAgentString) { | |
diff --git a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java | |
index 3846342..25368b1 100644 | |
--- a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java | |
+++ b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java | |
@@ -207,6 +207,15 @@ public class SettingsFragment extends PreferenceFragment { | |
MainWebViewActivity.mainWebView.reload(); | |
break; | |
+ case "do_not_track_enabled": | |
+ // Set doNotTrackEnabled to the new state. The default is false. | |
+ MainWebViewActivity.doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track_enabled", false); | |
+ | |
+ // Update mainWebView and reload the website. | |
+ MainWebViewActivity.customHeaders.put("DNT", (MainWebViewActivity.doNotTrackEnabled) ? "1" : "0"); | |
+ MainWebViewActivity.mainWebView.reload(); | |
+ break; | |
+ | |
case "user_agent": | |
String userAgentString = sharedPreferences.getString("user_agent", "Default user agent"); | |
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml | |
index bb9e981..c8bf9f6 100644 | |
--- a/app/src/main/res/values/strings.xml | |
+++ b/app/src/main/res/values/strings.xml | |
@@ -165,6 +165,8 @@ | |
<string name="dom_storage_preference_summary">JavaScript must be enabled for DOM storage to function.</string> | |
<string name="save_form_data_preference">Enable saving of form data by default</string> | |
<string name="save_form_data_preference_summary">Saved form data can auto-populate fields on websites.</string> | |
+ <string name="do_not_track_preference">Do not track</string> | |
+ <string name="do_not_track_preference_summary">Used to opt out of web tracking. Few scripts obey it. Potentially makes fingerprinting easier.</string> | |
<string name="user_agent">User agent</string> | |
<string-array name="user_agent_entries"> | |
<item>WebView Default</item> | |
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml | |
index e9c6405..313747b 100644 | |
--- a/app/src/main/res/xml/preferences.xml | |
+++ b/app/src/main/res/xml/preferences.xml | |
@@ -53,6 +53,12 @@ | |
android:summary="@string/save_form_data_preference_summary" | |
android:defaultValue="false" /> | |
+ <SwitchPreference | |
+ android:key="do_not_track_enabled" | |
+ android:title="@string/do_not_track_preference" | |
+ android:summary="@string/do_not_track_preference_summary" | |
+ android:defaultValue="false" /> | |
+ | |
<ListPreference | |
android:key="user_agent" | |
android:title="@string/user_agent" | |
-- | |
2.9.3 | |
From 49f000e6efb423cb07c0d5d5cb7bb914d295dab0 Mon Sep 17 00:00:00 2001 | |
From: Tad <tad@spotco.us> | |
Date: Mon, 29 Aug 2016 00:57:50 -0400 | |
Subject: [PATCH] Implement Tor support | |
--- | |
app/build.gradle | 1 + | |
app/proguard-rules.pro | 2 + | |
.../privacybrowser/MainWebViewActivity.java | 17 ++++ | |
.../stoutner/privacybrowser/SettingsFragment.java | 13 +++ | |
.../com/stoutner/privacybrowser/TorHelper.java | 95 ++++++++++++++++++++++ | |
app/src/main/res/menu/webview_options_menu.xml | 7 ++ | |
app/src/main/res/values/strings.xml | 9 ++ | |
app/src/main/res/xml/preferences.xml | 6 ++ | |
8 files changed, 150 insertions(+) | |
create mode 100644 app/src/main/java/com/stoutner/privacybrowser/TorHelper.java | |
diff --git a/app/build.gradle b/app/build.gradle | |
index c72546d..6753f03 100644 | |
--- a/app/build.gradle | |
+++ b/app/build.gradle | |
@@ -53,6 +53,7 @@ android { | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
+ compile 'info.guardianproject.netcipher:netcipher:1.2.1' | |
compile 'com.android.support:design:23.4.0' | |
// Only compile `com.google.android.gms:play-services-ads` for the free flavor. | |
freeCompile 'com.google.android.gms:play-services-ads:9.4.0' | |
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro | |
index 189b580..b4d9a6f 100644 | |
--- a/app/proguard-rules.pro | |
+++ b/app/proguard-rules.pro | |
@@ -15,3 +15,5 @@ | |
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | |
# public *; | |
#} | |
+ | |
+-dontwarn info.guardianproject.netcipher.client.** | |
diff --git a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java | |
index 328c21f..b29659b 100644 | |
--- a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java | |
+++ b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java | |
@@ -110,6 +110,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
// 'doNotTrackEnabled' is public static so it can be accessed from `SettingsFragment`. It is also used in `onCreate()`. | |
public static boolean doNotTrackEnabled; | |
+ // 'torEnabled' | |
+ public static boolean torEnabled; | |
+ | |
// `javaScriptDisabledSearchURL` is public static so it can be accessed from `SettingsFragment`. It is also used in `onCreate()` and `loadURLFromTextBox()`. | |
public static String javaScriptDisabledSearchURL; | |
@@ -401,6 +404,10 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
doNotTrackEnabled = savedPreferences.getBoolean("do_not_track_enabled", false); | |
customHeaders.put("DNT", (doNotTrackEnabled) ? "1" : "0"); | |
+ // Set the Tor initial status. The default is false. | |
+ torEnabled = savedPreferences.getBoolean("tor_enabled", false); | |
+ TorHelper.setTor(getApplicationContext()); | |
+ | |
// Set the user agent initial status. | |
String userAgentString = savedPreferences.getString("user_agent", "Default user agent"); | |
switch (userAgentString) { | |
@@ -523,12 +530,14 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
MenuItem toggleThirdPartyCookies = menu.findItem(R.id.toggleThirdPartyCookies); | |
MenuItem toggleDomStorage = menu.findItem(R.id.toggleDomStorage); | |
MenuItem toggleSaveFormData = menu.findItem(R.id.toggleSaveFormData); | |
+ MenuItem toggleTor = menu.findItem(R.id.toggleTor); | |
// Set the initial status of the menu item checkboxes. | |
toggleFirstPartyCookies.setChecked(firstPartyCookiesEnabled); | |
toggleThirdPartyCookies.setChecked(thirdPartyCookiesEnabled); | |
toggleDomStorage.setChecked(domStorageEnabled); | |
toggleSaveFormData.setChecked(saveFormDataEnabled); | |
+ toggleTor.setChecked(torEnabled); | |
return true; | |
} | |
@@ -785,6 +794,13 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
mainWebView.reload(); | |
return true; | |
+ case R.id.toggleTor: | |
+ torEnabled = !torEnabled; | |
+ menuItem.setChecked(torEnabled); | |
+ TorHelper.setTor(getApplicationContext()); | |
+ mainWebView.reload(); | |
+ return true; | |
+ | |
default: | |
// Don't consume the event. | |
return super.onOptionsItemSelected(menuItem); | |
@@ -1051,4 +1067,5 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation | |
} | |
} | |
} | |
+ | |
} | |
diff --git a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java | |
index 25368b1..da8c4af 100644 | |
--- a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java | |
+++ b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java | |
@@ -216,6 +216,19 @@ public class SettingsFragment extends PreferenceFragment { | |
MainWebViewActivity.mainWebView.reload(); | |
break; | |
+ case "tor_enabled": | |
+ // Set doNotTrackEnabled to the new state. The default is false. | |
+ MainWebViewActivity.torEnabled = sharedPreferences.getBoolean("tor_enabled", false); | |
+ | |
+ // Update the checkbox in the options menu. | |
+ MenuItem toggleTorMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleTor); | |
+ toggleTorMenuItem.setChecked(MainWebViewActivity.torEnabled); | |
+ | |
+ // Update mainWebView and reload the website. | |
+ TorHelper.setTor(getActivity()); | |
+ MainWebViewActivity.mainWebView.reload(); | |
+ break; | |
+ | |
case "user_agent": | |
String userAgentString = sharedPreferences.getString("user_agent", "Default user agent"); | |
diff --git a/app/src/main/java/com/stoutner/privacybrowser/TorHelper.java b/app/src/main/java/com/stoutner/privacybrowser/TorHelper.java | |
new file mode 100644 | |
index 0000000..30dd0d1 | |
--- /dev/null | |
+++ b/app/src/main/java/com/stoutner/privacybrowser/TorHelper.java | |
@@ -0,0 +1,95 @@ | |
+/** | |
+ * Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>. | |
+ * | |
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>. | |
+ * | |
+ * Privacy Browser is free software: you can redistribute it and/or modify | |
+ * it under the terms of the GNU General Public License as published by | |
+ * the Free Software Foundation, either version 3 of the License, or | |
+ * (at your option) any later version. | |
+ * | |
+ * Privacy Browser is distributed in the hope that it will be useful, | |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+ * GNU General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU General Public License | |
+ * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>. | |
+ */ | |
+ | |
+package com.stoutner.privacybrowser; | |
+ | |
+import android.app.AlertDialog; | |
+import android.content.Context; | |
+import android.content.DialogInterface; | |
+import android.content.SharedPreferences; | |
+import android.preference.PreferenceManager; | |
+import android.view.MenuItem; | |
+ | |
+import info.guardianproject.netcipher.proxy.OrbotHelper; | |
+import info.guardianproject.netcipher.web.WebkitProxy; | |
+ | |
+public class TorHelper { | |
+ | |
+ public static void setTor(Context context) { | |
+ if(MainWebViewActivity.torEnabled) { | |
+ if(checkTorInstalled(context)) { | |
+ if(!OrbotHelper.isOrbotRunning(context)) { | |
+ OrbotHelper.requestStartTor(context); | |
+ } | |
+ try { | |
+ WebkitProxy.setProxy(MainWebViewActivity.class.getCanonicalName(), context.getApplicationContext(), MainWebViewActivity.mainWebView, "127.0.0.1", 8118); | |
+ } catch(Exception e) { | |
+ disableTor(context); | |
+ e.printStackTrace(); | |
+ } | |
+ } else { | |
+ disableTor(context); | |
+ } | |
+ } else { | |
+ try { | |
+ WebkitProxy.setProxy(MainWebViewActivity.class.getCanonicalName(), context.getApplicationContext(), MainWebViewActivity.mainWebView, "", 0); | |
+ WebkitProxy.resetProxy(MainWebViewActivity.class.getCanonicalName(), context.getApplicationContext()); | |
+ } catch(Exception e) { | |
+ disableTor(context); | |
+ e.printStackTrace(); | |
+ } | |
+ } | |
+ } | |
+ | |
+ private static boolean checkTorInstalled(final Context context) { | |
+ if(OrbotHelper.isOrbotInstalled(context)) { | |
+ return true; | |
+ } else { | |
+ AlertDialog.Builder notInstalled = new AlertDialog.Builder(context); | |
+ notInstalled.setMessage(R.string.tor_preference_orbot_missing); | |
+ notInstalled.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { | |
+ @Override | |
+ public void onClick(DialogInterface dialog, int id) { | |
+ context.startActivity(OrbotHelper.getOrbotInstallIntent(context)); | |
+ dialog.dismiss(); | |
+ } | |
+ }); | |
+ notInstalled.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() { | |
+ @Override | |
+ public void onClick(DialogInterface dialog, int id) { | |
+ dialog.cancel(); | |
+ } | |
+ }); | |
+ AlertDialog notInstalledAlert = notInstalled.create(); | |
+ notInstalledAlert.show(); | |
+ return false; | |
+ } | |
+ } | |
+ | |
+ private static void disableTor(Context context) { | |
+ MainWebViewActivity.torEnabled = false; | |
+ final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); | |
+ SharedPreferences.Editor editor = sharedPreferences.edit(); | |
+ editor.putBoolean("tor_enabled", false); | |
+ editor.commit(); | |
+ MenuItem toggleTorMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleTor); | |
+ toggleTorMenuItem.setChecked(MainWebViewActivity.torEnabled); | |
+ } | |
+ | |
+} | |
diff --git a/app/src/main/res/menu/webview_options_menu.xml b/app/src/main/res/menu/webview_options_menu.xml | |
index 202437d..c212ae3 100644 | |
--- a/app/src/main/res/menu/webview_options_menu.xml | |
+++ b/app/src/main/res/menu/webview_options_menu.xml | |
@@ -146,4 +146,11 @@ | |
android:title="@string/refresh" | |
android:orderInCategory="120" | |
app:showAsAction="never" /> | |
+ | |
+ <item | |
+ android:id="@+id/toggleTor" | |
+ android:title="@string/toggleTor" | |
+ android:orderInCategory="130" | |
+ android:checkable="true" | |
+ app:showAsAction="never" /> | |
</menu> | |
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml | |
index c8bf9f6..4006418 100644 | |
--- a/app/src/main/res/values/strings.xml | |
+++ b/app/src/main/res/values/strings.xml | |
@@ -102,6 +102,7 @@ | |
<string name="share">Share</string> | |
<string name="add_to_home_screen">Add to Home Screen</string> | |
<string name="refresh">Refresh</string> | |
+ <string name="toggleTor">Use Tor</string> | |
<!-- Create Home Screen Shortcut Alert Dialog. --> | |
<string name="create_shortcut">Create shortcut</string> | |
@@ -145,6 +146,11 @@ | |
<string name="bookmarks_database_view">Bookmarks Database View</string> | |
<string name="home_folder">Home Folder</string> | |
+ <!-- Dialogs. --> | |
+ <string name="dialog_yes">Yes</string> | |
+ <string name="dialog_no">No</string> | |
+ <string name="dialog_ok">Ok</string> | |
+ | |
<!-- Guide. --> | |
<string name="privacy_browser_guide">Privacy Browser Guide</string> | |
<string name="overview">Overview</string> | |
@@ -167,6 +173,9 @@ | |
<string name="save_form_data_preference_summary">Saved form data can auto-populate fields on websites.</string> | |
<string name="do_not_track_preference">Do not track</string> | |
<string name="do_not_track_preference_summary">Used to opt out of web tracking. Few scripts obey it. Potentially makes fingerprinting easier.</string> | |
+ <string name="tor_preference">Use Tor by default</string> | |
+ <string name="tor_preference_summary" >Routes all traffic through Tor using Orbot for enhanced privacy/anonymity.</string> | |
+ <string name="tor_preference_orbot_missing" >Orbot doesn\'t seem to be installed. Install now?</string> | |
<string name="user_agent">User agent</string> | |
<string-array name="user_agent_entries"> | |
<item>WebView Default</item> | |
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml | |
index 313747b..ab732ba 100644 | |
--- a/app/src/main/res/xml/preferences.xml | |
+++ b/app/src/main/res/xml/preferences.xml | |
@@ -59,6 +59,12 @@ | |
android:summary="@string/do_not_track_preference_summary" | |
android:defaultValue="false" /> | |
+ <SwitchPreference | |
+ android:key="tor_enabled" | |
+ android:title="@string/tor_preference" | |
+ android:summary="@string/tor_preference_summary" | |
+ android:defaultValue="false" /> | |
+ | |
<ListPreference | |
android:key="user_agent" | |
android:title="@string/user_agent" | |
-- | |
2.9.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment