Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Avoid tinting the profile icon for FxA honeycomb (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and bluemarvin committed Nov 20, 2019
1 parent 1846765 commit 6e42b71
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand All @@ -33,6 +32,7 @@ public class HoneycombButton extends LinearLayout {
private float mButtonTextSize;
private String mSecondaryButtonText;
private Drawable mButtonIcon;
private boolean mButtonIconHover;

public HoneycombButton(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.style.honeycombButtonTheme);
Expand All @@ -44,6 +44,7 @@ public HoneycombButton(Context context, @Nullable AttributeSet attrs, int defSty
mButtonText = attributes.getString(R.styleable.HoneycombButton_honeycombButtonText);
mButtonTextSize = attributes.getDimension(R.styleable.HoneycombButton_honeycombButtonTextSize, 0.0f);
mButtonIcon = attributes.getDrawable(R.styleable.HoneycombButton_honeycombButtonIcon);
mButtonIconHover = attributes.getBoolean(R.styleable.HoneycombButton_honeycombButtonIconHover, true);

String iconIdStr = attributes.getString(R.styleable.HoneycombButton_honeycombButtonIcon);
int deviceTypeId = DeviceType.getType();
Expand Down Expand Up @@ -123,14 +124,18 @@ public void setOnHoverListener(final OnHoverListener l) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_HOVER_ENTER:
if (mIcon != null && mText != null) {
mIcon.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.asphalt, getContext().getTheme()), PorterDuff.Mode.MULTIPLY));
if (mButtonIconHover) {
mIcon.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.asphalt, getContext().getTheme()), PorterDuff.Mode.MULTIPLY));
}
mText.setTextColor(getContext().getColor(R.color.asphalt));
mSecondaryText.setTextColor(getContext().getColor(R.color.asphalt));
}
break;
case MotionEvent.ACTION_HOVER_EXIT:
if (mIcon != null && mText != null) {
mIcon.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.fog, getContext().getTheme()), PorterDuff.Mode.MULTIPLY));
if (mButtonIconHover) {
mIcon.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.fog, getContext().getTheme()), PorterDuff.Mode.MULTIPLY));
}
mText.setTextColor(getContext().getColor(R.color.fog));
mSecondaryText.setTextColor(getContext().getColor(R.color.fog));
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@
style="?attr/honeycombButtonStyle"
app:honeycombButtonIcon="@drawable/ic_icon_settings_account"
app:honeycombButtonText="@string/settings_fxa_account_sign_in"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width"
app:honeycombButtonIconHover="false"/>

</LinearLayout>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<attr name="honeycombButtonText" format="string" />
<attr name="honeycombButtonTextSize" format="dimension" />
<attr name="honeycombSecondaryText" format="string" />
<attr name="honeycombButtonIconHover" format="boolean" />
</declare-styleable>

<declare-styleable name="HoneycombSwitch">
Expand Down

0 comments on commit 6e42b71

Please sign in to comment.