183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar/* 283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * Copyright (C) 2014 The Android Open Source Project 383b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * 483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * Licensed under the Apache License, Version 2.0 (the "License"); 583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * you may not use this file except in compliance with the License. 683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * You may obtain a copy of the License at 783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * 883b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * http://www.apache.org/licenses/LICENSE-2.0 983b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * 1083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * Unless required by applicable law or agreed to in writing, software 1183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * distributed under the License is distributed on an "AS IS" BASIS, 1283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1383b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * See the License for the specific language governing permissions and 1483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * limitations under the License. 1583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar */ 1683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarpackage android.support.v7.widget; 1783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 18b7adf5d2ae19bc616c2d040a667ac1de3769f423Aurimas Liutikasimport static android.support.v7.widget.RoundRectDrawableWithShadow.calculateHorizontalPadding; 19b7adf5d2ae19bc616c2d040a667ac1de3769f423Aurimas Liutikasimport static android.support.v7.widget.RoundRectDrawableWithShadow.calculateVerticalPadding; 20b7adf5d2ae19bc616c2d040a667ac1de3769f423Aurimas Liutikas 21104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banesimport android.content.res.ColorStateList; 2283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.Canvas; 23104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banesimport android.graphics.Color; 2483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.ColorFilter; 2583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.Outline; 2683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.Paint; 2783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.PixelFormat; 28104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banesimport android.graphics.PorterDuff; 29104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banesimport android.graphics.PorterDuffColorFilter; 3083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.Rect; 3183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.RectF; 3283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarimport android.graphics.drawable.Drawable; 33d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikasimport android.support.annotation.Nullable; 348f886fe8c7e23fe6ccb8734167c960c2ed3429c3Alan Viveretteimport android.support.annotation.RequiresApi; 3583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 3683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar/** 3783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * Very simple drawable that draws a rounded rectangle background with arbitrary corners and also 38104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes * reports proper outline for Lollipop. 3983b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * <p> 4083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar * Simpler and uses less resources compared to GradientDrawable or ShapeDrawable. 4183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar */ 428f886fe8c7e23fe6ccb8734167c960c2ed3429c3Alan Viverette@RequiresApi(21) 4383b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyarclass RoundRectDrawable extends Drawable { 44bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private float mRadius; 45bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private final Paint mPaint; 46bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private final RectF mBoundsF; 47bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private final Rect mBoundsI; 48bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private float mPadding; 49bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private boolean mInsetForPadding = false; 50c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar private boolean mInsetForRadius = true; 5183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 52d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas private ColorStateList mBackground; 53104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes private PorterDuffColorFilter mTintFilter; 54104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes private ColorStateList mTint; 55ffbf42aa3acb41b82cc6c1226c63c3649bedfe49Chris Banes private PorterDuff.Mode mTintMode = PorterDuff.Mode.SRC_IN; 56104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 57b7adf5d2ae19bc616c2d040a667ac1de3769f423Aurimas Liutikas RoundRectDrawable(ColorStateList backgroundColor, float radius) { 5883b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar mRadius = radius; 5983b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); 60d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas setBackground(backgroundColor); 61d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas 62bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mBoundsF = new RectF(); 63bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mBoundsI = new Rect(); 64bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar } 65bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar 66d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas private void setBackground(ColorStateList color) { 67d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas mBackground = (color == null) ? ColorStateList.valueOf(Color.TRANSPARENT) : color; 68d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas mPaint.setColor(mBackground.getColorForState(getState(), mBackground.getDefaultColor())); 69d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas } 70d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas 71c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar void setPadding(float padding, boolean insetForPadding, boolean insetForRadius) { 72b7adf5d2ae19bc616c2d040a667ac1de3769f423Aurimas Liutikas if (padding == mPadding && mInsetForPadding == insetForPadding 73b7adf5d2ae19bc616c2d040a667ac1de3769f423Aurimas Liutikas && mInsetForRadius == insetForRadius) { 74bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar return; 75bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar } 76bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mPadding = padding; 77bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mInsetForPadding = insetForPadding; 78c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar mInsetForRadius = insetForRadius; 79bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar updateBounds(null); 80bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar invalidateSelf(); 81bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar } 82bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar 83bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar float getPadding() { 84bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar return mPadding; 8583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 8683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 8783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar @Override 8883b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar public void draw(Canvas canvas) { 89104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes final Paint paint = mPaint; 90104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 91104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes final boolean clearColorFilter; 92104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes if (mTintFilter != null && paint.getColorFilter() == null) { 93104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes paint.setColorFilter(mTintFilter); 94104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes clearColorFilter = true; 95104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } else { 96104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes clearColorFilter = false; 97104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 98104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 99104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes canvas.drawRoundRect(mBoundsF, mRadius, mRadius, paint); 100104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 101104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes if (clearColorFilter) { 102104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes paint.setColorFilter(null); 103104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 104bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar } 105bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar 106bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar private void updateBounds(Rect bounds) { 107bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar if (bounds == null) { 108bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar bounds = getBounds(); 109bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar } 110bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mBoundsF.set(bounds.left, bounds.top, bounds.right, bounds.bottom); 111bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mBoundsI.set(bounds); 112bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar if (mInsetForPadding) { 113c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar float vInset = calculateVerticalPadding(mPadding, mRadius, mInsetForRadius); 114c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar float hInset = calculateHorizontalPadding(mPadding, mRadius, mInsetForRadius); 115bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar mBoundsI.inset((int) Math.ceil(hInset), (int) Math.ceil(vInset)); 116c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar // to make sure they have same bounds. 117c42ba8c000d1e6ce85e152dfc17089a0a69e739fYigit Boyar mBoundsF.set(mBoundsI); 118bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar } 11983b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 12083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 12183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar @Override 12283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar protected void onBoundsChange(Rect bounds) { 12383b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar super.onBoundsChange(bounds); 124bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar updateBounds(bounds); 12583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 12683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 12783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar @Override 128bf43be6ab14db8489f924d1673951f0c49014605Chris Craik public void getOutline(Outline outline) { 129bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar outline.setRoundRect(mBoundsI, mRadius); 13083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 13183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 132bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar void setRadius(float radius) { 13383b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar if (radius == mRadius) { 13483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar return; 13583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 13683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar mRadius = radius; 137bdb07a1802c017efa64a5cfd8ab5a7ff4c4926b0Yigit Boyar updateBounds(null); 13883b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar invalidateSelf(); 13983b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 14083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 14183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar @Override 14283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar public void setAlpha(int alpha) { 143104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mPaint.setAlpha(alpha); 14483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 14583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 14683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar @Override 14783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar public void setColorFilter(ColorFilter cf) { 148104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mPaint.setColorFilter(cf); 14983b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 15083b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 15183b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar @Override 15283b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar public int getOpacity() { 153ad124ea5fa71f1b675c9c42b858adfbc42093d37Yigit Boyar return PixelFormat.TRANSLUCENT; 15483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 15583b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar 15683b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar public float getRadius() { 15783b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar return mRadius; 15883b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar } 1594eb77f0ed24a9d300f7d12959de8cf7efd837e2fYigit Boyar 160d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas public void setColor(@Nullable ColorStateList color) { 161d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas setBackground(color); 1624eb77f0ed24a9d300f7d12959de8cf7efd837e2fYigit Boyar invalidateSelf(); 1634eb77f0ed24a9d300f7d12959de8cf7efd837e2fYigit Boyar } 164104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 165e7c701f05b4f6afa2913c3743638d7b25b96df83Aurimas Liutikas public ColorStateList getColor() { 166e7c701f05b4f6afa2913c3743638d7b25b96df83Aurimas Liutikas return mBackground; 167e7c701f05b4f6afa2913c3743638d7b25b96df83Aurimas Liutikas } 168e7c701f05b4f6afa2913c3743638d7b25b96df83Aurimas Liutikas 169104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes @Override 170104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes public void setTintList(ColorStateList tint) { 171104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mTint = tint; 172104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mTintFilter = createTintFilter(mTint, mTintMode); 173104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes invalidateSelf(); 174104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 175104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 176104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes @Override 177104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes public void setTintMode(PorterDuff.Mode tintMode) { 178104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mTintMode = tintMode; 179104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mTintFilter = createTintFilter(mTint, mTintMode); 180104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes invalidateSelf(); 181104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 182104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 183104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes @Override 184104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes protected boolean onStateChange(int[] stateSet) { 185d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas final int newColor = mBackground.getColorForState(stateSet, mBackground.getDefaultColor()); 186d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas final boolean colorChanged = newColor != mPaint.getColor(); 187d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas if (colorChanged) { 188d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas mPaint.setColor(newColor); 189d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas } 190104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes if (mTint != null && mTintMode != null) { 191104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes mTintFilter = createTintFilter(mTint, mTintMode); 192104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes return true; 193104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 194d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas return colorChanged; 195104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 196104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 197104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes @Override 198104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes public boolean isStateful() { 199d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas return (mTint != null && mTint.isStateful()) 200d2c60296856244030e9a92ef3065d3884ac67527Aurimas Liutikas || (mBackground != null && mBackground.isStateful()) || super.isStateful(); 201104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 202104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes 203104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes /** 204104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes * Ensures the tint filter is consistent with the current tint color and 205104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes * mode. 206104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes */ 207104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes private PorterDuffColorFilter createTintFilter(ColorStateList tint, PorterDuff.Mode tintMode) { 208104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes if (tint == null || tintMode == null) { 209104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes return null; 210104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 211104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes final int color = tint.getColorForState(getState(), Color.TRANSPARENT); 212104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes return new PorterDuffColorFilter(color, tintMode); 213104ba18fc93b6b6d98bf1ef56e6f3febe4a4fb90Chris Banes } 21483b8526436ba2e564dff99ec4c6cf46fabfdf22eYigit Boyar} 215