From eade139811bd3bc90a289b2c81b4b32cfa2dee42 Mon Sep 17 00:00:00 2001 From: OxrxL <108184954+OxrxL@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:17:56 +0200 Subject: [PATCH] feat: `hide-artist-card` patch (#859) --- .../HideArtistCardCompatibility.kt | 13 +++++++ .../patch/HideArtistCardPatch.kt | 38 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/annotations/HideArtistCardCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/patch/HideArtistCardPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/annotations/HideArtistCardCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/annotations/HideArtistCardCompatibility.kt new file mode 100644 index 000000000..b7f8c27bc --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/annotations/HideArtistCardCompatibility.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.layout.buttons.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [Package( + "com.google.android.youtube", arrayOf("17.25.34", "17.26.35", "17.27.39", "17.28.34", "17.29.34", "17.32.35", "17.33.42", "17.34.35", "17.34.36", "17.36.37") + )] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class HideArtistCardCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/patch/HideArtistCardPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/patch/HideArtistCardPatch.kt new file mode 100644 index 000000000..57a9f096c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hideartistcard/patch/HideArtistCardPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.youtube.layout.hideartistcard.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.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch +import app.revanced.patches.youtube.layout.buttons.annotations.HideArtistCardCompatibility +import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch +import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource +import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference + +@Patch +@DependsOn([ResourceMappingResourcePatch::class, GeneralBytecodeAdsPatch::class]) +@Name("hide-artist-card") +@Description("Hides the artist card below the searchbar.") +@HideArtistCardCompatibility +@Version("0.0.1") +class HideArtistCardPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SwitchPreference( + "revanced_hide_artist_card", + StringResource("revanced_hide_hide_artist_card_title", "Hide artist card"), + false, + StringResource("revanced_hide_hide_artist_card_on", "Artist card is hidden"), + StringResource("revanced_hide_hide_artist_card_off", "Artist card is shown") + ), + ) + return PatchResultSuccess() + } +}