From dbe9e3b03b125ee631665d0395e235414370d40e Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 8 May 2018 14:31:10 -0700 Subject: [PATCH] Request Orbot to connect on every restart. https://redmine.stoutner.com/issues/262 --- .../free/assets/de/about_permissions_dark.html | 6 +++--- .../free/assets/de/about_permissions_light.html | 6 +++--- .../main/assets/de/about_permissions_dark.html | 6 +++--- .../main/assets/de/about_permissions_light.html | 6 +++--- .../activities/MainWebViewActivity.java | 17 ++++++++++++++++- .../helpers/OrbotProxyHelper.java | 13 +++++++++---- app/src/main/res/values-de/strings.xml | 6 ++++++ app/src/main/res/values-es/strings.xml | 3 ++- app/src/main/res/values-ru/strings.xml | 3 ++- 9 files changed, 47 insertions(+), 19 deletions(-) diff --git a/app/src/free/assets/de/about_permissions_dark.html b/app/src/free/assets/de/about_permissions_dark.html index 32b9700e..e71e703d 100644 --- a/app/src/free/assets/de/about_permissions_dark.html +++ b/app/src/free/assets/de/about_permissions_dark.html @@ -34,10 +34,10 @@

com.android.launcher.permission.INSTALL_SHORTCUT

Benötigt, um Verknüpfungen zu Websites auf Ihrer Startseite zu erstellen.

-

Write storage

+

Schreibrechte im Dateisystem

android.permission.WRITE_EXTERNAL_STORAGE

-

Required to download files to the public download folder. - On Android Marshmallow (API 23) and newer, if this permission is denied Privacy Browser will store downloads in the app’s download folder instead.

+

Benötigt, um Dateien im öffentlichen Download-Ordner abzuspeichern. + In Android Marshmallow (API 23) und neuer werden Downloads im Downdload-Ordner der App gespeichert, falls die Berechtigung verweigert wurde.



diff --git a/app/src/free/assets/de/about_permissions_light.html b/app/src/free/assets/de/about_permissions_light.html index 43bb65f4..6f41a377 100644 --- a/app/src/free/assets/de/about_permissions_light.html +++ b/app/src/free/assets/de/about_permissions_light.html @@ -34,10 +34,10 @@

com.android.launcher.permission.INSTALL_SHORTCUT

Benötigt, um Verknüpfungen zu Websites auf Ihrer Startseite zu erstellen.

-

Write storage

+

Schreibrechte im Dateisystem

android.permission.WRITE_EXTERNAL_STORAGE

-

Required to download files to the public download folder. - On Android Marshmallow (API 23) and newer, if this permission is denied Privacy Browser will store downloads in the app’s download folder instead.

+

Benötigt, um Dateien im öffentlichen Download-Ordner abzuspeichern. + In Android Marshmallow (API 23) und neuer werden Downloads im Downdload-Ordner der App gespeichert, falls die Berechtigung verweigert wurde.



diff --git a/app/src/main/assets/de/about_permissions_dark.html b/app/src/main/assets/de/about_permissions_dark.html index b8e3173b..27eb4e0a 100644 --- a/app/src/main/assets/de/about_permissions_dark.html +++ b/app/src/main/assets/de/about_permissions_dark.html @@ -34,9 +34,9 @@

com.android.launcher.permission.INSTALL_SHORTCUT

Benötigt, um Verknüpfungen zu Websites auf Ihrer Startseite zu erstellen.

-

Write storage

+

Schreibrechte im Dateisystem

android.permission.WRITE_EXTERNAL_STORAGE

-

Required to download files to the public download folder. - On Android Marshmallow (API 23) and newer, if this permission is denied Privacy Browser will store downloads in the app’s download folder instead.

+

Benötigt, um Dateien im öffentlichen Download-Ordner abzuspeichern. + In Android Marshmallow (API 23) und neuer werden Downloads im Downdload-Ordner der App gespeichert, falls die Berechtigung verweigert wurde.

\ No newline at end of file diff --git a/app/src/main/assets/de/about_permissions_light.html b/app/src/main/assets/de/about_permissions_light.html index 0ff9f7b8..54863f0d 100644 --- a/app/src/main/assets/de/about_permissions_light.html +++ b/app/src/main/assets/de/about_permissions_light.html @@ -34,9 +34,9 @@

com.android.launcher.permission.INSTALL_SHORTCUT

Benötigt, um Verknüpfungen zu Websites auf Ihrer Startseite zu erstellen.

-

Write storage

+

Schreibrechte im Dateisystem

android.permission.WRITE_EXTERNAL_STORAGE

-

Required to download files to the public download folder. - On Android Marshmallow (API 23) and newer, if this permission is denied Privacy Browser will store downloads in the app’s download folder instead.

+

Benötigt, um Dateien im öffentlichen Download-Ordner abzuspeichern. + In Android Marshmallow (API 23) und neuer werden Downloads im Downdload-Ordner der App gespeichert, falls die Berechtigung verweigert wurde.

\ No newline at end of file diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 0e81bf4f..bb525e7a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -289,6 +289,9 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD // `privacyBrowserRuntime` is used in `onCreate()`, `onOptionsItemSelected()`, and `applyAppSettings()`. private Runtime privacyBrowserRuntime; + // `proxyThroughOrbot` is used in `onRestart()` and `applyAppSettings()`. + boolean proxyThroughOrbot; + // `incognitoModeEnabled` is used in `onCreate()` and `applyAppSettings()`. private boolean incognitoModeEnabled; @@ -1429,6 +1432,18 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD // Run the default commands. super.onRestart(); + // Make sure Orbot is running if Privacy Browser is proxying through Orbot. + if (proxyThroughOrbot) { + // Request Orbot to start. If Orbot is already running no hard will be caused by this request. + Intent orbotIntent = new Intent("org.torproject.android.intent.action.START"); + + // Send the intent to the Orbot package. + orbotIntent.setPackage("org.torproject.android"); + + // Make it so. + sendBroadcast(orbotIntent); + } + // Apply the app settings if returning from the Settings activity.. if (reapplyAppSettingsOnRestart) { // Apply the app settings. @@ -3050,7 +3065,7 @@ public class MainWebViewActivity extends AppCompatActivity implements AddDomainD String searchCustomURLString = sharedPreferences.getString("search_custom_url", ""); incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false); boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false); - boolean proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false); + proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false); fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("full_screen_browsing_mode", false); hideSystemBarsOnFullscreen = sharedPreferences.getBoolean("hide_system_bars", false); translucentNavigationBarOnFullscreen = sharedPreferences.getBoolean("translucent_navigation_bar", true); 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 6253bc1c..b56269b1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java @@ -49,21 +49,26 @@ public class OrbotProxyHelper { // Use reflection to apply the new proxy values. try { Class applicationClass = Class.forName("android.app.Application"); - Field mLoadedApkField = applicationClass.getDeclaredField("mLoadedApk"); - // `setAccessible(true)` allows us to change the value of `mLoadedApkField`. + + // Suppress the lint warning that `mLoadedApk` cannot be resolved. + @SuppressWarnings("JavaReflectionMemberAccess") Field mLoadedApkField = applicationClass.getDeclaredField("mLoadedApk"); + + // `setAccessible(true)` allows the value of `mLoadedApkField` to be changed.. mLoadedApkField.setAccessible(true); Object mLoadedApkObject = mLoadedApkField.get(privacyBrowserContext); + // Suppress the lint warning that reflection may not alwasy work in the future and on all devices. @SuppressLint("PrivateApi") Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers"); - // `setAccessible(true)` allows us to change the value of `mReceiversField`. + + // `setAccessible(true)` allows the value of `mReceiversField` to be changed. mReceiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) mReceiversField.get(mLoadedApkObject); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { - // We have to use `Class`, which is an `unbounded wildcard parameterized type`, instead of `Class`, which is a `raw type`. + // `Class`, which is an `unbounded wildcard parameterized type`, must be used instead of `Class`, which is a `raw type`. // Otherwise, `receiveClass.getDeclaredMethod` below will produce an error. Class receiverClass = receiver.getClass(); if (receiverClass.getName().contains("ProxyChangeListener")) { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index e72b0d55..92b08327 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -47,6 +47,7 @@ Navigationspanel öffnen Navigationspanel schließen Kein Titel + Unbekannte URL: Speichern Unter @@ -333,6 +334,11 @@ Weitere Icons in der Titelleiste Icons zum Umschalten von Cookies, DOM-Speicher und Formulardaten neben der Adresszeile anzeigen, wenn noch Platz dafür da ist. + + Download-Zielordner + Privacy Browser benötigt die Berechtigung zur Speicherung im öffentlichen Download-Ordner. Anderenfalls wird der Download-Ordner der App verwendet. + OK + Orbot-Proxy wird nicht funktionieren, solange Orbot nicht installiert ist. Warte, bis sich Orbot verbindet... diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index e2b8bbf0..ef1b12de 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -45,6 +45,7 @@ Abrir la caja de navegación Cerrar la caja de navegación Sin título + URL no reconocida: Guardar como @@ -293,7 +294,7 @@ Agente de usuario personalizado Modo incógnito - Borrar el historial y el caché después de que cada página web termine de cargar. Forward and back do not work in Incognito Mode. + Borrar el historial y el caché después de que cada página web termine de cargar. Adelante y atrás no funcionan en el Modo incógnito. No rastrear Enviar la cabecera de no rastrear (DNT) que educadamente sugiere que los servidores web no rastreen este navegador. Listas de bloqueo diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2a02ddbf..aa99f13a 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -47,6 +47,7 @@ Открыть панель навигации Закрыть панель навигации Без названия + Нераспознанный URL: Сохранить как @@ -294,7 +295,7 @@ Пользовательский user agent Режим инкогнито - Очистка журнала и кэша после завершения загрузки каждой веб-страницы. Forward and back do not work in Incognito Mode. + Очистка журнала и кэша после завершения загрузки каждой веб-страницы. Кнопки \'Вперед\' и \'Назад\' не работают в этом режиме. Не отслеживать Отправлять заголовок \'не отслеживать\', являющийся пожеланием веб-серверу не отслеживать этот браузер. Списки блокировки -- 2.45.2