refactor: fix naming inconsistency

This commit is contained in:
oSumAtrIX 2023-08-23 05:28:57 +02:00
parent 8c74d2273a
commit c424c08f3d
9 changed files with 24 additions and 34 deletions

View File

@ -86,7 +86,7 @@ public final class AdsFilter extends Filter {
"cta_shelf_card" "cta_shelf_card"
); );
this.pathFilterGroups.addAll( this.pathFilterGroupList.addAll(
generalAds, generalAds,
buttonedAd, buttonedAd,
merchandise, merchandise,
@ -95,7 +95,7 @@ public final class AdsFilter extends Filter {
webLinkPanel, webLinkPanel,
movieAds movieAds
); );
this.identifierFilterGroups.addAll(carouselAd); this.identifierFilterGroupList.addAll(carouselAd);
} }
@Override @Override

View File

@ -20,14 +20,14 @@ final class ButtonsFilter extends Filter {
null, null,
VIDEO_ACTION_BAR_PATH VIDEO_ACTION_BAR_PATH
); );
identifierFilterGroups.addAll(actionBarGroup); identifierFilterGroupList.addAll(actionBarGroup);
bufferFilterPathGroup = new StringFilterGroup( bufferFilterPathGroup = new StringFilterGroup(
null, null,
"|CellType|CollectionType|CellType|ContainerType|button.eml|" "|CellType|CollectionType|CellType|ContainerType|button.eml|"
); );
pathFilterGroups.addAll( pathFilterGroupList.addAll(
new StringFilterGroup( new StringFilterGroup(
SettingsEnum.HIDE_LIKE_DISLIKE_BUTTON, SettingsEnum.HIDE_LIKE_DISLIKE_BUTTON,
"|segmented_like_dislike_button" "|segmented_like_dislike_button"
@ -82,7 +82,7 @@ final class ButtonsFilter extends Filter {
} }
private boolean isEveryFilterGroupEnabled() { private boolean isEveryFilterGroupEnabled() {
for (var group : pathFilterGroups) for (var group : pathFilterGroupList)
if (!group.isEnabled()) return false; if (!group.isEnabled()) return false;
for (var group : bufferButtonsGroupList) for (var group : bufferButtonsGroupList)

View File

@ -18,7 +18,7 @@ final class CommentsFilter extends Filter {
"comments_entry_point_simplebox" "comments_entry_point_simplebox"
); );
this.pathFilterGroups.addAll( this.pathFilterGroupList.addAll(
comments, comments,
previewComment previewComment
); );

View File

@ -142,7 +142,7 @@ public final class LayoutComponentsFilter extends Filter {
"chips_shelf" "chips_shelf"
); );
this.pathFilterGroups.addAll( this.pathFilterGroupList.addAll(
channelBar, channelBar,
communityPosts, communityPosts,
paidContent, paidContent,
@ -165,7 +165,7 @@ public final class LayoutComponentsFilter extends Filter {
custom custom
); );
this.identifierFilterGroups.addAll( this.identifierFilterGroupList.addAll(
graySeparator, graySeparator,
chipsShelf chipsShelf
); );

View File

@ -1,26 +1,16 @@
package app.revanced.integrations.patches.components; package app.revanced.integrations.patches.components;
import android.os.Build; import android.os.Build;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer; import java.util.function.Consumer;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.ByteTrieSearch;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.StringTrieSearch;
import app.revanced.integrations.utils.TrieSearch;
abstract class FilterGroup<T> { abstract class FilterGroup<T> {
final static class FilterGroupResult { final static class FilterGroupResult {
SettingsEnum setting; SettingsEnum setting;
@ -283,8 +273,8 @@ abstract class Filter {
* will never be called for any matches. * will never be called for any matches.
*/ */
protected final StringFilterGroupList pathFilterGroups = new StringFilterGroupList(); protected final StringFilterGroupList pathFilterGroupList = new StringFilterGroupList();
protected final StringFilterGroupList identifierFilterGroups = new StringFilterGroupList(); protected final StringFilterGroupList identifierFilterGroupList = new StringFilterGroupList();
/** /**
* Called after an enabled filter has been matched. * Called after an enabled filter has been matched.
@ -302,9 +292,9 @@ abstract class Filter {
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray, boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) { FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) {
if (SettingsEnum.DEBUG.getBoolean()) { if (SettingsEnum.DEBUG.getBoolean()) {
if (pathFilterGroups == matchedList) { if (pathFilterGroupList == matchedList) {
LogHelper.printDebug(() -> getClass().getSimpleName() + " Filtered path: " + path); LogHelper.printDebug(() -> getClass().getSimpleName() + " Filtered path: " + path);
} else if (identifierFilterGroups == matchedList) { } else if (identifierFilterGroupList == matchedList) {
LogHelper.printDebug(() -> getClass().getSimpleName() + " Filtered identifier: " + identifier); LogHelper.printDebug(() -> getClass().getSimpleName() + " Filtered identifier: " + identifier);
} }
} }
@ -391,8 +381,8 @@ public final class LithoFilterPatch {
static { static {
for (Filter filter : filters) { for (Filter filter : filters) {
filterGroupLists(pathSearchTree, filter, filter.pathFilterGroups); filterGroupLists(pathSearchTree, filter, filter.pathFilterGroupList);
filterGroupLists(identifierSearchTree, filter, filter.identifierFilterGroups); filterGroupLists(identifierSearchTree, filter, filter.identifierFilterGroupList);
} }
LogHelper.printDebug(() -> "Using: " LogHelper.printDebug(() -> "Using: "

View File

@ -8,7 +8,7 @@ public final class PlaybackSpeedMenuFilterPatch extends Filter {
public static volatile boolean isPlaybackSpeedMenuVisible; public static volatile boolean isPlaybackSpeedMenuVisible;
public PlaybackSpeedMenuFilterPatch() { public PlaybackSpeedMenuFilterPatch() {
pathFilterGroups.addAll(new StringFilterGroup( pathFilterGroupList.addAll(new StringFilterGroup(
null, null,
"playback_speed_sheet_content.eml-js" "playback_speed_sheet_content.eml-js"
)); ));

View File

@ -15,7 +15,7 @@ public class PlayerFlyoutMenuItemsFilter extends Filter {
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
public PlayerFlyoutMenuItemsFilter() { public PlayerFlyoutMenuItemsFilter() {
identifierFilterGroups.addAll(new StringFilterGroup(null, "overflow_menu_item.eml|")); identifierFilterGroupList.addAll(new StringFilterGroup(null, "overflow_menu_item.eml|"));
flyoutFilterGroupList.addAll( flyoutFilterGroupList.addAll(
new ByteArrayAsStringFilterGroup( new ByteArrayAsStringFilterGroup(

View File

@ -59,8 +59,8 @@ public final class ShortsFilter extends Filter {
"shorts_pivot_item" "shorts_pivot_item"
); );
pathFilterGroups.addAll(joinButton, subscribeButton, channelBar, soundButton, infoPanel); pathFilterGroupList.addAll(joinButton, subscribeButton, channelBar, soundButton, infoPanel);
identifierFilterGroups.addAll(shorts, thanksButton); identifierFilterGroupList.addAll(shorts, thanksButton);
} }
@Override @Override
@ -69,11 +69,11 @@ public final class ShortsFilter extends Filter {
if (matchedGroup == soundButton || matchedGroup == infoPanel || matchedGroup == channelBar) return true; if (matchedGroup == soundButton || matchedGroup == infoPanel || matchedGroup == channelBar) return true;
// Filter the path only when reelChannelBar is visible. // Filter the path only when reelChannelBar is visible.
if (pathFilterGroups == matchedList) { if (pathFilterGroupList == matchedList) {
return path.contains(REEL_CHANNEL_BAR_PATH); return path.contains(REEL_CHANNEL_BAR_PATH);
} }
return identifierFilterGroups == matchedList; return identifierFilterGroupList == matchedList;
} }
public static void hideShortsShelf(final View shortsShelfView) { public static void hideShortsShelf(final View shortsShelfView) {

View File

@ -10,7 +10,7 @@ public final class VideoQualityMenuFilterPatch extends Filter {
public static volatile boolean isVideoQualityMenuVisible; public static volatile boolean isVideoQualityMenuVisible;
public VideoQualityMenuFilterPatch() { public VideoQualityMenuFilterPatch() {
pathFilterGroups.addAll(new StringFilterGroup( pathFilterGroupList.addAll(new StringFilterGroup(
SettingsEnum.SHOW_OLD_VIDEO_QUALITY_MENU, SettingsEnum.SHOW_OLD_VIDEO_QUALITY_MENU,
"quick_quality_sheet_content.eml-js" "quick_quality_sheet_content.eml-js"
)); ));