From 7246781c90254fc0abe5c8477c292fa2c9cb62ee Mon Sep 17 00:00:00 2001 From: Serg Date: Tue, 3 Mar 2026 19:20:01 -0500 Subject: [PATCH] [Android] Use Leo design tokens for icons in Brave Origin settings (#34411) Migrate Origin settings icons from custom drawables with hardcoded fill colors to Leo design token equivalents that use @color/icon_default for proper dark theme support. Remove manual icon tinting code that was working around the hardcoded colors. Resolves: https://github.com/brave/brave-browser/issues/53334 --- android/BUILD.gn | 3 - android/java/brave-res/drawable/bar_chart.xml | 16 ----- .../java/brave-res/drawable/email_shield.xml | 16 ----- .../brave-res/drawable/product_origin.xml | 18 ------ .../brave-res/xml/brave_main_preferences.xml | 2 +- .../xml/brave_origin_preferences.xml | 12 ++-- .../settings/BraveOriginPreferences.java | 64 ------------------- android/nala/icons.gni | 5 ++ 8 files changed, 12 insertions(+), 124 deletions(-) delete mode 100644 android/java/brave-res/drawable/bar_chart.xml delete mode 100644 android/java/brave-res/drawable/email_shield.xml delete mode 100644 android/java/brave-res/drawable/product_origin.xml diff --git a/android/BUILD.gn b/android/BUILD.gn index 52bf4c991b5..a32f04b99a8 100644 --- a/android/BUILD.gn +++ b/android/BUILD.gn @@ -203,7 +203,6 @@ android_resources("java_resources") { "java/brave-res/drawable/always_on_tab_selector.xml", "java/brave-res/drawable/always_on_tutorial_action_bg.xml", "java/brave-res/drawable/antenna_layer_list.xml", - "java/brave-res/drawable/bar_chart.xml", "java/brave-res/drawable/bat_ads_logo_button.xml", "java/brave-res/drawable/blue_48_rounded_bg.xml", "java/brave-res/drawable/blue_rounded_notification_bg.xml", @@ -265,7 +264,6 @@ android_resources("java_resources") { "java/brave-res/drawable/default_dot.xml", "java/brave-res/drawable/default_indicator.xml", "java/brave-res/drawable/ellipse_217.xml", - "java/brave-res/drawable/email_shield.xml", "java/brave-res/drawable/file_download.xml", "java/brave-res/drawable/file_upload.xml", "java/brave-res/drawable/fingerprint_unlock_layer_list.xml", @@ -459,7 +457,6 @@ android_resources("java_resources") { "java/brave-res/drawable/origin_restart_snackbar_bg.xml", "java/brave-res/drawable/password_match.xml", "java/brave-res/drawable/private_tab_gradient_background.xml", - "java/brave-res/drawable/product_origin.xml", "java/brave-res/drawable/product_private_layer_list.xml", "java/brave-res/drawable/product_vpn_layer_list.xml", "java/brave-res/drawable/progress_bar_medium.xml", diff --git a/android/java/brave-res/drawable/bar_chart.xml b/android/java/brave-res/drawable/bar_chart.xml deleted file mode 100644 index 98b2b282566..00000000000 --- a/android/java/brave-res/drawable/bar_chart.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/java/brave-res/drawable/email_shield.xml b/android/java/brave-res/drawable/email_shield.xml deleted file mode 100644 index 5228fc50c58..00000000000 --- a/android/java/brave-res/drawable/email_shield.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/java/brave-res/drawable/product_origin.xml b/android/java/brave-res/drawable/product_origin.xml deleted file mode 100644 index 71b4cc1bc79..00000000000 --- a/android/java/brave-res/drawable/product_origin.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/android/java/brave-res/xml/brave_main_preferences.xml b/android/java/brave-res/xml/brave_main_preferences.xml index 738d74861a0..5c18ac8223e 100644 --- a/android/java/brave-res/xml/brave_main_preferences.xml +++ b/android/java/brave-res/xml/brave_main_preferences.xml @@ -121,7 +121,7 @@ @@ -26,13 +26,13 @@ @@ -44,7 +44,7 @@ diff --git a/android/java/org/chromium/chrome/browser/settings/BraveOriginPreferences.java b/android/java/org/chromium/chrome/browser/settings/BraveOriginPreferences.java index 355bcdf4c8d..c5f6d3c8725 100644 --- a/android/java/org/chromium/chrome/browser/settings/BraveOriginPreferences.java +++ b/android/java/org/chromium/chrome/browser/settings/BraveOriginPreferences.java @@ -5,17 +5,13 @@ package org.chromium.chrome.browser.settings; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; -import androidx.appcompat.content.res.AppCompatResources; import androidx.preference.Preference; -import androidx.preference.PreferenceGroup; import com.google.android.material.snackbar.Snackbar; @@ -124,9 +120,6 @@ public class BraveOriginPreferences extends BravePreferenceFragment return true; }); } - - // Apply tinting to all preference icons for proper dark theme support - applyIconTinting(getPreferenceScreen(), null); } @Override @@ -296,63 +289,6 @@ public class BraveOriginPreferences extends BravePreferenceFragment } } - /** - * Recursively applies tinting to all preferences with icons. - * - * @param preferenceGroup The preference group to process - * @param tintList The color state list to apply (fetched once on first call) - */ - private void applyIconTinting( - PreferenceGroup preferenceGroup, @Nullable ColorStateList tintList) { - // Fetch the tint list once on the first call - if (tintList == null) { - tintList = - AppCompatResources.getColorStateList( - requireContext(), R.color.default_icon_color_secondary_tint_list); - if (tintList == null) { - return; - } - } - - // Process all preferences in this group - for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) { - Preference preference = preferenceGroup.getPreference(i); - - // Apply tinting if this preference has an icon - if (preference.getIcon() != null) { - applyTintToPreferenceIcon(preference, tintList); - } - - // Recursively process nested preference groups - if (preference instanceof PreferenceGroup) { - applyIconTinting((PreferenceGroup) preference, tintList); - } - } - } - - /** - * Applies the default icon tint to a preference's icon drawable. This ensures icons display - * correctly in both light and dark themes by using the default secondary icon color. - * - * @param preference The preference whose icon should be tinted - * @param tintList The color state list to apply to the icon - */ - private void applyTintToPreferenceIcon(Preference preference, ColorStateList tintList) { - Drawable icon = preference.getIcon(); - if (icon == null) { - return; - } - - // Mutate the drawable to avoid affecting other instances - icon = icon.mutate(); - - // Apply the tint list - icon.setTintList(tintList); - - // Set the tinted icon back to the preference - preference.setIcon(icon); - } - @Override public void onDestroy() { dismissRestartSnackbar(); diff --git a/android/nala/icons.gni b/android/nala/icons.gni index 3783e96ae19..d52b739c954 100644 --- a/android/nala/icons.gni +++ b/android/nala/icons.gni @@ -8,6 +8,7 @@ nala_icons = [ "ic_accessibility.xml", "ic_appearance.xml", "ic_bar_chart_search.xml", + "ic_bar_chart.xml", "ic_browser_customizable_shortcut.xml", "ic_browser_home.xml", "ic_browser_mobile_tabs_bottom.xml", @@ -15,7 +16,9 @@ nala_icons = [ "ic_browser_mobile_tabs.xml", "ic_code.xml", "ic_credit_card.xml", + "ic_brave_icon_search.xml", "ic_download.xml", + "ic_email_shield.xml", "ic_media_player.xml", "ic_microphone.xml", "ic_info_outline.xml", @@ -24,8 +27,10 @@ nala_icons = [ "ic_location_on.xml", "ic_star_circle.xml", "ic_notification.xml", + "ic_product_bat_outline.xml", "ic_product_brave_leo.xml", "ic_product_brave_news.xml", + "ic_product_origin.xml", "ic_product_brave_wallet.xml", "ic_product_sync.xml", "ic_product_translate.xml",