From 9670bd305b3b9bbbc900af3b64152aaac125ec14 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 13 Oct 2023 17:13:47 +0200 Subject: [PATCH] fix(YouTube - Hide layout components): Hide new channel watermark component --- .../patches/BrandingWaterMarkPatch.java | 11 ----------- .../patches/components/LayoutComponentsFilter.java | 13 ++++++++++++- .../integrations/settings/SettingsEnum.java | 3 +++ 3 files changed, 15 insertions(+), 12 deletions(-) delete mode 100644 app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java b/app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java deleted file mode 100644 index e729e153..00000000 --- a/app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java +++ /dev/null @@ -1,11 +0,0 @@ -package app.revanced.integrations.patches; - -import app.revanced.integrations.settings.SettingsEnum; - -public class BrandingWaterMarkPatch { - - // Used by: app.revanced.patches.youtube.layout.watermark.patch.HideWatermarkPatch - public static boolean isBrandingWatermarkShown() { - return SettingsEnum.HIDE_VIDEO_WATERMARK.getBoolean() == false; - } -} diff --git a/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java index 4ee419d3..fa1d9b36 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java @@ -175,11 +175,17 @@ public final class LayoutComponentsFilter extends Filter { "chips_shelf" ); + final var channelWatermark = new StringFilterGroup( + SettingsEnum.HIDE_VIDEO_CHANNEL_WATERMARK, + "featured_channel_watermark_overlay" + ); + this.pathFilterGroupList.addAll( channelBar, communityPosts, paidContent, latestPosts, + channelWatermark, communityGuidelines, quickActions, expandableMetadata, @@ -211,6 +217,8 @@ public final class LayoutComponentsFilter extends Filter { public boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray, FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) { + // The groups are excluded from the filter due to the exceptions list below. + // Filter them separately here. if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey) return true; if (matchedGroup != custom && exceptions.matches(path)) @@ -225,7 +233,6 @@ public final class LayoutComponentsFilter extends Filter { /** * Injection point. - * * Called from a different place then the other filters. */ public static boolean filterMixPlaylists(final byte[] bytes) { @@ -236,4 +243,8 @@ public final class LayoutComponentsFilter extends Filter { return isMixPlaylistFiltered; } + + public static boolean showWatermark() { + return !SettingsEnum.HIDE_VIDEO_CHANNEL_WATERMARK.getBoolean(); + } } diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index 3affe384..0d72259b 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -123,6 +123,7 @@ public enum SettingsEnum { HIDE_SUBSCRIPTIONS_BUTTON("revanced_hide_subscriptions_button", BOOLEAN, FALSE, true), HIDE_TIMESTAMP("revanced_hide_timestamp", BOOLEAN, FALSE), HIDE_VIDEO_WATERMARK("revanced_hide_video_watermark", BOOLEAN, TRUE), + HIDE_VIDEO_CHANNEL_WATERMARK("revanced_hide_channel_watermark", BOOLEAN, TRUE), PLAYER_POPUP_PANELS("revanced_hide_player_popup_panels", BOOLEAN, FALSE), SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON("revanced_switch_create_with_notifications_button", BOOLEAN, TRUE, true), SPOOF_APP_VERSION("revanced_spoof_app_version", BOOLEAN, FALSE, true, "revanced_spoof_app_version_user_dialog_message"), @@ -374,6 +375,8 @@ public enum SettingsEnum { // region Migration + migrateOldSettingToNew(HIDE_VIDEO_WATERMARK, HIDE_VIDEO_CHANNEL_WATERMARK); + // Do _not_ delete this SB private user id migration property until sometime in 2024. // This is the only setting that cannot be reconfigured if lost, // and more time should be given for users who rarely upgrade.