tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 28583afbc9480cfdc99d3d0effda92cca49d5937
parent 5146d651fbe3ce8f26c1beb9e961fca1d0f7599a
Author: leowrites <leo@liuwork.ca>
Date:   Mon, 10 Nov 2025 15:39:07 +0000

Bug 1983652 - Part 2: Fenix UI updates for ETP Strict Exceptions Options r=twhite,android-reviewers,android-l10n-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D262993

Diffstat:
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt | 66++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Mmobile/android/fenix/app/src/main/res/values/preference_keys.xml | 2++
Mmobile/android/fenix/app/src/main/res/values/strings.xml | 15++++++++++++---
Mmobile/android/fenix/app/src/main/res/xml/tracking_protection_preferences.xml | 17++++++++++++++---
4 files changed, 78 insertions(+), 22 deletions(-)

diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt @@ -6,8 +6,10 @@ package org.mozilla.fenix.settings import android.content.DialogInterface import android.os.Bundle +import android.text.SpannableStringBuilder import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AlertDialog +import androidx.core.text.HtmlCompat import androidx.navigation.findNavController import androidx.navigation.fragment.navArgs import androidx.preference.CheckBoxPreference @@ -81,6 +83,12 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { internal lateinit var strictAllowListConvenienceTrackingProtection: CheckBoxPreference @VisibleForTesting + internal lateinit var strictAllowListTrackingProtectionSubheader: Preference + + @VisibleForTesting + internal lateinit var customAllowListTrackingProtectionSubheader: Preference + + @VisibleForTesting lateinit var alertDialog: AlertDialog override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -128,22 +136,6 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { getString(R.string.app_name), ) - val strictAllowListBaseline = - requirePreference<Preference>(R.string.pref_key_tracking_protection_strict_allow_list_baseline) - - strictAllowListBaseline.summary = getString( - R.string.preference_enhanced_tracking_protection_allow_list_baseline, - getString(R.string.app_name), - ) - - val customAllowListBaseline = - requirePreference<Preference>(R.string.pref_key_tracking_protection_custom_allow_list_baseline) - - customAllowListBaseline.summary = getString( - R.string.preference_enhanced_tracking_protection_allow_list_baseline, - getString(R.string.app_name), - ) - val preferenceExceptions = requirePreference<Preference>(R.string.pref_key_tracking_protection_exceptions) preferenceExceptions.onPreferenceClickListener = exceptionsClickListener @@ -196,6 +188,17 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { strictAllowListConvenienceTrackingProtection = requirePreference(R.string.pref_key_tracking_protection_strict_allow_list_convenience) + strictAllowListTrackingProtectionSubheader = + requirePreference(R.string.pref_key_tracking_protection_strict_allow_list_subheader) + + val learnMore = + getString(R.string.preference_enhanced_tracking_protection_allow_list_learn_more) + strictAllowListTrackingProtectionSubheader.summary = getLink(learnMore) + strictAllowListTrackingProtectionSubheader.setOnPreferenceClickListener { + openSumoArticle() + true + } + strictAllowListBaselineTrackingProtection.onPreferenceChangeListener = object : SharedPreferenceUpdater() { override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean { // If user is unchecking the baseline protection, show dialog and prevent immediate update @@ -259,6 +262,17 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { customAllowListConvenienceTrackingProtection = requirePreference(R.string.pref_key_tracking_protection_custom_allow_list_convenience) + customAllowListTrackingProtectionSubheader = + requirePreference(R.string.pref_key_tracking_protection_custom_allow_list_subheader) + + val learnMore = + getString(R.string.preference_enhanced_tracking_protection_allow_list_learn_more) + customAllowListTrackingProtectionSubheader.summary = getLink(learnMore) + customAllowListTrackingProtectionSubheader.setOnPreferenceClickListener { + openSumoArticle() + true + } + customCookies.onPreferenceChangeListener = object : SharedPreferenceUpdater() { override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean { customCookiesSelect.isVisible = !customCookies.isChecked @@ -374,6 +388,7 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { val isStrictSelected = requireContext().settings().useStrictTrackingProtection strictAllowListBaselineTrackingProtection.isVisible = isStrictSelected strictAllowListConvenienceTrackingProtection.isVisible = isStrictSelected + strictAllowListTrackingProtectionSubheader.isVisible = isStrictSelected } private fun updateCustomOptionsVisibility() { @@ -389,6 +404,7 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { customSuspectedFingerprintersSelect.isVisible = isCustomSelected && customSuspectedFingerprinters.isChecked customAllowListBaselineTrackingProtection.isVisible = isCustomSelected customAllowListConvenienceTrackingProtection.isVisible = isCustomSelected + customAllowListTrackingProtectionSubheader.isVisible = isCustomSelected } private fun updateFingerprintingProtection() { @@ -416,6 +432,24 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { } } + private fun getLink(text: String): SpannableStringBuilder { + val rawTextWithLink = HtmlCompat.fromHtml( + "<a href=\"\">$text</a>", + HtmlCompat.FROM_HTML_MODE_COMPACT, + ) + return SpannableStringBuilder(rawTextWithLink) + } + + private fun openSumoArticle() { + (activity as HomeActivity).openToBrowserAndLoad( + searchTermOrURL = SupportUtils.getGenericSumoURLForTopic( + SupportUtils.SumoTopic.TRACKING_PROTECTION, + ), + newTab = true, + from = BrowserDirection.FromTrackingProtection, + ) + } + /** * Shows a confirmation dialog when the user attempts to disable baseline tracking exceptions. * diff --git a/mobile/android/fenix/app/src/main/res/values/preference_keys.xml b/mobile/android/fenix/app/src/main/res/values/preference_keys.xml @@ -230,8 +230,10 @@ <string name="pref_key_tracking_protection_exceptions" translatable="false">pref_key_tracking_protection_exceptions</string> <string name="pref_key_tracking_protection_standard_option" translatable="false">pref_key_tracking_protection_standard_option</string> <string name="pref_key_tracking_protection_strict_default" translatable="false">pref_key_tracking_protection_strict_default</string> + <string name="pref_key_tracking_protection_strict_allow_list_subheader" translatable="false">pref_key_tracking_protection_strict_allow_list_subheader</string> <string name="pref_key_tracking_protection_strict_allow_list_baseline" translatable="false">pref_key_tracking_protection_strict_allow_list_baseline</string> <string name="pref_key_tracking_protection_strict_allow_list_convenience" translatable="false">pref_key_tracking_protection_strict_allow_list_convenience</string> + <string name="pref_key_tracking_protection_custom_allow_list_subheader" translatable="false">pref_key_tracking_protection_custom_allow_list_subheader</string> <string name="pref_key_tracking_protection_custom_allow_list_baseline" translatable="false">pref_key_tracking_protection_custom_allow_list_baseline</string> <string name="pref_key_tracking_protection_custom_allow_list_convenience" translatable="false">pref_key_tracking_protection_custom_allow_list_convenience</string> <string name="pref_key_tracking_protection_custom_option" translatable="false">pref_key_tracking_protection_custom_option</string> diff --git a/mobile/android/fenix/app/src/main/res/values/strings.xml b/mobile/android/fenix/app/src/main/res/values/strings.xml @@ -2163,10 +2163,19 @@ <!-- Preference description for enhanced tracking protection for the strict protection settings --> <string name="preference_enhanced_tracking_protection_strict_description_4">Stronger tracking protection and faster performance, but some sites may not work properly.</string> <!-- Preference description for the checkbox setting for "baseline" exceptions (a set of content blocking exceptions applied to fix major website breakage). %1$s is the name of the application (e.g. Fenix). --> - <string name="preference_enhanced_tracking_protection_allow_list_baseline">Allow %1$s to automatically apply exceptions required to avoid major website breakage.</string> + <string name="preference_enhanced_tracking_protection_allow_list_baseline" tools:ignore="UnusedResources" moz:removedIn="144">Allow %1$s to automatically apply exceptions required to avoid major website breakage.</string> <!-- Preference description for the checkbox setting for "convenience" exceptions (a set of content blocking exceptions applied to fix convenience site features). --> - <string name="preference_enhanced_tracking_protection_allow_list_convenience">Also apply exceptions automatically that are only required to fix minor issues and make convenience features available.</string> - + <string name="preference_enhanced_tracking_protection_allow_list_convenience" tools:ignore="UnusedResources" moz:removedIn="144">Also apply exceptions automatically that are only required to fix minor issues and make convenience features available.</string> + <!-- Preference label for the enhanced tracking protection option to fix major site issues caused by tracker blocking --> + <string name="preference_enhanced_tracking_protection_allow_list_baseline_2">Fix major site issues (recommended)</string> + <!-- Preference label for the enhanced tracking protection option to fix minor site issues caused by tracker blocking --> + <string name="preference_enhanced_tracking_protection_allow_list_convenience_label">Fix minor site issues</string> + <!-- Preference description for the enhanced tracking protection option to fix minor site issues caused by tracker blocking --> + <string name="preference_enhanced_tracking_protection_allow_list_convenience_description">Must be used with fixes for major issues.</string> + <!-- Preference sub header for the enhanced tracking protection options to fix issues caused by tracker blocking --> + <string name="preference_enhanced_tracking_protection_allow_list_subheader">Fix site issues</string> + <!-- Learn more text for the enhanced tracking protection options to fix issues caused by tracker blocking --> + <string name="preference_enhanced_tracking_protection_allow_list_learn_more">Learn more</string> <!-- Dialog that appears after user tries to uncheck the baseline exceptions preference under Strict or Custom tracking protection --> <!-- Title for the dialog that appears after disabling the baseline exceptions preference under Strict or Custom tracking protection --> <string name="preference_enhanced_tracking_protection_allow_list_dialog_title">Are you sure you want to turn off fixes?</string> diff --git a/mobile/android/fenix/app/src/main/res/xml/tracking_protection_preferences.xml b/mobile/android/fenix/app/src/main/res/xml/tracking_protection_preferences.xml @@ -27,35 +27,46 @@ android:key="@string/pref_key_tracking_protection_strict_default" android:summary="@string/preference_enhanced_tracking_protection_strict_description_4" android:title="@string/preference_enhanced_tracking_protection_strict" /> + <androidx.preference.Preference + android:key="@string/pref_key_tracking_protection_strict_allow_list_subheader" + android:title="@string/preference_enhanced_tracking_protection_allow_list_subheader"> + </androidx.preference.Preference> <CheckBoxPreference android:defaultValue="true" android:dependency="@string/pref_key_tracking_protection_strict_default" android:key="@string/pref_key_tracking_protection_strict_allow_list_baseline" + android:title="@string/preference_enhanced_tracking_protection_allow_list_baseline_2" android:layout="@layout/checkbox_left_preference_etp" /> <CheckBoxPreference android:defaultValue="false" android:dependency="@string/pref_key_tracking_protection_strict_allow_list_baseline" android:key="@string/pref_key_tracking_protection_strict_allow_list_convenience" android:layout="@layout/checkbox_left_preference_etp" - android:summary="@string/preference_enhanced_tracking_protection_allow_list_convenience" /> + android:title="@string/preference_enhanced_tracking_protection_allow_list_convenience_label" + android:summary="@string/preference_enhanced_tracking_protection_allow_list_convenience_description" /> <org.mozilla.fenix.settings.RadioButtonInfoPreference android:defaultValue="false" android:dependency="@string/pref_key_tracking_protection" android:key="@string/pref_key_tracking_protection_custom_option" android:summary="@string/preference_enhanced_tracking_protection_custom_description_2" android:title="@string/preference_enhanced_tracking_protection_custom" /> + <androidx.preference.Preference + android:key="@string/pref_key_tracking_protection_custom_allow_list_subheader" + android:title="@string/preference_enhanced_tracking_protection_allow_list_subheader"> + </androidx.preference.Preference> <CheckBoxPreference android:defaultValue="true" android:dependency="@string/pref_key_tracking_protection_custom_option" android:key="@string/pref_key_tracking_protection_custom_allow_list_baseline" android:layout="@layout/checkbox_left_preference_etp" - android:summary="@string/preference_enhanced_tracking_protection_allow_list_baseline" /> + android:title="@string/preference_enhanced_tracking_protection_allow_list_baseline_2" /> <CheckBoxPreference android:defaultValue="false" android:dependency="@string/pref_key_tracking_protection_custom_allow_list_baseline" android:key="@string/pref_key_tracking_protection_custom_allow_list_convenience" android:layout="@layout/checkbox_left_preference_etp" - android:summary="@string/preference_enhanced_tracking_protection_allow_list_convenience" /> + android:title="@string/preference_enhanced_tracking_protection_allow_list_convenience_label" + android:summary="@string/preference_enhanced_tracking_protection_allow_list_convenience_description" /> <CheckBoxPreference android:defaultValue="true" android:dependency="@string/pref_key_tracking_protection_custom_option"