Skip to content

Commit ae220bb

Browse files
committed
Fix bugs in Custom Theme V2
Signed-off-by: Dev4Mod <[email protected]>
1 parent 50fd03b commit ae220bb

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import java.util.HashMap;
1515

16-
import de.robv.android.xposed.XposedBridge;
1716
import de.robv.android.xposed.XposedHelpers;
1817

1918
public class ColorReplacement {
@@ -63,14 +62,12 @@ static void replace(TextView view, HashMap<String, String> colors) {
6362
var newColor = colors.get(sColor);
6463
if (newColor != null) {
6564
view.setTextColor(IColors.parseColor(newColor));
66-
XposedBridge.log("ColorReplacement.Text.replace: " + sColor + "->" + newColor);
6765
} else {
6866
if (!sColor.startsWith("#ff") && !sColor.startsWith("#0")) {
6967
var sColorSub = sColor.substring(0, 3);
7068
newColor = colors.get(sColor.substring(3));
7169
if (newColor != null) {
7270
view.setTextColor(IColors.parseColor(sColorSub + newColor));
73-
XposedBridge.log("ColorReplacement.Text.replace: " + sColor + "->" + newColor);
7471
}
7572
}
7673
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public static String toString(int i) {
5555
var color = Integer.toHexString(i);
5656
if (color.length() == 7) {
5757
color = "0" + color;
58+
} else if (color.length() == 1) {
59+
color = "00000000";
5860
}
5961
return "#" + color;
6062
}

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,20 @@ private boolean checkNotHomeActivity() {
280280
return (currentActivity == null || !homeClass.isInstance(currentActivity));
281281
}
282282

283+
private static int getOriginalColor(String sColor) {
284+
var colors = IColors.colors.keySet();
285+
var resultColor = -1;
286+
for (var c : colors) {
287+
var vColor = IColors.colors.getOrDefault(c, "");
288+
if (vColor.length() < 9) continue;
289+
if (sColor.equals(vColor)) {
290+
resultColor = IColors.parseColor(c);
291+
break;
292+
}
293+
}
294+
return resultColor;
295+
}
296+
283297
public static class IntBgColorHook extends XC_MethodHook {
284298

285299

@@ -295,15 +309,12 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
295309
return;
296310
}
297311
} else if (param.thisObject instanceof Paint) {
298-
if (ReflectionUtils.isCalledFromStrings("getValue")) {
299-
var colors = IColors.colors.keySet();
300-
for (var c : colors) {
301-
var vColor = IColors.colors.getOrDefault(c, "");
302-
if (vColor.length() < 9) continue;
303-
if (sColor.equals(vColor)) {
304-
param.args[0] = IColors.parseColor(c);
305-
return;
306-
}
312+
if (ReflectionUtils.isCalledFromStrings("getValue") && !ReflectionUtils.isCalledFromStrings("android.view")) {
313+
XposedBridge.log(new Exception());
314+
var resultColor = getOriginalColor(sColor);
315+
if (resultColor != -1) {
316+
param.args[0] = resultColor;
317+
return;
307318
}
308319
}
309320
}

0 commit comments

Comments
 (0)