| Index: chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageView.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageView.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageView.java
|
| index 96bb9a29f639d7304be5ef0de5fd5da332bfeb87..02713e0bee6a3381c1902be3282d8ec7489c2d3d 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageView.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/TintedImageView.java
|
| @@ -6,66 +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.support.v7.widget.AppCompatImageView;
|
| import android.util.AttributeSet;
|
|
|
| -import org.chromium.chrome.R;
|
| +import org.chromium.chrome.browser.widget.ImageViewTinter.ImageViewTinterOwner;
|
|
|
| /**
|
| - * Implementation of ImageView that allows to tint the color of the image view for all
|
| - * image view states using chrome:chrometint attribute in XML.
|
| + * Implementation of ImageView that allows tinting its Drawable for all states.
|
| + * For usage, see {@link ImageViewTinter}.
|
| */
|
| -public class TintedImageView extends AppCompatImageView {
|
| - private ColorStateList mTint;
|
| +public class TintedImageView extends AppCompatImageView implements ImageViewTinterOwner {
|
| + private ImageViewTinter mTinter;
|
|
|
| public TintedImageView(Context context) {
|
| - super(context);
|
| + this(context, null);
|
| }
|
|
|
| public TintedImageView(Context context, AttributeSet attrs) {
|
| - super(context, attrs);
|
| - init(context, attrs, 0);
|
| + this(context, attrs, 0);
|
| }
|
|
|
| public TintedImageView(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 ImageView for all view states.
|
| - * @param tint The set of colors to use to color the ImageView.
|
| - */
|
| - 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) {
|
| - clearColorFilter();
|
| - return;
|
| - }
|
| - setColorFilter(mTint.getColorForState(getDrawableState(), 0), PorterDuff.Mode.SRC_IN);
|
| + @Override
|
| + public void onDraw(Canvas canvas) {
|
| + super.onDraw(canvas);
|
| }
|
| }
|
|
|