From: Soren Stoutner Date: Fri, 7 Apr 2017 18:04:27 +0000 (-0700) Subject: Add an Incognito Mode. Implements https://redmine.stoutner.com/issues/116. X-Git-Tag: v2.2~20 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=d9b68b83e414c8d02227b195e6398e8f92fe22c8;p=PrivacyBrowserAndroid.git Add an Incognito Mode. Implements https://redmine.stoutner.com/issues/116. --- 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 292292fa..6e1189bb 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -203,6 +203,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // `adBlockerEnabled` is used in `onCreate()` and `applyAppSettings()`. private boolean adBlockerEnabled; + // `privacyBrowserRuntime` is used in `onCreate()` and `applyAppSettings()`. + Runtime privacyBrowserRuntime; + + // `incognitoModeEnabled` is used in `onCreate()` and `applyAppSettings()`. + private boolean incognitoModeEnabled; + // `fullScreenBrowsingModeEnabled` is used in `onCreate()` and `applyAppSettings()`. private boolean fullScreenBrowsingModeEnabled; @@ -227,6 +233,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // `waitingForOrbotData` is used in `onCreate()` and `applyAppSettings()`. private String waitingForOrbotHTMLString; + // `privateDataDirectoryString` is used in `onCreate()` and `onNavigationItemSelected()`. + private String privateDataDirectoryString; + // `findOnPageLinearLayout` is used in `onCreate()`, `onOptionsItemSelected()`, and `closeFindOnPage()`. private LinearLayout findOnPageLinearLayout; @@ -655,8 +664,28 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Update formattedUrlString and urlTextBox. It is necessary to do this after the page finishes loading because the final URL can change during load. @Override public void onPageFinished(WebView view, String url) { - // Check to see if we are waiting on Orbot. - if (pendingUrl.isEmpty()) { // we are not waiting on Orbot, so we need to process the URL. + // Clear the cache and history if Incognito Mode is enabled. + if (incognitoModeEnabled) { + // Clear the cache. `true` includes disk files. + mainWebView.clearCache(true); + + // Clear the back/forward history. + mainWebView.clearHistory(); + + // Manually delete cache folders. + try { + // Delete the main `cache` folder. + privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/cache"); + + // Delete the `app_webview` folder, which contains an additional `WebView` cache. See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`. + privacyBrowserRuntime.exec("rm -rf " + privacyBrowserRuntime + "/app_webview"); + } catch (IOException e) { + // Do nothing if an error is thrown. + } + } + + // Update `urlTextBox` and apply domain settings if not waiting on Orbot. + if (pendingUrl.isEmpty()) { // We are not waiting on Orbot, so we need to process the URL. // Check to see if `WebView` has set `url` to be `about:blank`. if (url.equals("about:blank")) { // `WebView` is blank, so `formattedUrlString` should be `""` and `urlTextBox` should display a hint. // Set `formattedUrlString` to `""`. @@ -828,6 +857,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation formattedUrlString = launchingIntentUriData.toString(); } + // Get a handle for the `Runtime`. + privacyBrowserRuntime = Runtime.getRuntime(); + + // Store the application's private data directory. + privateDataDirectoryString = getApplicationInfo().dataDir; // `dataDir` will vary, but will be something like `/data/user/0/com.stoutner.privacybrowser.standard`, which links to `/data/data/com.stoutner.privacybrowser.standard`. + // Initialize `inFullScreenBrowsingMode`, which is always false at this point because Privacy Browser never starts in full screen browsing mode. inFullScreenBrowsingMode = false; @@ -1358,7 +1393,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(this); webViewDatabase.clearFormData(); - // Clear cache. The argument of "true" includes disk files. + // Clear the cache. `true` includes disk files. mainWebView.clearCache(true); // Clear the back/forward history. @@ -1379,15 +1414,13 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Destroy the internal state of `mainWebView`. mainWebView.destroy(); - // Manually delete folders. - Runtime runtime = Runtime.getRuntime(); - String dataDirString = getApplicationInfo().dataDir; // `dataDir` will vary, but will be something like `/data/user/0/com.stoutner.privacybrowser.standard`, which links to `/data/data/com.stoutner.privacybrowser.standard`. + // Manually delete cache folders. try { // Delete the main `cache` folder. - runtime.exec("rm -rf " + dataDirString + "/cache"); + privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/cache"); // Delete the `app_webview` folder, which contains an additional `WebView` cache. See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`. - runtime.exec("rm -rf " + dataDirString + "/app_webview"); + privacyBrowserRuntime.exec("rm -rf " + privacyBrowserRuntime + "/app_webview"); } catch (IOException e) { // Do nothing if an error is thrown. } @@ -2110,13 +2143,14 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation String torJavaScriptDisabledSearchCustomURLString = sharedPreferences.getString("tor_javascript_disabled_search_custom_url", ""); String torJavaScriptEnabledSearchString = sharedPreferences.getString("tor_javascript_enabled_search", "https://3g2upl4pq6kufc4m.onion/?q="); String torJavaScriptEnabledSearchCustomURLString = sharedPreferences.getString("tor_javascript_enabled_search_custom_url", ""); - swipeToRefreshEnabled = sharedPreferences.getBoolean("swipe_to_refresh_enabled", false); adBlockerEnabled = sharedPreferences.getBoolean("block_ads", true); + incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false); boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false); proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false); fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("enable_full_screen_browsing_mode", false); hideSystemBarsOnFullscreen = sharedPreferences.getBoolean("hide_system_bars", false); translucentNavigationBarOnFullscreen = sharedPreferences.getBoolean("translucent_navigation_bar", true); + swipeToRefreshEnabled = sharedPreferences.getBoolean("swipe_to_refresh", false); // Set the homepage, search, and proxy options. if (proxyThroughOrbot) { // Set the Tor options. diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index f25ac7ed..38addd36 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -215,6 +215,9 @@ Eigener User Agent Nicht verfolgen (Do not track) Einen "Do Not Track-Header" senden, der freundlich anfragt, dass Webserver diesen Browser nicht nachverfolgen sollen. + Tor + Proxy durch Orbot + Sämtlichen Web-Verkehr durch Orbot mittels localhost:8118 leiten. Suche Suchmaschine bei deaktiviertem JavaScript @@ -239,11 +242,8 @@ Suchmaschinen-URL bei aktivertem JavaScript Eigene URL - Tor - Proxy durch Orbot - Sämtlichen Web-Verkehr durch Orbot mittels localhost:8118 leiten. Allgemein - Startseite + Startseite Standard-Schriftgröße 50% diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index a869942f..fe6d89bf 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -230,6 +230,24 @@ Usar la lista de servidores de anuncios de pgl.yoyo.org para bloquear anuncios. No rastrear Enviar la cabecera de no rastrear (DNT) que educadamente sugiere que los servidores web no rastreen este navegador. + Tor + Enviar a través de Orbot + Enviar todo el tráfico web a través de Orbot en localhost:8118. + Página de inicio de Tor + Buscar en Tor con Javascript deshabilitado. + + DuckDuckGo + Torch + Personalizado + + URL personalizada de búsqueda en Tor con Javascript deshabilitado + Buscar en Tor con JavaScript habilitado + + DuckDuckGo + Torch + Personalizado + + URL personalizada de búsqueda en Tor con JavaScript habilitado Buscar Búsqueda de Javascript deshabilitado @@ -261,24 +279,6 @@ Esconder las barras de estado y de navegación en el modo de navegación a pantalla completa. Esto no funciona bien si el teclado es mostrado durante el modo de navegación a pantalla completa. Barra de navegación translúcida Hacer la barra de navegación translúcida en el modo de navegación a pantalla completa. - Tor - Enviar a través de Orbot - Enviar todo el tráfico web a través de Orbot en localhost:8118. - Página de inicio de Tor - Buscar en Tor con Javascript deshabilitado. - - DuckDuckGo - Torch - Personalizado - - URL personalizada de búsqueda en Tor con Javascript deshabilitado - Buscar en Tor con JavaScript habilitado - - DuckDuckGo - Torch - Personalizado - - URL personalizada de búsqueda en Tor con JavaScript habilitado General Página de inicio Tamaño de fuente por defecto diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index c25b4977..92e91601 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -232,6 +232,24 @@ Per bloccare gli annunci utilizza la lista dei server di pgl.yoyo.org. Non tracciare Invia un\'intestazione di non tracciamento per chiedere al web server di non tracciare il browser. + Tor + Utilizza Proxy con Orbot + Utilizza Proxy attraverso Orbot su localhost:8118. + Tor Homepage + Tor - Ricerca con JavaScript disabilitato + + DuckDuckGo + Torch + Custom + + Tor - Ricerca personalizzata con JavaScript disabilitato + Tor - Ricerca con JavaScript abilitato + + DuckDuckGo + Torch + Custom + + Tor - Ricerca personalizzata con JavaScript abilitato Ricerca Ricerca con JavaScript disabilitato @@ -263,24 +281,6 @@ Nasconde la barra di stato e la barra di navigazione durante la navigazione a schermo intero. Questa opzione non funziona perfettamente se si visualizza la tastiera durante la navigazione a schermo intero. Barra di navigazione trasparente Rende la barra di navigazione trasparente durante la navigazione a schermo intero. - Tor - Utilizza Proxy con Orbot - Utilizza Proxy attraverso Orbot su localhost:8118. - Tor Homepage - Tor - Ricerca con JavaScript disabilitato - - DuckDuckGo - Torch - Custom - - Tor - Ricerca personalizzata con JavaScript disabilitato - Tor - Ricerca con JavaScript abilitato - - DuckDuckGo - Torch - Custom - - Tor - Ricerca personalizzata con JavaScript abilitato Generale Homepage Dimensione standard carattere diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9ef9022c..7b41f49f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -249,8 +249,38 @@ Custom user agent Block ads Use the list of ad servers from pgl.yoyo.org to block ads. + Incognito Mode + Clear the history and cache after each webpage finishes loading. Do Not Track Send the Do Not Track header, which politely suggests that web servers not track this browser. + Tor + Proxy through Orbot + Proxy all web traffic through Orbot on localhost:8118. + Tor Homepage + Tor JavaScript-disabled search + + DuckDuckGo + Torch + Custom + + + http://3g2upl4pq6kufc4m.onion/html/?q= + http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?q= + Custom URL + + Tor JavaScript-disabled search custom URL + Tor JavaScript-enabled search + + DuckDuckGo + Torch + Custom + + + http://3g2upl4pq6kufc4m.onion/?q= + http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?q= + Custom URL + + Tor JavaScript-enabled search custom URL Search JavaScript-disabled search @@ -300,34 +330,6 @@ Hide the status and navigation bars in full screen browsing mode. This doesn\'t work well if the keyboard is displayed during full screen browsing mode. Translucent navigation bar Make the navigation bar translucent in full screen browsing mode. - Tor - Proxy through Orbot - Proxy all web traffic through Orbot on localhost:8118. - Tor Homepage - Tor JavaScript-disabled search - - DuckDuckGo - Torch - Custom - - - http://3g2upl4pq6kufc4m.onion/html/?q= - http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?q= - Custom URL - - Tor JavaScript-disabled search custom URL - Tor JavaScript-enabled search - - DuckDuckGo - Torch - Custom - - - http://3g2upl4pq6kufc4m.onion/?q= - http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?q= - Custom URL - - Tor JavaScript-enabled search custom URL General Homepage Default font size diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index b978d8f9..8f813b75 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -73,6 +73,12 @@ android:summary="@string/block_ads_summary" android:defaultValue="true" /> + + + + + + + + + + + + + + + + + @@ -134,49 +183,6 @@ android:defaultValue="true" /> - - - - - - - - - - - - - - - @@ -195,7 +201,7 @@ android:defaultValue="100" />