From 8e191e2df354017d2af2a067b771ce24d938a9da Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:59:28 -0400 Subject: [PATCH] fix(YouTube - Hide layout components): Hide player shopping shelf --- .../revanced/integrations/shared/Utils.java | 2 +- .../components/LayoutComponentsFilter.java | 19 +++++++++++++------ .../youtube/settings/Settings.java | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/shared/Utils.java b/app/src/main/java/app/revanced/integrations/shared/Utils.java index c00886a317..296c0b3bc0 100644 --- a/app/src/main/java/app/revanced/integrations/shared/Utils.java +++ b/app/src/main/java/app/revanced/integrations/shared/Utils.java @@ -106,7 +106,7 @@ public static void hideViewBy0dpUnderCondition(BooleanSetting condition, View vi } /** - * Hide a view by setting its layout height and width to 1dp. + * Hide a view by setting its layout height and width to 0dp. * * @param condition The setting to check for hiding the view. * @param view The view to hide. diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java index 415b7d8c8e..579396b55f 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java @@ -251,7 +251,7 @@ public LayoutComponentsFilter() { ); horizontalShelves = new StringFilterGroup( - Settings.HIDE_HORIZONTAL_SHELVES, + null, // Multiple settings use this filter. "horizontal_video_shelf.eml", "horizontal_shelf.eml", "horizontal_shelf_inline.eml", @@ -458,11 +458,18 @@ public static void hideShowMoreButton(View view) { } private static boolean hideShelves() { - // If the player is opened while library is selected, - // then filter any recommendations below the player. - if (PlayerType.getCurrent().isMaximizedOrFullscreen() - // Or if the search is active while library is selected, then also filter. - || NavigationBar.isSearchBarActive()) { + // Video player can show a horizontal shopping shelf below the video. + // It appears this is the only shelf that can appear in the player, + // and no shelves are shown in the recommendations under the video. + if (PlayerType.getCurrent().isMaximizedOrFullscreen()) { + return Settings.HIDE_PLAYER_STORE_SHELF.get(); + } + + if (!Settings.HIDE_HORIZONTAL_SHELVES.get()) { + return false; + } + + if (NavigationBar.isSearchBarActive()) { return true; } diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java index 1b3147f297..b9a2148f38 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java @@ -48,6 +48,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_MERCHANDISE_BANNERS = new BooleanSetting("revanced_hide_merchandise_banners", TRUE); public static final BooleanSetting HIDE_PAID_PROMOTION_LABEL = new BooleanSetting("revanced_hide_paid_promotion_label", TRUE); public static final BooleanSetting HIDE_PRODUCTS_BANNER = new BooleanSetting("revanced_hide_products_banner", TRUE); + public static final BooleanSetting HIDE_PLAYER_STORE_SHELF = new BooleanSetting("revanced_hide_player_store_shelf", TRUE); public static final BooleanSetting HIDE_SHOPPING_LINKS = new BooleanSetting("revanced_hide_shopping_links", TRUE); 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);