fix(wallet): change wallet icon color per website theme

This commit is contained in:
Pavneet-Sing
2022-06-24 16:29:00 +05:30
parent fdfc0c92f2
commit 2380da3877
@@ -13,6 +13,7 @@ import android.app.Dialog;
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.components.user_prefs.UserPrefs;
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<Integer> mTabsWithWalletIcon =
Collections.synchronizedSet(new HashSet<Integer>());
@@ -226,6 +232,11 @@ public abstract class BraveToolbarLayoutImpl extends ToolbarLayout
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 @@ public abstract class BraveToolbarLayoutImpl extends ToolbarLayout
@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);