Skip to content
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Hide feed components): Hide carousel shelf setting hi…
Browse files Browse the repository at this point in the history
…des the library shelf
  • Loading branch information
anddea committed Oct 29, 2024
1 parent 050f58e commit 4be6d9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import app.revanced.integrations.shared.patches.components.Filter;
import app.revanced.integrations.shared.patches.components.StringFilterGroup;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.NavigationBar.NavigationButton;
import app.revanced.integrations.youtube.shared.RootView;

@SuppressWarnings("unused")
Expand All @@ -31,28 +32,19 @@ public final class CarouselShelfFilter extends Filter {
BROWSE_ID_NOTIFICATION_INBOX
);

public final StringFilterGroup horizontalShelf;

public CarouselShelfFilter() {
final StringFilterGroup carouselShelf = new StringFilterGroup(
Settings.HIDE_CAROUSEL_SHELF,
"horizontal_shelf_inline.eml",
"horizontal_tile_shelf.eml",
"horizontal_video_shelf.eml"
);

horizontalShelf = new StringFilterGroup(
Settings.HIDE_CAROUSEL_SHELF,
"horizontal_shelf.eml"
);

addIdentifierCallbacks(
carouselShelf,
horizontalShelf
addPathCallbacks(
new StringFilterGroup(
Settings.HIDE_CAROUSEL_SHELF,
"horizontal_video_shelf.eml",
"horizontal_shelf.eml",
"horizontal_shelf_inline.eml",
"horizontal_tile_shelf.eml"
)
);
}

private static boolean hideShelves() {
private static boolean hideShelves(NavigationButton selectedNavButton, String browseId) {
// Must check player type first, as search bar can be active behind the player.
if (RootView.isPlayerActive()) {
return false;
Expand All @@ -61,7 +53,10 @@ private static boolean hideShelves() {
if (RootView.isSearchBarActive()) {
return true;
}
String browseId = RootView.getBrowseId();
// Unknown tab, treat the same as home.
if (selectedNavButton == null) {
return true;
}
if (knownBrowseId.get().anyMatch(browseId::equals)) {
return true;
}
Expand All @@ -71,10 +66,10 @@ private static boolean hideShelves() {
@Override
public boolean isFiltered(String path, @Nullable String identifier, String allValue, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (matchedGroup == horizontalShelf && !hideShelves()) {
return false;
if (contentIndex == 0 && hideShelves(NavigationButton.getSelectedNavigationButton(), RootView.getBrowseId())) {
return super.isFiltered(path, identifier, allValue, protobufBufferArray, matchedGroup, contentType, contentIndex);
}

return super.isFiltered(path, identifier, allValue, protobufBufferArray, matchedGroup, contentType, contentIndex);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ enum class PlayerType {

/**
* Check if the current player type is
* [WATCH_WHILE_MAXIMIZED], [WATCH_WHILE_FULLSCREEN], [WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN].
* [WATCH_WHILE_MAXIMIZED], [WATCH_WHILE_FULLSCREEN].
*
* Useful to check if a regular video is being played.
*/
fun isMaximizedOrFullscreen(): Boolean {
return this == WATCH_WHILE_MAXIMIZED || this == WATCH_WHILE_FULLSCREEN || this == WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN
return this == WATCH_WHILE_MAXIMIZED || this == WATCH_WHILE_FULLSCREEN
}

/**
Expand Down

0 comments on commit 4be6d9e

Please sign in to comment.