feat(Reddit - Hide navigation buttons): Add support for latest versions

This commit is contained in:
inotia00
2025-01-16 12:36:54 +09:00
parent a1a775cdf8
commit 9e9b170a82
4 changed files with 83 additions and 45 deletions

View File

@ -3,7 +3,9 @@ package app.revanced.extension.reddit.patches;
import android.view.View;
import android.view.ViewGroup;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import app.revanced.extension.reddit.settings.Settings;
import app.revanced.extension.shared.utils.Logger;
@ -24,6 +26,22 @@ public final class NavigationButtonsPatch {
return list;
}
public static Object[] hideNavigationButtons(Object[] array) {
try {
for (NavigationButton button : NavigationButton.values()) {
if (button.enabled && array.length > button.index) {
Object buttonObject = array[button.index];
array = Arrays.stream(array)
.filter(item -> !Objects.equals(item, buttonObject))
.toArray(Object[]::new);
}
}
} catch (Exception exception) {
Logger.printException(() -> "Failed to remove button array", exception);
}
return array;
}
public static void hideNavigationButtons(ViewGroup viewGroup) {
try {
if (viewGroup == null) return;