[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
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/shield_text_color"
|
||||
android:pathData="M20.3333,22H16.1667C15.7058,22 15.3333,21.6267 15.3333,21.1667V2.8333C15.3333,2.3733 15.7058,2 16.1667,2H20.3333C20.7942,2 21.1667,2.3733 21.1667,2.8333V21.1667C21.1667,21.6267 20.7942,22 20.3333,22ZM19.5,3.6667H17V20.3333H19.5V3.6667ZM13.6667,22H9.5C9.0392,22 8.6667,21.6267 8.6667,21.1667V12.8333C8.6667,12.3733 9.0392,12 9.5,12H13.6667C14.1275,12 14.5,12.3733 14.5,12.8333V21.1667C14.5,21.6267 14.1275,22 13.6667,22ZM12.8333,13.6667H10.3333V20.3333H12.8333V13.6667ZM7,22H2.8333C2.3725,22 2,21.6267 2,21.1667V8.6667C2,8.2067 2.3725,7.8333 2.8333,7.8333H7C7.4608,7.8333 7.8333,8.2067 7.8333,8.6667V21.1667C7.8333,21.6267 7.4608,22 7,22ZM6.1667,9.5H3.6667V20.3333H6.1667V9.5Z"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="21"
|
||||
android:viewportHeight="18">
|
||||
<path
|
||||
android:fillColor="@color/shield_text_color"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M19.167,8.16642C18.7067,8.16642 18.3867,7.83469 18.3867,7.37511V2.92289L10.5489,9.79311C10.3918,9.93098 10.1963,9.9995 10,9.9995C9.80366,9.9995 9.60732,9.93098 9.45108,9.79311L1.66681,2.96968V12.4996C1.66681,12.9592 2.04027,13.3335 2.49979,13.3335H11C11.4604,13.3335 11.833,13.7062 11.833,14.1666C11.833,14.627 11.4604,14.9997 11,14.9997H2.49979C1.12123,14.9997 0,13.8783 0,12.4996V2.50008C0,1.12136 1.12123,0 2.49979,0H17.5002C18.8788,0 20,1.12136 20,2.50008V7.33333C20,7.79291 19.6265,8.16642 19.167,8.16642ZM2.70869,1.667L10,8.05842L17.2914,1.667H2.70869ZM14.6,11.5993L16.6,10.6823L18.6,11.5993V13.0485C18.6,14.5299 17.6955,15.8292 16.6,16.3132C15.5045,15.8292 14.6,14.5299 14.6,13.0485V11.5993ZM16.2751,9.07113C16.4819,8.97629 16.7181,8.97629 16.9249,9.07113L19.7249,10.3549C20.0138,10.4873 20.2,10.7829 20.2,11.109V13.0485C20.2,15.3385 18.664,17.4801 16.6,18C14.536,17.4801 13,15.3385 13,13.0485V11.109C13,10.7829 13.1862,10.4873 13.4751,10.3549L16.2751,9.07113Z" />
|
||||
</vector>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/shield_text_color"
|
||||
android:fillType="evenOdd"
|
||||
android:scaleType="fitCenter"
|
||||
android:pathData="M10.3135,2.33496C11.2852,1.50683 12.7148,1.50682 13.6865,2.33496L15.3984,3.79395L17.6416,3.97363C18.9143,4.0752 19.9248,5.08567 20.0264,6.3584L20.2061,8.60156L21.665,10.3135C22.4932,11.2852 22.4932,12.7148 21.665,13.6865L20.2061,15.3984L20.0264,17.6416C19.9248,18.9143 18.9143,19.9248 17.6416,20.0264L15.3984,20.2061L13.6865,21.665C12.7148,22.4932 11.2852,22.4932 10.3135,21.665L8.60156,20.2061L6.3584,20.0264C5.08568,19.9248 4.0752,18.9143 3.97363,17.6416L3.79395,15.3984L2.33496,13.6865C1.50683,12.7148 1.50682,11.2852 2.33496,10.3135L3.79395,8.60156L3.97363,6.3584C4.0752,5.08568 5.08567,4.0752 6.3584,3.97363L8.60156,3.79395L10.3135,2.33496ZM12.6484,3.55273C12.2747,3.23435 11.7253,3.23435 11.3516,3.55273L9.49121,5.1377C9.33105,5.27419 9.13164,5.35728 8.92188,5.37402L6.48535,5.56836C5.996,5.6075 5.6075,5.996 5.56836,6.48535L5.37402,8.92188C5.35728,9.13164 5.27419,9.33105 5.1377,9.49121L3.55273,11.3516C3.23435,11.7253 3.23435,12.2747 3.55273,12.6484L5.1377,14.5088C5.142,14.5138 5.14522,14.5203 5.14941,14.5254C5.85874,15.0759 6.90888,15.0039 7.16211,14.1377C7.32228,13.5893 7.36185,12.9959 7.3125,12.4121C7.30121,12.2785 7.29493,12.1434 7.29492,12.0068C7.29492,9.38145 9.42345,7.25299 12.0488,7.25293C12.7464,7.25293 13.4091,7.40295 14.0059,7.67285L10.5449,11.1338C10.8155,12.3124 11.7433,13.2402 12.9219,13.5107L16.3828,10.0498C16.6527,10.6465 16.8027,11.3093 16.8027,12.0068C16.8026,14.6322 14.6742,16.7607 12.0488,16.7607C11.9123,16.7607 11.7772,16.7544 11.6436,16.7432C11.0033,16.689 10.3662,16.7277 9.7793,16.9248C8.98641,17.1913 8.93349,18.1781 9.45117,18.833C9.46416,18.843 9.47869,18.8516 9.49121,18.8623L11.3516,20.4473C11.7253,20.7657 12.2747,20.7657 12.6484,20.4473L14.5088,18.8623C14.669,18.7258 14.8684,18.6427 15.0781,18.626L17.5146,18.4316C18.004,18.3925 18.3925,18.004 18.4316,17.5146L18.626,15.0781C18.6427,14.8684 18.7258,14.669 18.8623,14.5088L20.4473,12.6484C20.7657,12.2747 20.7657,11.7253 20.4473,11.3516L18.8623,9.49121C18.7258,9.33105 18.6427,9.13164 18.626,8.92188L18.4316,6.48535C18.3925,5.99599 18.004,5.6075 17.5146,5.56836L15.0781,5.37402C14.8684,5.35728 14.669,5.27419 14.5088,5.1377L12.6484,3.55273Z" />
|
||||
|
||||
</vector>
|
||||
@@ -121,7 +121,7 @@
|
||||
<org.chromium.components.browser_ui.settings.ChromeBasePreference
|
||||
android:key="brave_origin"
|
||||
android:order="14"
|
||||
android:icon="@drawable/product_origin"
|
||||
android:icon="@drawable/ic_product_origin"
|
||||
android:title="@string/menu_origin"/>
|
||||
<PreferenceCategory
|
||||
android:key="display_section"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="rewards_switch"
|
||||
android:title="@string/origin_rewards_toggle"
|
||||
android:icon="@drawable/brave_menu_rewards"
|
||||
android:icon="@drawable/ic_product_bat_outline"
|
||||
android:defaultValue="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
@@ -26,13 +26,13 @@
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="crash_reports_switch"
|
||||
android:title="@string/origin_crash_reports_toggle"
|
||||
android:icon="@drawable/bar_chart"
|
||||
android:icon="@drawable/ic_bar_chart"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="privacy_preserving_analytics_switch"
|
||||
android:title="@string/origin_privacy_preserving_analytics_toggle"
|
||||
android:icon="@drawable/bar_chart"
|
||||
android:icon="@drawable/ic_bar_chart"
|
||||
android:defaultValue="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
@@ -44,7 +44,7 @@
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="email_aliases_switch"
|
||||
android:title="@string/origin_email_aliases_toggle"
|
||||
android:icon="@drawable/email_shield"
|
||||
android:icon="@drawable/ic_email_shield"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
@@ -62,7 +62,7 @@
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="statistics_reporting_switch"
|
||||
android:title="@string/origin_statistics_reporting_toggle"
|
||||
android:icon="@drawable/bar_chart"
|
||||
android:icon="@drawable/ic_bar_chart"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
@@ -80,7 +80,7 @@
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="web_discovery_project_switch"
|
||||
android:title="@string/origin_web_discovery_project_toggle"
|
||||
android:icon="@drawable/brave_icon_search"
|
||||
android:icon="@drawable/ic_brave_icon_search"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<!-- Informational text about Brave Origin -->
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user