Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
feat(YouTube - Hide layout components): Add option to hide horizontal…
Browse files Browse the repository at this point in the history
… shelves (#598)

Co-authored-by: oSumAtrIX <[email protected]>
Co-authored-by: LisoUseInAIKyrios <[email protected]>
  • Loading branch information
3 people authored Apr 6, 2024
1 parent bddcc97 commit fedace0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -43,7 +44,6 @@ public final class LayoutComponentsFilter extends Filter {
);
}


@RequiresApi(api = Build.VERSION_CODES.N)
public LayoutComponentsFilter() {
exceptions.addPatterns(
Expand Down Expand Up @@ -237,6 +237,12 @@ public LayoutComponentsFilter() {
"endorsement_header_footer"
);

horizontalShelves = new StringFilterGroup(
Settings.HIDE_HORIZONTAL_SHELVES,
"horizontal_video_shelf.eml",
"horizontal_shelf.eml"
);

addPathCallbacks(
expandableMetadata,
inFeedSurvey,
Expand All @@ -263,7 +269,8 @@ public LayoutComponentsFilter() {
timedReactions,
imageShelf,
channelMemberShelf,
forYouShelf
forYouShelf,
horizontalShelves
);
}

Expand All @@ -279,7 +286,9 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
// 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.

Expand All @@ -298,6 +307,10 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
// 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);
}

Expand Down Expand Up @@ -346,4 +359,15 @@ public static void hideShowMoreButton(View view) {
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SELF_SPONSOR = new BooleanSetting("revanced_hide_self_sponsor_ads", TRUE);
public static final BooleanSetting HIDE_VIDEO_ADS = new BooleanSetting("revanced_hide_video_ads", TRUE, true);
public static final BooleanSetting HIDE_WEB_SEARCH_RESULTS = new BooleanSetting("revanced_hide_web_search_results", TRUE);

// Layout
public static final EnumSetting<ThumbnailOption> ALT_THUMBNAIL_HOME = new EnumSetting<>("revanced_alt_thumbnail_home", ThumbnailOption.ORIGINAL);
public static final EnumSetting<ThumbnailOption> ALT_THUMBNAIL_SUBSCRIPTIONS = new EnumSetting<>("revanced_alt_thumbnail_subscription", ThumbnailOption.ORIGINAL);
Expand All @@ -76,7 +77,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_ALBUM_CARDS = new BooleanSetting("revanced_hide_album_cards", FALSE, true);
public static final BooleanSetting HIDE_ARTIST_CARDS = new BooleanSetting("revanced_hide_artist_cards", FALSE);
public static final BooleanSetting HIDE_AUTOPLAY_BUTTON = new BooleanSetting("revanced_hide_autoplay_button", TRUE, true);
public static final BooleanSetting HIDE_BREAKING_NEWS = new BooleanSetting("revanced_hide_breaking_news", TRUE, true);
public static final BooleanSetting HIDE_HORIZONTAL_SHELVES = new BooleanSetting("revanced_hide_horizontal_shelves", TRUE);
public static final BooleanSetting HIDE_CAPTIONS_BUTTON = new BooleanSetting("revanced_hide_captions_button", FALSE);
public static final BooleanSetting HIDE_CAST_BUTTON = new BooleanSetting("revanced_hide_cast_button", TRUE, true);
public static final BooleanSetting HIDE_CHANNEL_BAR = new BooleanSetting("revanced_hide_channel_bar", FALSE);
Expand Down

0 comments on commit fedace0

Please sign in to comment.