Commit 6e7ba7a6 authored by Jing-wei Wu's avatar Jing-wei Wu
Browse files

Bug 1400164 - Part 2: Tint close button manually when checked status is changed. r=nechen

Because without implementing 'Checkable' interface, ThemedImageButton doesn't refresh its
drawable when the 'checked' status is changed.

We have to tint the drawable and set into the view manually.

MozReview-Commit-ID: CDYUxOZkn60

--HG--
extra : rebase_source : a98bf72df25a85f0e9fec32a0d0d4277580e3784
parent 0352c3f4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -15,8 +15,12 @@ import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
import org.mozilla.gecko.widget.themed.ThemedTextView;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.widget.TextViewCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -112,6 +116,13 @@ public class TabStripItemView extends ThemedLinearLayout

        this.checked = checked;
        refreshDrawableState();

        // Tint the close view based on current checked status.
        final ColorStateList colorStateList = closeView.getDrawableColors();
        final int tintColor = colorStateList.getColorForState(getDrawableState(), Color.TRANSPARENT);
        final Drawable drawable = DrawableCompat.wrap(closeView.getDrawable());
        DrawableCompat.setTint(drawable, tintColor);
        closeView.setImageDrawable(drawable);
    }

    @Override