mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-06-02 11:26:18 +02:00
merge to layouts components patch
This commit is contained in:
parent
0c3a3400bc
commit
115c963112
|
@ -1,42 +0,0 @@
|
|||
package app.revanced.integrations.youtube.patches.components;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import app.revanced.integrations.youtube.settings.Settings;
|
||||
import app.revanced.integrations.youtube.shared.NavigationBar;
|
||||
import app.revanced.integrations.youtube.shared.PlayerType;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class HorizontalShelvesFilter extends Filter {
|
||||
|
||||
public HorizontalShelvesFilter() {
|
||||
addPathCallbacks(
|
||||
new StringFilterGroup(
|
||||
Settings.HIDE_HORIZONTAL_SHELVES,
|
||||
"horizontal_video_shelf.eml",
|
||||
"horizontal_shelf.eml"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (contentIndex == 0 && shouldHideShelves()) {
|
||||
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean shouldHideShelves() {
|
||||
// Only filter if the library tab is not selected.
|
||||
// This check is important as the shelf layout is used for the library tab playlists.
|
||||
return !NavigationBar.NavigationButton.libraryOrYouTabIsSelected()
|
||||
// But if the player is opened while library is selected,
|
||||
// then still filter any recommendations below the player.
|
||||
|| PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||
// Or if the search is active while library is selected, then also filter.
|
||||
|| NavigationBar.isSearchBarActive();
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
private final StringFilterGroup compactChannelBarInner;
|
||||
private final StringFilterGroup compactChannelBarInnerButton;
|
||||
private final ByteArrayFilterGroup joinMembershipButton;
|
||||
private final StringFilterGroup horizontalShelves;
|
||||
|
||||
static {
|
||||
mixPlaylistsExceptions.addPatterns(
|
||||
|
@ -43,7 +44,6 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public LayoutComponentsFilter() {
|
||||
exceptions.addPatterns(
|
||||
|
@ -237,6 +237,12 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
"endorsement_header_footer"
|
||||
);
|
||||
|
||||
horizontalShelves = new StringFilterGroup(
|
||||
Settings.HIDE_HORIZONTAL_SHELVES,
|
||||
"horizontal_video_shelf.eml",
|
||||
"horizontal_shelf.eml"
|
||||
);
|
||||
|
||||
addPathCallbacks(
|
||||
expandableMetadata,
|
||||
inFeedSurvey,
|
||||
|
@ -263,7 +269,8 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
timedReactions,
|
||||
imageShelf,
|
||||
channelMemberShelf,
|
||||
forYouShelf
|
||||
forYouShelf,
|
||||
horizontalShelves
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -279,7 +286,9 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
// The groups are excluded from the filter due to the exceptions list below.
|
||||
// Filter them separately here.
|
||||
if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey || matchedGroup == expandableMetadata)
|
||||
{
|
||||
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||
}
|
||||
|
||||
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
|
||||
|
||||
|
@ -298,6 +307,10 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
// TODO: This also hides the feed Shorts shelf header
|
||||
if (matchedGroup == searchResultShelfHeader && contentIndex != 0) return false;
|
||||
|
||||
if (contentIndex == 0 && matchedGroup == horizontalShelves && hideShelves()) {
|
||||
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||
}
|
||||
|
||||
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||
}
|
||||
|
||||
|
@ -346,4 +359,15 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
Utils.hideViewByLayoutParams(view);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hideShelves() {
|
||||
// Only filter if the library tab is not selected.
|
||||
// This check is important as the shelf layout is used for the library tab playlists.
|
||||
return !NavigationBar.NavigationButton.libraryOrYouTabIsSelected()
|
||||
// But if the player is opened while library is selected,
|
||||
// then still filter any recommendations below the player.
|
||||
|| PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||
// Or if the search is active while library is selected, then also filter.
|
||||
|| NavigationBar.isSearchBarActive();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user