Skip to content

Commit b401cbe

Browse files
committed
feat: added popup notif to confirm patching
1 parent 91ab98f commit b401cbe

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

extensions/extension/src/main/java/app/revanced/extension/customfilters/TintFieldHook.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
package app.revanced.extension.customfilters;
22

3+
import android.content.Context;
4+
import android.os.Handler;
5+
import android.os.Looper;
6+
import android.widget.Toast;
7+
38
import java.lang.reflect.Constructor;
49
import java.lang.reflect.Method;
510

611
public class TintFieldHook {
712
public static void installTintField(Object table) {
813
try {
14+
// Try to show a toast first — to confirm the hook actually runs
15+
showToast("Custom filter hook triggered ✅");
16+
917
ClassLoader cl = table.getClass().getClassLoader();
1018

1119
Class<?> appClass = Class.forName("org.fortheloss.sticknodes.App", false, cl);
@@ -39,8 +47,38 @@ public static void installTintField(Object table) {
3947
Method setValue = labelFieldClass.getMethod("setValue", colorClass);
4048
setValue.invoke(field, whiteColor);
4149

50+
System.out.println("[CustomFilters] Tint field added successfully!");
51+
4252
} catch (Throwable t) {
4353
t.printStackTrace();
54+
showToast("❌ Custom filter hook failed: " + t.getClass().getSimpleName());
55+
}
56+
}
57+
58+
// Show Toast using main thread
59+
private static void showToast(String message) {
60+
try {
61+
Context context = getAppContext();
62+
if (context == null) {
63+
System.out.println("[CustomFilters] No context available for Toast");
64+
return;
65+
}
66+
67+
new Handler(Looper.getMainLooper()).post(() ->
68+
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
69+
);
70+
} catch (Throwable ignored) {
71+
}
72+
}
73+
74+
// Universal app context getter
75+
private static Context getAppContext() {
76+
try {
77+
Class<?> activityThread = Class.forName("android.app.ActivityThread");
78+
Object currentActivityThread = activityThread.getMethod("currentActivityThread").invoke(null);
79+
return (Context) activityThread.getMethod("getApplication").invoke(currentActivityThread);
80+
} catch (Throwable ignored) {
81+
return null;
4482
}
4583
}
4684
}

0 commit comments

Comments
 (0)