From d22c96fbffbb49ddeec0c4246d2802866b9a263e Mon Sep 17 00:00:00 2001 From: inotia00 Date: Thu, 9 Mar 2023 09:34:27 +0900 Subject: [PATCH] add `hide-music-button` patch --- .../musicbutton/patch/HideMusicButtonPatch.kt | 44 +++++++++++++++++++ .../youtube/settings/host/values/strings.xml | 3 ++ .../youtube/settings/xml/revanced_prefs.xml | 4 ++ 3 files changed, 51 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt new file mode 100644 index 000000000..712790fea --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt @@ -0,0 +1,44 @@ +package app.revanced.patches.youtube.layout.player.musicbutton.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch + +@Patch +@Name("hide-music-button") +@Description("Hides the YouTube Music button in the video player.") +@DependsOn( + [ + PlayerButtonPatch::class, + SettingsPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class HideMusicButtonPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + + /* + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: PLAYER_LAYOUT_SETTINGS", + "SETTINGS: HIDE_YOUTUBE_MUSIC_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-music-button") + + return PatchResultSuccess() + } +} diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index e0895e302..44da6fa15 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -435,6 +435,9 @@ Is it ready to submit?" Time stamp is shown Time stamp is hidden Hide time stamp + YouTube Music button is shown + YouTube Music button is hidden + Hide youtube music button Fetch ReVanced settings from saved file Import settings Miscellaneous diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 3bce0a105..038dfbceb 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -148,6 +148,9 @@ + + @@ -404,6 +407,7 @@ +