diff --git a/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java b/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java deleted file mode 100644 index 63dfed33..00000000 --- a/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java +++ /dev/null @@ -1,42 +0,0 @@ -package app.revanced.integrations.adremover; - - -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.Toolbar; - -import app.revanced.integrations.utils.LogHelper; - -public class AdRemoverAPI { - - /** - * Removes Reels and Home ads - * - * @param view - */ - //ToDo: refactor this - public static void HideViewWithLayout1dp(View view) { - if (view instanceof LinearLayout) { - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1); - view.setLayoutParams(layoutParams); - } else if (view instanceof FrameLayout) { - FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1); - view.setLayoutParams(layoutParams2); - } else if (view instanceof RelativeLayout) { - RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1); - view.setLayoutParams(layoutParams3); - } else if (view instanceof Toolbar) { - Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1); - view.setLayoutParams(layoutParams4); - } else if (view instanceof ViewGroup) { - ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1); - view.setLayoutParams(layoutParams5); - } else { - LogHelper.printDebug(() -> "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName()); - } - } - -} 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 8bfb7631..f02e60f8 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -1,7 +1,6 @@ package app.revanced.integrations.patches; import android.view.View; -import app.revanced.integrations.adremover.AdRemoverAPI; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; @@ -166,7 +165,7 @@ public final class GeneralAdsPatch extends Filter { LogHelper.printDebug(() -> "Hiding view with setting: " + condition); - AdRemoverAPI.HideViewWithLayout1dp(view); + ReVancedUtils.HideViewByLayoutParams(view); } /** diff --git a/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java index 0ec70f79..cb4b9b0e 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java @@ -2,12 +2,12 @@ package app.revanced.integrations.patches; import android.view.View; -import app.revanced.integrations.adremover.AdRemoverAPI; import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.ReVancedUtils; public class HideAlbumCardsPatch { public static void hideAlbumCard(View view) { if (!SettingsEnum.HIDE_ALBUM_CARDS.getBoolean()) return; - AdRemoverAPI.HideViewWithLayout1dp(view); + ReVancedUtils.HideViewByLayoutParams(view); } } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java index 370e32f4..1853380f 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java @@ -2,8 +2,8 @@ package app.revanced.integrations.patches; import android.view.View; -import app.revanced.integrations.adremover.AdRemoverAPI; import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.ReVancedUtils; public class HideBreakingNewsPatch { @@ -24,6 +24,6 @@ public class HideBreakingNewsPatch { public static void hideBreakingNews(View view) { if (!SettingsEnum.HIDE_BREAKING_NEWS.getBoolean() || isSpoofingOldVersionWithHorizontalCardListWatchHistory()) return; - AdRemoverAPI.HideViewWithLayout1dp(view); + ReVancedUtils.HideViewByLayoutParams(view); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java index 747784e8..f7de894c 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java @@ -2,13 +2,13 @@ package app.revanced.integrations.patches; import android.view.View; -import app.revanced.integrations.adremover.AdRemoverAPI; import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.ReVancedUtils; public class HideCrowdfundingBoxPatch { //Used by app.revanced.patches.youtube.layout.hidecrowdfundingbox.patch.HideCrowdfundingBoxPatch public static void hideCrowdfundingBox(View view) { if (!SettingsEnum.HIDE_CROWDFUNDING_BOX.getBoolean()) return; - AdRemoverAPI.HideViewWithLayout1dp(view); + ReVancedUtils.HideViewByLayoutParams(view); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java index d786bab4..e5358a54 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java @@ -1,8 +1,8 @@ package app.revanced.integrations.patches; import android.view.View; -import app.revanced.integrations.adremover.AdRemoverAPI; import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.ReVancedUtils; public final class HideFilterBarPatch { public static int hideInFeed(final int height) { @@ -14,7 +14,7 @@ public final class HideFilterBarPatch { public static void hideInRelatedVideos(final View chipView) { if (!SettingsEnum.HIDE_FILTER_BAR_FEED_IN_RELATED_VIDEOS.getBoolean()) return; - AdRemoverAPI.HideViewWithLayout1dp(chipView); + ReVancedUtils.HideViewByLayoutParams(chipView); } public static int hideInSearch(final int height) { diff --git a/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java index 5b23bebe..cb6d22f6 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java @@ -2,12 +2,12 @@ package app.revanced.integrations.patches; import android.view.View; -import app.revanced.integrations.adremover.AdRemoverAPI; import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.ReVancedUtils; public class HideLoadMoreButtonPatch { public static void hideLoadMoreButton(View view){ if(!SettingsEnum.HIDE_LOAD_MORE_BUTTON.getBoolean()) return; - AdRemoverAPI.HideViewWithLayout1dp(view); + ReVancedUtils.HideViewByLayoutParams(view); } } diff --git a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java index b92d4bd5..a24cf27d 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java @@ -6,9 +6,11 @@ import android.content.res.Resources; import android.net.ConnectivityManager; import android.os.Handler; import android.os.Looper; +import android.view.View; +import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationUtils; -import android.widget.Toast; +import android.widget.*; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -239,6 +241,31 @@ public class ReVancedUtils { || (type == ConnectivityManager.TYPE_BLUETOOTH) ? NetworkType.MOBILE : NetworkType.OTHER; } + /** + * Hide a view by setting its layout params to 1x1 + * @param view The view to hide. + */ + public static void HideViewByLayoutParams(View view) { + if (view instanceof LinearLayout) { + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1); + view.setLayoutParams(layoutParams); + } else if (view instanceof FrameLayout) { + FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1); + view.setLayoutParams(layoutParams2); + } else if (view instanceof RelativeLayout) { + RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1); + view.setLayoutParams(layoutParams3); + } else if (view instanceof Toolbar) { + Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1); + view.setLayoutParams(layoutParams4); + } else if (view instanceof ViewGroup) { + ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1); + view.setLayoutParams(layoutParams5); + } else { + LogHelper.printDebug(() -> "Hidden view with id " + view.getId()); + } + } + public enum NetworkType { NONE, MOBILE,