From 1f48749958675926dd71b08e079497daed2b332b Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 22 Nov 2022 23:40:36 +0100 Subject: [PATCH] fix(youtube/general-ads): hide reels shelf --- .../integrations/patches/GeneralAdsPatch.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index dd6daba1..c28f68ed 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -114,10 +114,7 @@ public final class GeneralAdsPatch extends Filter { else result = BlockResult.UNBLOCKED; - LogHelper.debug( - GeneralAdsPatch.class, - String.format("%s (ID: %s): %s", result.message, identifier, path) - ); + log(String.format("%s (ID: %s): %s", result.message, identifier, path)); return result.filter; } @@ -138,12 +135,38 @@ public final class GeneralAdsPatch extends Filter { } /** - * Hide the specific view, which shows ads in the homepage. + * Hide a view. + * + * @param condition The setting to check for hiding the view. + * @param view The view to hide. + */ + private static void hideView(SettingsEnum condition, View view) { + if (!condition.getBoolean()) return; + + log("Hiding view with setting: " + condition); + + AdRemoverAPI.HideViewWithLayout1dp(view); + } + + /** + * Hide the view, which shows ads in the homepage. * * @param view The view, which shows ads. */ public static void hideAdAttributionView(View view) { - if (!SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL.getBoolean()) return; - AdRemoverAPI.HideViewWithLayout1dp(view); + hideView(SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL, view); + } + + /** + * Hide the view, which shows reels in the homepage. + * + * @param view The view, which shows reels. + */ + public static void hideReelView(View view) { + hideView(SettingsEnum.ADREMOVER_SHORTS_REMOVAL, view); + } + + private static void log(String message) { + LogHelper.debug(GeneralAdsPatch.class, message); } }