fix(YouTube - Hide layout components): Resolve "Hide community posts" not working when selecting a channel from subscribed channels bar in Subscriptions tab
Co-authored-by: ILoveOpenSourceApplications <117499019+iloveopensourceapplications@users.noreply.github.com>
This commit is contained in:
parent
136cecc290
commit
009cf71462
14 changed files with 175 additions and 53 deletions
|
|
@ -12,6 +12,8 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
|
@ -172,14 +174,21 @@ public final class CustomFilter extends Filter {
|
|||
|
||||
if (!groups.isEmpty()) {
|
||||
CustomFilterGroup[] groupsArray = groups.toArray(new CustomFilterGroup[0]);
|
||||
Logger.printDebug(()-> "Using Custom filters: " + Arrays.toString(groupsArray));
|
||||
Logger.printDebug(() -> "Using Custom filters: " + Arrays.toString(groupsArray));
|
||||
addPathCallbacks(groupsArray);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(
|
||||
ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
// All callbacks are custom filter groups.
|
||||
CustomFilterGroup custom = (CustomFilterGroup) matchedGroup;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package app.revanced.extension.shared.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
||||
|
|
@ -9,27 +11,33 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Filters litho based components.
|
||||
*
|
||||
* <p>
|
||||
* Callbacks to filter content are added using {@link #addIdentifierCallbacks(StringFilterGroup...)}
|
||||
* and {@link #addPathCallbacks(StringFilterGroup...)}.
|
||||
*
|
||||
* <p>
|
||||
* To filter {@link FilterContentType#PROTOBUFFER} or {@link FilterContentType#ACCESSIBILITY}, first add a callback to
|
||||
* either an identifier or a path.
|
||||
* Then inside {@link #isFiltered(String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* Then inside {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* search for the buffer content using either a {@link ByteArrayFilterGroup} (if searching for 1 pattern)
|
||||
* or a {@link FilterGroupList.ByteArrayFilterGroupList} (if searching for more than 1 pattern).
|
||||
*
|
||||
* <p>
|
||||
* All callbacks must be registered before the constructor completes.
|
||||
*/
|
||||
public abstract class Filter {
|
||||
|
||||
public enum FilterContentType {
|
||||
CONTEXT,
|
||||
IDENTIFIER,
|
||||
PATH,
|
||||
ACCESSIBILITY,
|
||||
PROTOBUFFER
|
||||
}
|
||||
|
||||
/**
|
||||
* Context callbacks. Do not add to this instance,
|
||||
* and instead use {@link #addContextCallbacks(StringFilterGroup...)}.
|
||||
*/
|
||||
protected final List<StringFilterGroup> contextCallbacks = new ArrayList<>();
|
||||
/**
|
||||
* Identifier callbacks. Do not add to this instance,
|
||||
* and instead use {@link #addIdentifierCallbacks(StringFilterGroup...)}.
|
||||
|
|
@ -42,7 +50,15 @@ public abstract class Filter {
|
|||
public final List<StringFilterGroup> pathCallbacks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Adds callbacks to {@link #isFiltered(String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* Adds callbacks to {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* if any of the groups are found.
|
||||
*/
|
||||
protected final void addContextCallbacks(StringFilterGroup... groups) {
|
||||
contextCallbacks.addAll(Arrays.asList(groups));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds callbacks to {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* if any of the groups are found.
|
||||
*/
|
||||
protected final void addIdentifierCallbacks(StringFilterGroup... groups) {
|
||||
|
|
@ -50,7 +66,7 @@ public abstract class Filter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds callbacks to {@link #isFiltered(String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* Adds callbacks to {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* if any of the groups are found.
|
||||
*/
|
||||
protected final void addPathCallbacks(StringFilterGroup... groups) {
|
||||
|
|
@ -64,6 +80,7 @@ public abstract class Filter {
|
|||
* <p>
|
||||
* Method is called off the main thread.
|
||||
*
|
||||
* @param contextInterface The interface to get the Litho conversion context.
|
||||
* @param identifier Litho identifier.
|
||||
* @param accessibility Accessibility string, or an empty string if not present for the component.
|
||||
* @param buffer Protocol buffer.
|
||||
|
|
@ -72,8 +89,8 @@ public abstract class Filter {
|
|||
* @param contentIndex Matched index of the identifier or path.
|
||||
* @return True if the litho component should be filtered out.
|
||||
*/
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface, String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue