Update DrawableWrapper to DrawableWrapperCompat

Api changed in aosp/2120177

Bug: 235727273
Test: TAP
Change-Id: I1645dab6000dc760b4de2bb625e0af8df014c8c8
This commit is contained in:
Chaohui Wang
2022-09-15 02:21:58 +00:00
committed by Anvesh Renikindi
parent af083023d7
commit f648675fab
2 changed files with 6 additions and 6 deletions
@@ -21,7 +21,7 @@ import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.appcompat.graphics.drawable.DrawableWrapper; import androidx.appcompat.graphics.drawable.DrawableWrapperCompat;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import android.util.TypedValue; import android.util.TypedValue;
@@ -53,8 +53,8 @@ public class SwitchCompatUtils {
private static Drawable getColorTintedDrawable(Drawable oldDrawable, private static Drawable getColorTintedDrawable(Drawable oldDrawable,
final ColorStateList colorStateList, final PorterDuff.Mode mode) { final ColorStateList colorStateList, final PorterDuff.Mode mode) {
final int[] thumbState = oldDrawable.isStateful() ? oldDrawable.getState() : null; final int[] thumbState = oldDrawable.isStateful() ? oldDrawable.getState() : null;
if (oldDrawable instanceof DrawableWrapper) { if (oldDrawable instanceof DrawableWrapperCompat) {
oldDrawable = ((DrawableWrapper) oldDrawable).getWrappedDrawable(); oldDrawable = ((DrawableWrapperCompat) oldDrawable).getDrawable();
} }
final Drawable newDrawable = new TintDrawableWrapper(oldDrawable, colorStateList, mode); final Drawable newDrawable = new TintDrawableWrapper(oldDrawable, colorStateList, mode);
if (thumbState != null) { if (thumbState != null) {
@@ -20,16 +20,16 @@ import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.appcompat.graphics.drawable.DrawableWrapper; import androidx.appcompat.graphics.drawable.DrawableWrapperCompat;
/* /*
* This is directly copied from v7/appcompat/src/androidx.appcompat.internal/widget/TintManager.java * This is directly copied from v7/appcompat/src/androidx.appcompat.internal/widget/TintManager.java
*/ */
/** /**
* A {@link DrawableWrapper} which updates it's color filter using a {@link ColorStateList}. * A {@link DrawableWrapperCompat} which updates it's color filter using a {@link ColorStateList}.
*/ */
class TintDrawableWrapper extends DrawableWrapper { class TintDrawableWrapper extends DrawableWrapperCompat {
private final ColorStateList mTintStateList; private final ColorStateList mTintStateList;
private final PorterDuff.Mode mTintMode; private final PorterDuff.Mode mTintMode;
private int mCurrentColor; private int mCurrentColor;