// Store the values from the shared preferences in variables.
incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false);
- boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false);
sanitizeGoogleAnalytics = sharedPreferences.getBoolean("google_analytics", true);
sanitizeFacebookClickIds = sharedPreferences.getBoolean("facebook_click_ids", true);
sanitizeTwitterAmpRedirects = sharedPreferences.getBoolean("twitter_amp_redirects", true);
// Apply the proxy.
applyProxy(false);
- // Set Do Not Track status.
- if (doNotTrackEnabled) {
- customHeaders.put("DNT", "1");
- } else {
- customHeaders.remove("DNT");
- }
-
// Get the current layout parameters. Using coordinator layout parameters allows the `setBehavior()` command and using app bar layout parameters allows the `setScrollFlags()` command.
CoordinatorLayout.LayoutParams swipeRefreshLayoutParams = (CoordinatorLayout.LayoutParams) swipeRefreshLayout.getLayoutParams();
AppBarLayout.LayoutParams toolbarLayoutParams = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
/*
- * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2021 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
// Set the swipe refresh background color.
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(colorBackgroundInt)
- // Get the Do Not Track status.
- val doNotTrack = sharedPreferences.getBoolean(getString(R.string.do_not_track_key), false)
-
// Populate the locale string.
val localeString = if (Build.VERSION.SDK_INT >= 24) { // SDK >= 24 has a list of locales.
// Get the list of locales.
progressBar.isIndeterminate = true
// Instantiate the WebView source factory.
- val webViewSourceFactory: ViewModelProvider.Factory = WebViewSourceFactory(currentUrl!!, userAgent!!, doNotTrack, localeString, proxy, MainWebViewActivity.executorService)
+ val webViewSourceFactory: ViewModelProvider.Factory = WebViewSourceFactory(currentUrl!!, userAgent!!, localeString, proxy, MainWebViewActivity.executorService)
// Instantiate the WebView source view model class.
val webViewSource = ViewModelProvider(this, webViewSourceFactory).get(WebViewSource::class.java)
// Get the index of the `/` immediately after the domain name.
val endOfDomainName = urlString.indexOf("/", urlString.indexOf("//") + 2)
- // Create a base URL string.
- val baseUrl: String
-
// Get the base URL.
- baseUrl = if (endOfDomainName > 0) { // There is at least one character after the base URL.
+ val baseUrl = if (endOfDomainName > 0) { // There is at least one character after the base URL.
// Get the base URL.
urlString.substring(0, endOfDomainName)
} else { // There are no characters after the base URL.
/*
- * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2021 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import java.net.URL;
public class GetSourceBackgroundTask {
- public SpannableStringBuilder[] acquire(String urlString, String userAgent, boolean doNotTrack, String localeString, Proxy proxy, WebViewSource webViewSource) {
+ public SpannableStringBuilder[] acquire(String urlString, String userAgent, String localeString, Proxy proxy, WebViewSource webViewSource) {
// Initialize the spannable string builders.
SpannableStringBuilder requestHeadersBuilder = new SpannableStringBuilder();
SpannableStringBuilder responseMessageBuilder = new SpannableStringBuilder();
requestHeadersBuilder.append(": ?1");
- // Only populate `Do Not Track` if it is enabled.
- if (doNotTrack) {
- // Set the `dnt` header property.
- httpUrlConnection.setRequestProperty("dnt", "1");
-
- // Add the `dnt` header to the string builder and format the text.
- requestHeadersBuilder.append(System.getProperty("line.separator"));
- if (Build.VERSION.SDK_INT >= 21) { // Newer versions of Android are so smart.
- requestHeadersBuilder.append("dnt", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- } else { // Older versions not so much.
- oldRequestHeadersBuilderLength = requestHeadersBuilder.length();
- requestHeadersBuilder.append("dnt");
- newRequestHeadersBuilderLength = requestHeadersBuilder.length();
- requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- requestHeadersBuilder.append(": 1");
- }
-
-
// Set the `Accept` header property.
httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
Preference userAgentPreference = findPreference("user_agent");
Preference customUserAgentPreference = findPreference("custom_user_agent");
Preference incognitoModePreference = findPreference("incognito_mode");
- Preference doNotTrackPreference = findPreference("do_not_track");
Preference allowScreenshotsPreference = findPreference(getString(R.string.allow_screenshots_key));
Preference easyListPreference = findPreference("easylist");
Preference easyPrivacyPreference = findPreference("easyprivacy");
assert userAgentPreference != null;
assert customUserAgentPreference != null;
assert incognitoModePreference != null;
- assert doNotTrackPreference != null;
assert allowScreenshotsPreference != null;
assert easyListPreference != null;
assert easyPrivacyPreference != null;
}
}
- // Set the Do Not Track icon.
- if (savedPreferences.getBoolean("do_not_track", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_enabled_night);
- } else {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_enabled_day);
- }
- } else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_disabled_night);
- } else {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_disabled_day);
- }
- }
-
// Set the allow screenshots icon.
if (savedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)) {
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
}
break;
- case "do_not_track":
- // Update the icon.
- if (sharedPreferences.getBoolean("do_not_track", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_enabled_night);
- } else {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_enabled_day);
- }
- } else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_disabled_night);
- } else {
- doNotTrackPreference.setIcon(R.drawable.block_tracking_disabled_day);
- }
- }
-
- break;
-
case "allow_screenshots":
// Update the icon.
if (sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)) {
public static final String IMPORT_SUCCESSFUL = "Import Successful";
// Declare the class constants.
- private static final int SCHEMA_VERSION = 13;
+ private static final int SCHEMA_VERSION = 14;
private static final String PREFERENCES_TABLE = "preferences";
// Declare the preferences constants.
private static final String USER_AGENT = "user_agent";
private static final String CUSTOM_USER_AGENT = "custom_user_agent";
private static final String INCOGNITO_MODE = "incognito_mode";
- private static final String DO_NOT_TRACK = "do_not_track";
private static final String ALLOW_SCREENSHOTS = "allow_screenshots";
private static final String EASYLIST = "easylist";
private static final String EASYPRIVACY = "easyprivacy";
// Upgrade from schema version 12, Privacy Browser 3.6.
case 12:
// Do nothing. `download_location` and `download_custom_location` were removed from the preferences table.
+
+ // Upgrade from schema version 13, Privacy Browser 3.7
+ case 13:
+ // Do nothing. `do_not_track` was removed from the preferences table.
}
}
.putString(USER_AGENT, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndex(USER_AGENT)))
.putString(CUSTOM_USER_AGENT, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndex(CUSTOM_USER_AGENT)))
.putBoolean(INCOGNITO_MODE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(INCOGNITO_MODE)) == 1)
- .putBoolean(DO_NOT_TRACK, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(DO_NOT_TRACK)) == 1)
.putBoolean(ALLOW_SCREENSHOTS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(ALLOW_SCREENSHOTS)) == 1)
.putBoolean(EASYLIST, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(EASYLIST)) == 1)
.putBoolean(EASYPRIVACY, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(EASYPRIVACY)) == 1)
USER_AGENT + " TEXT, " +
CUSTOM_USER_AGENT + " TEXT, " +
INCOGNITO_MODE + " BOOLEAN, " +
- DO_NOT_TRACK + " BOOLEAN, " +
ALLOW_SCREENSHOTS + " BOOLEAN, " +
EASYLIST + " BOOLEAN, " +
EASYPRIVACY + " BOOLEAN, " +
preferencesContentValues.put(USER_AGENT, sharedPreferences.getString(USER_AGENT, context.getString(R.string.user_agent_default_value)));
preferencesContentValues.put(CUSTOM_USER_AGENT, sharedPreferences.getString(CUSTOM_USER_AGENT, context.getString(R.string.custom_user_agent_default_value)));
preferencesContentValues.put(INCOGNITO_MODE, sharedPreferences.getBoolean(INCOGNITO_MODE, false));
- preferencesContentValues.put(DO_NOT_TRACK, sharedPreferences.getBoolean(DO_NOT_TRACK, false));
preferencesContentValues.put(ALLOW_SCREENSHOTS, sharedPreferences.getBoolean(ALLOW_SCREENSHOTS, false));
preferencesContentValues.put(EASYLIST, sharedPreferences.getBoolean(EASYLIST, true));
preferencesContentValues.put(EASYPRIVACY, sharedPreferences.getBoolean(EASYPRIVACY, true));
/*
- * Copyright © 2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2020-2021 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import java.net.Proxy
import java.util.concurrent.ExecutorService
-class WebViewSourceFactory (private val urlString: String, private val userAgent: String, private val doNotTrack: Boolean, private val localeString: String, private val proxy: Proxy,
+class WebViewSourceFactory (private val urlString: String, private val userAgent: String, private val localeString: String, private val proxy: Proxy,
private val executorService: ExecutorService): ViewModelProvider.Factory {
// Override the create function in order to add the provided arguments.
override fun <T: ViewModel?> create(modelClass: Class<T>): T {
// Return a new instance of the model class with the provided arguments.
return modelClass.getConstructor(String::class.java, String::class.java, Boolean::class.java, String::class.java, Proxy::class.java, ExecutorService::class.java)
- .newInstance(urlString, userAgent, doNotTrack, localeString, proxy, executorService)
+ .newInstance(urlString, userAgent, localeString, proxy, executorService)
}
}
\ No newline at end of file
/*
- * Copyright © 2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2020-2021 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import java.net.Proxy
import java.util.concurrent.ExecutorService
-class WebViewSource(private val urlString: String, private val userAgent: String, private val doNotTrack: Boolean, private val localeString: String, private val proxy: Proxy,
+class WebViewSource(private val urlString: String, private val userAgent: String, private val localeString: String, private val proxy: Proxy,
private val executorService: ExecutorService): ViewModel() {
// Initialize the mutable live data variables.
private val mutableLiveDataSourceStringArray = MutableLiveData<Array<SpannableStringBuilder>>()
val getSourceBackgroundTask = GetSourceBackgroundTask()
// Get the source.
- executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, doNotTrack, localeString, proxy, this)) }
+ executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, this)) }
}
// The source observer.
val getSourceBackgroundTask = GetSourceBackgroundTask()
// Get the source.
- executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, doNotTrack, localeString, proxy, this)) }
+ executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, this)) }
}
}
\ No newline at end of file
<string name="incognito_mode">Inkognito-Modus</string>
<string name="incognito_mode_summary">Löscht den Verlauf und den Cache nach jedem fertigen Laden einer Webseite.
Im Incognito-Modus schließt \'Zurück\'-Button den aktive Tab (oder die App, wenn nur ein Tab geöffnet wurde).</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="allow_screenshots">Screenshots zulassen</string>
<string name="allow_screenshots_summary">Screenshots, Bildschirmvideos und Anzeige auf unsicheren Bildschirmen zulassen. Eine Änderung dieser Einstellung startet Privacy Browser neu.</string>
<string name="blocklists">Sperrlisten</string>
<string name="incognito_mode">Modo incógnito</string>
<string name="incognito_mode_summary">Borrar el historial y el caché después de que cada página web termine de cargar.
En el modo Incógnito, Atrás cierra la pestaña (o la app si hay solo una pestaña).</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="allow_screenshots">Permitir capturas de pantalla</string>
<string name="allow_screenshots_summary">Permitir capturas de pantalla, grabación de vídeo y visualización en pantallas inseguras. Cambiar esta configuración reiniciará Navegador Privado.</string>
<string name="blocklists">Listas de bloqueo</string>
<string name="incognito_mode">Mode Incognito</string>
<string name="incognito_mode_summary">Vider l\'historique et le cache après le chargement de chaque page.
Dans le mode Incognito, le bouton Retour ferme l\'onglet (ou l\'application s\'il n\'y a qu\'un seul onglet).</string>
- <string name="do_not_track">Ne pas me pister</string>
- <string name="do_not_track_summary">Envoyer aux sites web un signal «Ne pas me pister» indiquant poliement que vous ne souhaitez pas être pisté</string>
<string name="allow_screenshots">Autoriser captures d\'écrans</string>
<string name="allow_screenshots_summary">Autoriser les captures d\'écrans, enregistrements vidéo et affichage sur des écrans non-sécurisés. Changer ce paramètre redémarrera Privacy Browser.</string>
<string name="blocklists">Listes noires</string>
<string name="incognito_mode">Modalità Incognito</string>
<string name="incognito_mode_summary">Cancella la cronologia e la cache al termine del caricamento di ogni pagina.
In Modalità Incognito, il tasto "Indietro" chiude la scheda (o l\'applicazione se è aperta solo una scheda).</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="allow_screenshots">Permetti gli screenshot</string>
<string name="allow_screenshots_summary">Permette gli screenshot, la registrazione di video, e la possibilità di visualizzare su schermi non sicuri.
La modifica di questa impostazione provoca il riavvio di Privacy Browser.</string>
<string name="incognito_mode">Modo de navegação anônima</string>
<string name="incognito_mode_summary">Limpe o histórico e o cache após o término do carregamento de cada página da web. No modo de navegação anônima,
volta para fechar a guia (ou o aplicativo, se houver apenas uma guia).</string>
- <string name="do_not_track">Não rastreie</string>
- <string name="do_not_track_summary">Envie \'Não Rastreie\' ao cabeçalho, que sugere educadamente que os servidores da web não rastreiam este navegador.</string>
<string name="allow_screenshots">Permitir capturas de tela</string>
<string name="allow_screenshots_summary">Permitir capturas de tela, gravação de vídeo e visualização em monitores não seguros. Alterar esta configuração irá reiniciar o Privacy Browser.</string>
<string name="blocklists">Blocklists</string>
<string name="incognito_mode">Режим инкогнито</string>
<string name="incognito_mode_summary">Очистка журнала и кэша по завершении загрузки каждой веб-страницы.
В режиме инкогнито нажатие кнопки Назад приведет к закрытию вкладки (или приложения, если открыта только одна вкладка).</string>
- <string name="do_not_track">Не отслеживать</string>
- <string name="do_not_track_summary">Отправлять заголовок \'Не отслеживать\', предлагающий веб-серверу не отслеживать этот браузер.</string>
<string name="allow_screenshots">Разрешить скриншоты</string>
<string name="allow_screenshots_summary">Разрешить скриншоты, запись видео и просмотр на незащищенных дисплеях. При изменении этого параметра Privacy Browser будет перезапущен.</string>
<string name="blocklists">Списки блокировки</string>
<string name="custom_user_agent">Özel kullanıcı aracısı</string>
<string name="incognito_mode">Gizli Mod</string>
<string name="incognito_mode_summary">Her web sayfasının yüklenmesi bittikten sonra geçmişi ve önbelleği temizler. In Incognito Mode, back closes the tab (or the app if there is only one tab).</string>
- <string name="do_not_track">Takip Etme</string>
- <string name="do_not_track_summary">Web Serverlarına bu tarayıcıyı takip etmemesi için Takip Etme Başlığı gönderir.</string>
<string name="allow_screenshots">Ekran görüntülerine izin ver</string>
<string name="allow_screenshots_summary">Ekran görüntülerine, video kaydına ve güvenli olmayan ekranlarda görüntülenmeye izin verir.
Bu ayarı değiştirmek Privacy Browser uygulamasını yeniden başlatır.</string>
<string name="system_default_user_agent" translatable="false">System default user agent</string> <!-- This item is referenced in code. It is never displayed on the screen. -->
<string name="incognito_mode">Incognito Mode</string>
<string name="incognito_mode_summary">Clear the history and cache after each webpage finishes loading. In Incognito Mode, back closes the tab (or the app if there is only one tab).</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="allow_screenshots">Allow screenshots</string>
<string name="allow_screenshots_summary">Allow screenshots, video recording, and viewing on non-secure displays. Changing this setting will restart Privacy Browser.</string>
<string name="blocklists">Blocklists</string>
<!-- Non-translatable preference keys. -->
<string name="allow_screenshots_key" translatable="false">allow_screenshots</string>
- <string name="do_not_track_key" translatable="false">do_not_track</string>
<string name="clear_logcat_key" translatable="false">clear_logcat</string>
<string name="display_additional_app_bar_icons_key" translatable="false">display_additional_app_bar_icons</string>
android:summary="@string/incognito_mode_summary"
android:defaultValue="false" />
- <SwitchPreference
- android:key="do_not_track"
- android:title="@string/do_not_track"
- android:summary="@string/do_not_track_summary"
- android:defaultValue="false" />
-
<SwitchPreference
android:key="allow_screenshots"
android:title="@string/allow_screenshots"