Skip to content

Commit 896ec5a

Browse files
committed
feat: d
1 parent 9648693 commit 896ec5a

1 file changed

Lines changed: 49 additions & 17 deletions

File tree

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

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,28 +190,60 @@ public static void installCustomTintSlot(Object table) {
190190
filtersSubTableField.setAccessible(true);
191191
Object filtersSubTable = filtersSubTableField.get(table);
192192

193-
// FIX: Use Actor class instead of Object for the add method
194-
Method tableAdd = tableClass.getMethod("add", actorClass); // Changed Object.class to actorClass
195-
Object cell = tableAdd.invoke(filtersSubTable, fieldInstance);
196-
197-
// Configure Cell layout: colspan(2).fillX()
193+
// FIX: Try different method signatures for Table.add
194+
Method tableAdd = null;
198195
try {
199-
Method colspan = cellClass.getMethod("colspan", int.class);
200-
Object cellAfterColspan = colspan.invoke(cell, 2);
201-
202-
Method fillX = cellClass.getMethod("fillX");
203-
fillX.invoke(cellAfterColspan);
204-
205-
Log.i(TAG, "✓ Cell configured (colspan=2, fillX)");
196+
// First try: add(Actor)
197+
tableAdd = tableClass.getMethod("add", actorClass);
198+
Log.i(TAG, "✓ Found Table.add(Actor) method");
206199
} catch (NoSuchMethodException e) {
207-
Log.w(TAG, "Could not configure Cell layout: " + e.getMessage());
200+
Log.w(TAG, "✗ Table.add(Actor) not found, trying alternatives...");
201+
202+
// Try: add(Actor) with getDeclaredMethod
203+
try {
204+
tableAdd = tableClass.getDeclaredMethod("add", actorClass);
205+
tableAdd.setAccessible(true);
206+
Log.i(TAG, "✓ Found Table.add(Actor) via getDeclaredMethod");
207+
} catch (NoSuchMethodException e2) {
208+
Log.w(TAG, "✗ Table.add(Actor) not found with getDeclaredMethod");
209+
210+
// Last resort: Try to find any add method that takes one parameter
211+
Method[] methods = tableClass.getMethods();
212+
for (Method method : methods) {
213+
if (method.getName().equals("add") && method.getParameterTypes().length == 1) {
214+
tableAdd = method;
215+
Log.i(TAG, "✓ Found compatible Table.add method: " + method);
216+
break;
217+
}
218+
}
219+
}
208220
}
209221

210-
// Add row separator
211-
Method tableRow = tableClass.getMethod("row");
212-
tableRow.invoke(filtersSubTable);
222+
if (tableAdd != null) {
223+
Object cell = tableAdd.invoke(filtersSubTable, fieldInstance);
224+
Log.i(TAG, "✓ Field added to table, got cell: " + (cell != null ? cell.getClass().getSimpleName() : "null"));
225+
226+
// Configure Cell layout: colspan(2).fillX()
227+
try {
228+
Method colspan = cellClass.getMethod("colspan", int.class);
229+
Object cellAfterColspan = colspan.invoke(cell, 2);
213230

214-
Log.i(TAG, "✓ Added to filters table");
231+
Method fillX = cellClass.getMethod("fillX");
232+
fillX.invoke(cellAfterColspan);
233+
234+
Log.i(TAG, "✓ Cell configured (colspan=2, fillX)");
235+
} catch (NoSuchMethodException e) {
236+
Log.w(TAG, "Could not configure Cell layout: " + e.getMessage());
237+
}
238+
239+
// Add row separator
240+
Method tableRow = tableClass.getMethod("row");
241+
tableRow.invoke(filtersSubTable);
242+
243+
Log.i(TAG, "✓ Added to filters table");
244+
} else {
245+
throw new NoSuchMethodException("Could not find Table.add method with any signature");
246+
}
215247

216248
// ========================================
217249
// Step 8: Create and set field listener

0 commit comments

Comments
 (0)