From 788d0fd06c8a33631e98ba20ffd24804f7094769 Mon Sep 17 00:00:00 2001
From: inotia00 <108592928+inotia00@users.noreply.github.com>
Date: Wed, 20 Mar 2024 01:56:37 +0900
Subject: [PATCH] feat(YouTube Music): add `Hide sample shelf` patch
---
.../sampleshelf/HideSampleShelfPatch.kt | 53 +++++++++++++++++++
.../music/settings/host/values/strings.xml | 2 +
2 files changed, 55 insertions(+)
create mode 100644 src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt
diff --git a/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt
new file mode 100644
index 000000000..288293117
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt
@@ -0,0 +1,53 @@
+package app.revanced.patches.music.general.sampleshelf
+
+import app.revanced.patcher.data.BytecodeContext
+import app.revanced.patcher.patch.BytecodePatch
+import app.revanced.patcher.patch.annotation.CompatiblePackage
+import app.revanced.patcher.patch.annotation.Patch
+import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH
+import app.revanced.patches.music.utils.litho.LithoFilterPatch
+import app.revanced.patches.music.utils.settings.CategoryType
+import app.revanced.patches.music.utils.settings.SettingsPatch
+
+@Patch(
+ name = "Hide sample shelf",
+ description = "Adds an option to hide the sample shelf from the homepage.",
+ dependencies = [
+ LithoFilterPatch::class,
+ SettingsPatch::class
+ ],
+ compatiblePackages = [
+ CompatiblePackage(
+ "com.google.android.apps.youtube.music",
+ [
+ "6.21.52",
+ "6.22.52",
+ "6.23.56",
+ "6.25.53",
+ "6.26.51",
+ "6.27.54",
+ "6.28.53",
+ "6.29.58",
+ "6.31.55",
+ "6.33.52"
+ ]
+ )
+ ]
+)
+@Suppress("unused")
+object HideSampleShelfPatch : BytecodePatch(emptySet()) {
+ override fun execute(context: BytecodeContext) {
+
+ SettingsPatch.addMusicPreference(
+ CategoryType.GENERAL,
+ "revanced_hide_samples_shelf",
+ "false"
+ )
+
+ LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
+
+ }
+
+ private const val FILTER_CLASS_DESCRIPTOR =
+ "$COMPONENTS_PATH/SampleShelfFilter;"
+}
diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml
index 599275824..b7fb4976b 100644
--- a/src/main/resources/music/settings/host/values/strings.xml
+++ b/src/main/resources/music/settings/host/values/strings.xml
@@ -178,6 +178,8 @@ Some features may not work properly in the old player layout."
Hide premium renewal banner
Hides the samples button.
Hide samples button
+ Hides the samples shelf from the homepage.
+ Hide samples shelf
Hides terms of service container.
Hide terms container
Hides the upgrade button.