// `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;
// `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;
// 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 `""`.
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;
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.
// 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.
}
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.
<string name="custom_user_agent">Eigener User Agent</string>
<string name="do_not_track">Nicht verfolgen (Do not track)</string>
<string name="do_not_track_summary">Einen "Do Not Track-Header" senden, der freundlich anfragt, dass Webserver diesen Browser nicht nachverfolgen sollen.</string>
+ <string name="tor">Tor</string>
+ <string name="proxy_through_orbot">Proxy durch Orbot</string>
+ <string name="proxy_through_orbot_summary">Sämtlichen Web-Verkehr durch Orbot mittels localhost:8118 leiten.</string>
<string name="search">Suche</string>
<string name="javascript_disabled_search">Suchmaschine bei deaktiviertem JavaScript</string>
<string-array name="javascript_disabled_search_entries">
</string-array>
<string name="javascript_enabled_search_custom_url">Suchmaschinen-URL bei aktivertem JavaScript</string>
<string name="custom_url">Eigene URL</string>
- <string name="tor">Tor</string>
- <string name="proxy_through_orbot">Proxy durch Orbot</string>
- <string name="proxy_through_orbot_summary">Sämtlichen Web-Verkehr durch Orbot mittels localhost:8118 leiten.</string>
<string name="general">Allgemein</string>
- <string name="homepage">Startseite</string>
+ <string name="homepage">Startseite</string>
<string name="default_font_size">Standard-Schriftgröße</string>
<string-array name="default_font_size_entries">
<item>50%</item>
<string name="block_ads_summary">Usar la lista de servidores de anuncios de pgl.yoyo.org para bloquear anuncios.</string>
<string name="do_not_track">No rastrear</string>
<string name="do_not_track_summary">Enviar la cabecera de no rastrear (DNT) que educadamente sugiere que los servidores web no rastreen este navegador.</string>
+ <string name="tor">Tor</string>
+ <string name="proxy_through_orbot">Enviar a través de Orbot</string>
+ <string name="proxy_through_orbot_summary">Enviar todo el tráfico web a través de Orbot en localhost:8118.</string>
+ <string name="tor_homepage">Página de inicio de Tor</string>
+ <string name="tor_javascript_disabled_search">Buscar en Tor con Javascript deshabilitado.</string>
+ <string-array name="tor_javascript_disabled_search_entries">
+ <item>DuckDuckGo</item>
+ <item>Torch</item>
+ <item>Personalizado</item>
+ </string-array>
+ <string name="tor_javascript_disabled_search_custom_url">URL personalizada de búsqueda en Tor con Javascript deshabilitado</string>
+ <string name="tor_javascript_enabled_search">Buscar en Tor con JavaScript habilitado</string>
+ <string-array name="tor_javascript_enabled_search_entries">
+ <item>DuckDuckGo</item>
+ <item>Torch</item>
+ <item>Personalizado</item>
+ </string-array>
+ <string name="tor_javascript_enabled_search_custom_url">URL personalizada de búsqueda en Tor con JavaScript habilitado</string>
<string name="search">Buscar</string>
<string name="javascript_disabled_search">Búsqueda de Javascript deshabilitado</string>
<string-array name="javascript_disabled_search_entries">
<string name="hide_system_bars_summary">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.</string>
<string name="translucent_navigation_bar">Barra de navegación translúcida</string>
<string name="translucent_navigation_bar_summary">Hacer la barra de navegación translúcida en el modo de navegación a pantalla completa.</string>
- <string name="tor">Tor</string>
- <string name="proxy_through_orbot">Enviar a través de Orbot</string>
- <string name="proxy_through_orbot_summary">Enviar todo el tráfico web a través de Orbot en localhost:8118.</string>
- <string name="tor_homepage">Página de inicio de Tor</string>
- <string name="tor_javascript_disabled_search">Buscar en Tor con Javascript deshabilitado.</string>
- <string-array name="tor_javascript_disabled_search_entries">
- <item>DuckDuckGo</item>
- <item>Torch</item>
- <item>Personalizado</item>
- </string-array>
- <string name="tor_javascript_disabled_search_custom_url">URL personalizada de búsqueda en Tor con Javascript deshabilitado</string>
- <string name="tor_javascript_enabled_search">Buscar en Tor con JavaScript habilitado</string>
- <string-array name="tor_javascript_enabled_search_entries">
- <item>DuckDuckGo</item>
- <item>Torch</item>
- <item>Personalizado</item>
- </string-array>
- <string name="tor_javascript_enabled_search_custom_url">URL personalizada de búsqueda en Tor con JavaScript habilitado</string>
<string name="general">General</string>
<string name="homepage">Página de inicio</string>
<string name="default_font_size">Tamaño de fuente por defecto</string>
<string name="block_ads_summary">Per bloccare gli annunci utilizza la lista dei server di pgl.yoyo.org.</string>
<string name="do_not_track">Non tracciare</string>
<string name="do_not_track_summary">Invia un\'intestazione di non tracciamento per chiedere al web server di non tracciare il browser.</string>
+ <string name="tor">Tor</string>
+ <string name="proxy_through_orbot">Utilizza Proxy con Orbot</string>
+ <string name="proxy_through_orbot_summary">Utilizza Proxy attraverso Orbot su localhost:8118.</string>
+ <string name="tor_homepage">Tor Homepage</string>
+ <string name="tor_javascript_disabled_search">Tor - Ricerca con JavaScript disabilitato</string>
+ <string-array name="tor_javascript_disabled_search_entries">
+ <item>DuckDuckGo</item>
+ <item>Torch</item>
+ <item>Custom</item>
+ </string-array>
+ <string name="tor_javascript_disabled_search_custom_url">Tor - Ricerca personalizzata con JavaScript disabilitato</string>
+ <string name="tor_javascript_enabled_search">Tor - Ricerca con JavaScript abilitato</string>
+ <string-array name="tor_javascript_enabled_search_entries">
+ <item>DuckDuckGo</item>
+ <item>Torch</item>
+ <item>Custom</item>
+ </string-array>
+ <string name="tor_javascript_enabled_search_custom_url">Tor - Ricerca personalizzata con JavaScript abilitato</string>
<string name="search">Ricerca</string>
<string name="javascript_disabled_search">Ricerca con JavaScript disabilitato</string>
<string-array name="javascript_disabled_search_entries">
<string name="hide_system_bars_summary">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.</string>
<string name="translucent_navigation_bar">Barra di navigazione trasparente</string>
<string name="translucent_navigation_bar_summary">Rende la barra di navigazione trasparente durante la navigazione a schermo intero.</string>
- <string name="tor">Tor</string>
- <string name="proxy_through_orbot">Utilizza Proxy con Orbot</string>
- <string name="proxy_through_orbot_summary">Utilizza Proxy attraverso Orbot su localhost:8118.</string>
- <string name="tor_homepage">Tor Homepage</string>
- <string name="tor_javascript_disabled_search">Tor - Ricerca con JavaScript disabilitato</string>
- <string-array name="tor_javascript_disabled_search_entries">
- <item>DuckDuckGo</item>
- <item>Torch</item>
- <item>Custom</item>
- </string-array>
- <string name="tor_javascript_disabled_search_custom_url">Tor - Ricerca personalizzata con JavaScript disabilitato</string>
- <string name="tor_javascript_enabled_search">Tor - Ricerca con JavaScript abilitato</string>
- <string-array name="tor_javascript_enabled_search_entries">
- <item>DuckDuckGo</item>
- <item>Torch</item>
- <item>Custom</item>
- </string-array>
- <string name="tor_javascript_enabled_search_custom_url">Tor - Ricerca personalizzata con JavaScript abilitato</string>
<string name="general">Generale</string>
<string name="homepage">Homepage</string>
<string name="default_font_size">Dimensione standard carattere</string>
<string name="custom_user_agent">Custom user agent</string>
<string name="block_ads">Block ads</string>
<string name="block_ads_summary">Use the list of ad servers from pgl.yoyo.org to block ads.</string>
+ <string name="incognito_mode">Incognito Mode</string>
+ <string name="incognito_mode_summary">Clear the history and cache after each webpage finishes loading.</string>
<string name="do_not_track">Do Not Track</string>
<string name="do_not_track_summary">Send the Do Not Track header, which politely suggests that web servers not track this browser.</string>
+ <string name="tor">Tor</string>
+ <string name="proxy_through_orbot">Proxy through Orbot</string>
+ <string name="proxy_through_orbot_summary">Proxy all web traffic through Orbot on localhost:8118.</string>
+ <string name="tor_homepage">Tor Homepage</string>
+ <string name="tor_javascript_disabled_search">Tor JavaScript-disabled search</string>
+ <string-array name="tor_javascript_disabled_search_entries">
+ <item>DuckDuckGo</item>
+ <item>Torch</item>
+ <item>Custom</item>
+ </string-array>
+ <string-array name="tor_javascript_disabled_search_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. -->
+ <item>http://3g2upl4pq6kufc4m.onion/html/?q=</item>
+ <item>http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?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="tor_javascript_disabled_search_custom_url">Tor JavaScript-disabled search custom URL</string>
+ <string name="tor_javascript_enabled_search">Tor JavaScript-enabled search</string>
+ <string-array name="tor_javascript_enabled_search_entries">
+ <item>DuckDuckGo</item>
+ <item>Torch</item>
+ <item>Custom</item>
+ </string-array>
+ <string-array name="tor_javascript_enabled_search_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. -->
+ <item>http://3g2upl4pq6kufc4m.onion/?q=</item>
+ <item>http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?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="tor_javascript_enabled_search_custom_url">Tor JavaScript-enabled search custom URL</string>
<string name="search">Search</string>
<string name="javascript_disabled_search">JavaScript-disabled search</string>
<string-array name="javascript_disabled_search_entries">
<string name="hide_system_bars_summary">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.</string>
<string name="translucent_navigation_bar">Translucent navigation bar</string>
<string name="translucent_navigation_bar_summary">Make the navigation bar translucent in full screen browsing mode.</string>
- <string name="tor">Tor</string>
- <string name="proxy_through_orbot">Proxy through Orbot</string>
- <string name="proxy_through_orbot_summary">Proxy all web traffic through Orbot on localhost:8118.</string>
- <string name="tor_homepage">Tor Homepage</string>
- <string name="tor_javascript_disabled_search">Tor JavaScript-disabled search</string>
- <string-array name="tor_javascript_disabled_search_entries">
- <item>DuckDuckGo</item>
- <item>Torch</item>
- <item>Custom</item>
- </string-array>
- <string-array name="tor_javascript_disabled_search_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. -->
- <item>http://3g2upl4pq6kufc4m.onion/html/?q=</item>
- <item>http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?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="tor_javascript_disabled_search_custom_url">Tor JavaScript-disabled search custom URL</string>
- <string name="tor_javascript_enabled_search">Tor JavaScript-enabled search</string>
- <string-array name="tor_javascript_enabled_search_entries">
- <item>DuckDuckGo</item>
- <item>Torch</item>
- <item>Custom</item>
- </string-array>
- <string-array name="tor_javascript_enabled_search_entry_values" translatable="false"> <!-- None of the items in this `string-array` should be translated. -->
- <item>http://3g2upl4pq6kufc4m.onion/?q=</item>
- <item>http://xmh57jrzrnw6insl.onion/4a1f6b371c/search.cgi?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="tor_javascript_enabled_search_custom_url">Tor JavaScript-enabled search custom URL</string>
<string name="general">General</string>
<string name="homepage">Homepage</string>
<string name="default_font_size">Default font size</string>
android:summary="@string/block_ads_summary"
android:defaultValue="true" />
+ <SwitchPreference
+ android:key="incognito_mode"
+ android:title="@string/incognito_mode"
+ android:summary="@string/incognito_mode_summary"
+ android:defaultValue="false" />
+
<SwitchPreference
android:key="do_not_track"
android:title="@string/do_not_track"
android:defaultValue="false" />
</PreferenceCategory>
+ <PreferenceCategory
+ android:key="tor"
+ android:title="@string/tor" >
+
+ <SwitchPreference
+ android:key="proxy_through_orbot"
+ android:title="@string/proxy_through_orbot"
+ android:summary="@string/proxy_through_orbot_summary"
+ android:defaultValue="false" />
+
+ <EditTextPreference
+ android:key="tor_homepage"
+ android:title="@string/tor_homepage"
+ android:defaultValue="https://3g2upl4pq6kufc4m.onion"
+ android:inputType="textUri" />
+
+ <ListPreference
+ android:key="tor_javascript_disabled_search"
+ android:title="@string/tor_javascript_disabled_search"
+ android:entries="@array/tor_javascript_disabled_search_entries"
+ android:entryValues="@array/tor_javascript_disabled_search_entry_values"
+ android:defaultValue="https://3g2upl4pq6kufc4m.onion/html/?q=" />
+
+ <EditTextPreference
+ android:key="tor_javascript_disabled_search_custom_url"
+ android:title="@string/tor_javascript_disabled_search_custom_url"
+ android:defaultValue=""
+ android:inputType="textUri" />
+
+ <ListPreference
+ android:key="tor_javascript_enabled_search"
+ android:title="@string/tor_javascript_enabled_search"
+ android:entries="@array/tor_javascript_enabled_search_entries"
+ android:entryValues="@array/tor_javascript_enabled_search_entry_values"
+ android:defaultValue="https://3g2upl4pq6kufc4m.onion/?q=" />
+
+ <EditTextPreference
+ android:key="tor_javascript_enabled_search_custom_url"
+ android:title="@string/tor_javascript_enabled_search_custom_url"
+ android:defaultValue=""
+ android:inputType="textUri" />
+ </PreferenceCategory>
+
<PreferenceCategory
android:key="search"
android:title="@string/search">
android:defaultValue="true" />
</PreferenceCategory>
- <PreferenceCategory
- android:key="tor"
- android:title="@string/tor" >
-
- <SwitchPreference
- android:key="proxy_through_orbot"
- android:title="@string/proxy_through_orbot"
- android:summary="@string/proxy_through_orbot_summary"
- android:defaultValue="false" />
-
- <EditTextPreference
- android:key="tor_homepage"
- android:title="@string/tor_homepage"
- android:defaultValue="https://3g2upl4pq6kufc4m.onion"
- android:inputType="textUri" />
-
- <ListPreference
- android:key="tor_javascript_disabled_search"
- android:title="@string/tor_javascript_disabled_search"
- android:entries="@array/tor_javascript_disabled_search_entries"
- android:entryValues="@array/tor_javascript_disabled_search_entry_values"
- android:defaultValue="https://3g2upl4pq6kufc4m.onion/html/?q=" />
-
- <EditTextPreference
- android:key="tor_javascript_disabled_search_custom_url"
- android:title="@string/tor_javascript_disabled_search_custom_url"
- android:defaultValue=""
- android:inputType="textUri" />
-
- <ListPreference
- android:key="tor_javascript_enabled_search"
- android:title="@string/tor_javascript_enabled_search"
- android:entries="@array/tor_javascript_enabled_search_entries"
- android:entryValues="@array/tor_javascript_enabled_search_entry_values"
- android:defaultValue="https://3g2upl4pq6kufc4m.onion/?q=" />
-
- <EditTextPreference
- android:key="tor_javascript_enabled_search_custom_url"
- android:title="@string/tor_javascript_enabled_search_custom_url"
- android:defaultValue=""
- android:inputType="textUri" />
- </PreferenceCategory>
-
<PreferenceCategory
android:key="general"
android:title="@string/general" >
android:defaultValue="100" />
<SwitchPreference
- android:key="swipe_to_refresh_enabled"
+ android:key="swipe_to_refresh"
android:title="@string/swipe_to_refresh_enabled"
android:summary="@string/swipe_to_refresh_enabled_summary"
android:defaultValue="false" />