33import android .content .res .ColorStateList ;
44import android .graphics .Bitmap ;
55import android .graphics .NinePatch ;
6- import android .graphics .PorterDuff ;
7- import android .graphics .PorterDuffColorFilter ;
8- import android .graphics .drawable .ClipDrawable ;
96import android .graphics .drawable .ColorDrawable ;
107import android .graphics .drawable .Drawable ;
118import android .graphics .drawable .DrawableContainer ;
9+ import android .graphics .drawable .DrawableWrapper ;
1210import android .graphics .drawable .GradientDrawable ;
1311import android .graphics .drawable .InsetDrawable ;
1412import android .graphics .drawable .LayerDrawable ;
1513import android .graphics .drawable .LevelListDrawable ;
1614import android .graphics .drawable .NinePatchDrawable ;
1715import android .graphics .drawable .RippleDrawable ;
18- import android .graphics .drawable .RotateDrawable ;
19- import android .graphics .drawable .ScaleDrawable ;
2016import android .graphics .drawable .ShapeDrawable ;
2117import android .graphics .drawable .StateListDrawable ;
2218import android .graphics .drawable .TransitionDrawable ;
2319
24- import com .wmods .wppenhacer .xposed .utils .DesignUtils ;
25-
2620import java .util .HashMap ;
2721
2822import de .robv .android .xposed .XposedBridge ;
@@ -35,10 +29,6 @@ public class DrawableColors {
3529 public static void replaceColor (Drawable drawable , HashMap <String , String > colors ) {
3630 if (drawable == null ) return ;
3731
38- if (DesignUtils .isNightMode ()) {
39- colors .remove ("#ffffffff" );
40- }
41-
4232 if (drawable instanceof StateListDrawable stateListDrawable ) {
4333 var count = StateListDrawableCompact .getStateCount (stateListDrawable );
4434 for (int i = 0 ; i < count ; i ++) {
@@ -57,43 +47,23 @@ public static void replaceColor(Drawable drawable, HashMap<String, String> color
5747 }
5848 gradientDrawable .setColors (gradientColors );
5949 }
60- } else if (drawable instanceof InsetDrawable insetDrawable ) {
61- replaceColor (insetDrawable .getDrawable (), colors );
50+ } else if (drawable instanceof DrawableWrapper drawableWrapper ) {
51+ replaceColor (drawableWrapper .getDrawable (), colors );
6252 } else if (drawable instanceof NinePatchDrawable ninePatchDrawable ) {
6353 var color = getNinePatchDrawableColor (ninePatchDrawable );
6454 var newColor = IColors .getFromIntColor (color , colors );
6555 if (color == newColor ) return ;
6656 ninePatchDrawable .setTintList (ColorStateList .valueOf (newColor ));
6757 } else if (drawable instanceof ColorDrawable colorDrawable ) {
6858 var color = getColorDrawableColor (colorDrawable );
69- colorDrawable .setColor (IColors .getFromIntColor (color , colors ));
59+ var newColor = IColors .getFromIntColor (color , colors );
60+ if (newColor == color ) return ;
61+ colorDrawable .setColor (newColor );
7062 } else if (drawable instanceof ShapeDrawable shapeDrawable ) {
7163 var color = getShapeDrawableColor (shapeDrawable );
7264 var newColor = IColors .getFromIntColor (color , colors );
7365 if (color == newColor ) return ;
7466 shapeDrawable .getPaint ().setColor (newColor );
75- } else if (drawable instanceof RippleDrawable rippleDrawable ) {
76- var color = getRippleDrawableColor (rippleDrawable );
77- var newColor = IColors .getFromIntColor (color , colors );
78- if (color == newColor ) return ;
79- rippleDrawable .setColor (ColorStateList .valueOf (newColor ));
80-
81- // Also handle the content and mask drawables of the ripple
82- Drawable contentDrawable = rippleDrawable .getDrawable (0 );
83- if (contentDrawable != null ) {
84- replaceColor (contentDrawable , colors );
85- }
86-
87- Drawable maskDrawable = rippleDrawable .getDrawable (1 );
88- if (maskDrawable != null ) {
89- replaceColor (maskDrawable , colors );
90- }
91- } else if (drawable instanceof ClipDrawable clipDrawable ) {
92- replaceColor (clipDrawable .getDrawable (), colors );
93- } else if (drawable instanceof RotateDrawable rotateDrawable ) {
94- replaceColor (rotateDrawable .getDrawable (), colors );
95- } else if (drawable instanceof ScaleDrawable scaleDrawable ) {
96- replaceColor (scaleDrawable .getDrawable (), colors );
9767 } else if (drawable instanceof LevelListDrawable levelListDrawable ) {
9868 int count = (int ) XposedHelpers .callMethod (levelListDrawable , "getNumberOfLevels" );
9969 for (int i = 0 ; i < count ; i ++) {
@@ -125,13 +95,7 @@ public static void replaceColor(Drawable drawable, HashMap<String, String> color
12595 for (var drawable1 : drawables ) {
12696 replaceColor (drawable1 , colors );
12797 }
128- } else {
129- var color = getColor (drawable );
130- var newColor = IColors .getFromIntColor (color , colors );
131- if (color == newColor ) return ;
132- drawable .setColorFilter (new PorterDuffColorFilter (newColor , PorterDuff .Mode .SRC_IN ));
13398 }
134-
13599 }
136100
137101 public static int getColor (Drawable drawable ) {
0 commit comments