| Index: chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageButton.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageButton.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageButton.java
|
| index 8d848e0507a4bf05d3f597a899eeccc785158832..3678694825638bd0d8d2f6c1d73216dbc7819424 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageButton.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageButton.java
|
| @@ -6,63 +6,45 @@ package org.chromium.chrome.browser.widget;
|
|
|
| import android.content.Context;
|
| import android.content.res.ColorStateList;
|
| -import android.content.res.TypedArray;
|
| -import android.graphics.PorterDuff;
|
| +import android.graphics.Canvas;
|
| import android.util.AttributeSet;
|
| import android.widget.ImageButton;
|
|
|
| -import org.chromium.chrome.R;
|
| +import org.chromium.chrome.browser.widget.ImageViewTinter.ImageViewTinterOwner;
|
|
|
| /**
|
| - * Implementation of ImageButton that allows to tint the color of the image button for all
|
| - * image button states using chrome:chrometint attribute in XML.
|
| + * Implementation of ImageButton that allows tinting the Drawable for all states.
|
| + * For usage, see {@link ImageViewTinter}.
|
| */
|
| -public class TintedImageButton extends ImageButton {
|
| - private ColorStateList mTint;
|
| +public class TintedImageButton extends ImageButton implements ImageViewTinterOwner {
|
| + private ImageViewTinter mTinter;
|
|
|
| public TintedImageButton(Context context) {
|
| - super(context);
|
| + this(context, null);
|
| }
|
|
|
| public TintedImageButton(Context context, AttributeSet attrs) {
|
| - super(context, attrs);
|
| - init(context, attrs, 0);
|
| + this(context, attrs, 0);
|
| }
|
|
|
| public TintedImageButton(Context context, AttributeSet attrs, int defStyle) {
|
| super(context, attrs, defStyle);
|
| - init(context, attrs, defStyle);
|
| - }
|
| -
|
| - private void init(Context context, AttributeSet attrs, int defStyle) {
|
| - TypedArray a = context.obtainStyledAttributes(
|
| - attrs, R.styleable.TintedImage, defStyle, 0);
|
| - setTintInternal(a.getColorStateList(R.styleable.TintedImage_chrometint));
|
| - a.recycle();
|
| + mTinter = new ImageViewTinter(this, attrs, defStyle);
|
| }
|
|
|
| @Override
|
| - protected void drawableStateChanged() {
|
| + public void drawableStateChanged() {
|
| super.drawableStateChanged();
|
| - updateTintColor();
|
| - }
|
| -
|
| - /**
|
| - * Sets the tint color for the given ImageButton for all button states.
|
| - * @param tint The set of colors to use to color the ImageButton.
|
| - */
|
| - public void setTint(ColorStateList tint) {
|
| - if (mTint == tint) return;
|
| - setTintInternal(tint);
|
| - updateTintColor();
|
| + mTinter.drawableStateChanged();
|
| }
|
|
|
| - private void setTintInternal(ColorStateList tint) {
|
| - mTint = tint;
|
| + @Override
|
| + public void setTint(ColorStateList tintList) {
|
| + mTinter.setTint(tintList);
|
| }
|
|
|
| - private void updateTintColor() {
|
| - if (mTint == null) return;
|
| - setColorFilter(mTint.getColorForState(getDrawableState(), 0), PorterDuff.Mode.SRC_IN);
|
| + @Override
|
| + public void onDraw(Canvas canvas) {
|
| + super.onDraw(canvas);
|
| }
|
| }
|
|
|