Skip to content

Commit 38db657

Browse files
committed
Fix bug on change navigation bar transparency
1 parent 301c34c commit 38db657

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

app/src/main/java/com/wmods/wppenhacer/utils/ColorReplacement.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@
1010
import android.widget.TextView;
1111

1212
import com.wmods.wppenhacer.xposed.utils.DesignUtils;
13+
import com.wmods.wppenhacer.xposed.utils.Utils;
1314

1415
import java.util.HashMap;
1516

1617
import de.robv.android.xposed.XposedHelpers;
1718

1819
public class ColorReplacement {
1920
public static void replaceColors(View view, HashMap<String, String> colors) {
21+
if (view == null) return;
22+
if (view.getId() == Utils.getID("bottom_nav", "id")) return;
2023
if (view instanceof ImageView imageView) {
21-
Image.replace(imageView,colors);
24+
Image.replace(imageView, colors);
2225
} else if (view instanceof TextView textView) {
2326
Text.replace(textView, colors);
2427
} else if (view instanceof ViewGroup viewGroup) {
25-
Group.replace(viewGroup,colors);
28+
Group.replace(viewGroup, colors);
2629
} else if (view instanceof ViewStub viewStub) {
2730
replaceColor(viewStub.getBackground(), colors);
2831
}

app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomThemeV2.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.wmods.wppenhacer.xposed.features.customization;
22

33
import static com.wmods.wppenhacer.utils.ColorReplacement.replaceColors;
4+
import static com.wmods.wppenhacer.utils.DrawableColors.replaceColor;
45
import static com.wmods.wppenhacer.utils.IColors.alphacolors;
56
import static com.wmods.wppenhacer.utils.IColors.backgroundColors;
67
import static com.wmods.wppenhacer.utils.IColors.primaryColors;
@@ -24,7 +25,6 @@
2425
import androidx.annotation.NonNull;
2526
import androidx.core.content.ContextCompat;
2627

27-
import com.wmods.wppenhacer.utils.DrawableColors;
2828
import com.wmods.wppenhacer.utils.IColors;
2929
import com.wmods.wppenhacer.views.WallpaperView;
3030
import com.wmods.wppenhacer.xposed.core.Feature;
@@ -34,7 +34,6 @@
3434
import com.wmods.wppenhacer.xposed.utils.ReflectionUtils;
3535
import com.wmods.wppenhacer.xposed.utils.Utils;
3636

37-
import java.lang.reflect.Method;
3837
import java.util.HashMap;
3938
import java.util.Objects;
4039
import java.util.Properties;
@@ -62,8 +61,8 @@ private static void processColors(String color, HashMap<String, String> mapColor
6261
if (color.length() == 7) { // #RRGGBB
6362
inputColorFull = "#ff" + color.substring(1);
6463
} else if (color.length() == 9) { // #AARRGGBB
65-
// Base the color on input, but force FF alpha
66-
inputColorFull = "#ff" + color.substring(3);
64+
// Base the color on input, but force FF alpha
65+
inputColorFull = "#ff" + color.substring(3);
6766
} else {
6867
// Invalid format, ignore
6968
return;
@@ -209,15 +208,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
209208
var viewGroup = (ViewGroup) param.thisObject;
210209
if (checkNotHomeActivity()) return;
211210
var background = viewGroup.getBackground();
212-
try {
213-
var colorfilters = XposedHelpers.getObjectField(background, "A01");
214-
var fields = ReflectionUtils.getFieldsByType(colorfilters.getClass(), ColorStateList.class);
215-
var colorStateList = (ColorStateList) fields.get(0).get(colorfilters);
216-
var newColor = IColors.getFromIntColor(colorStateList.getDefaultColor(), navAlpha);
217-
if (newColor == colorStateList.getDefaultColor()) return;
218-
background.setTint(newColor);
219-
} catch (Throwable ignored) {
220-
}
211+
replaceColor(background, navAlpha);
221212
}
222213
});
223214

@@ -247,7 +238,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
247238
@Override
248239
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
249240
var drawable = (Drawable) param.getResult();
250-
DrawableColors.replaceColor(drawable, IColors.colors);
241+
replaceColor(drawable, IColors.colors);
251242
}
252243
});
253244

0 commit comments

Comments
 (0)