From 2380da38772bda6550a3a0c31f6a2a6ef86fd515 Mon Sep 17 00:00:00 2001 From: Pavneet-Sing Date: Fri, 24 Jun 2022 16:15:32 +0530 Subject: [PATCH] fix(wallet): change wallet icon color per website theme --- .../toolbar/top/BraveToolbarLayoutImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java b/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java index cd7b4a6ff3c9..c265a271491f 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java +++ b/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java @@ -13,6 +13,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; @@ -124,6 +125,7 @@ import org.chromium.content_public.browser.NavigationHandle; import org.chromium.ui.UiUtils; import org.chromium.ui.interpolators.BakedBezierInterpolator; +import org.chromium.ui.util.ColorUtils; import org.chromium.ui.widget.Toast; import org.chromium.url.GURL; @@ -170,6 +172,7 @@ public abstract class BraveToolbarLayoutImpl extends ToolbarLayout private TextView mBraveRewardsNotificationsCount; private ImageView mBraveRewardsOnboardingIcon; private View mBraveWalletBadge; + private ImageView mWalletIcon; private boolean mShieldsLayoutIsColorBackground; private int mCurrentToolbarColor; @@ -181,6 +184,9 @@ public abstract class BraveToolbarLayoutImpl extends ToolbarLayout private boolean mIsBottomToolbarVisible; + private ColorStateList mDarkModeTint; + private ColorStateList mLightModeTint; + private final Set mTabsWithWalletIcon = Collections.synchronizedSet(new HashSet()); @@ -226,6 +232,11 @@ protected void onFinishInflate() { mBraveRewardsButton = (ImageButton) findViewById(R.id.brave_rewards_button); mHomeButton = (HomeButton) findViewById(R.id.home_button); mBraveWalletBadge = findViewById(R.id.wallet_notfication_badge); + mWalletIcon = mWalletLayout.findViewById(R.id.brave_wallet_button); + + mDarkModeTint = ThemeUtils.getThemedToolbarIconTint(getContext(), false); + mLightModeTint = + ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.brave_white)); if (mHomeButton != null) { mHomeButton.setOnLongClickListener(this); @@ -1178,6 +1189,10 @@ private void updateNotificationBadgeForNewInstall() { @Override public void onThemeColorChanged(int color, boolean shouldAnimate) { + ApiCompatibilityUtils.setImageTintList(mWalletIcon, + !ColorUtils.shouldUseLightForegroundOnBackground(color) ? mDarkModeTint + : mLightModeTint); + final int textBoxColor = ThemeUtils.getTextBoxColorForToolbarBackgroundInNonNativePage( getContext(), color, isIncognito()); updateModernLocationBarColorImpl(textBoxColor);