From fbd0507ce5cdeb93a1f661aa8097139c61e643a0 Mon Sep 17 00:00:00 2001 From: epireyn <48213068+epireyn@users.noreply.github.com> Date: Thu, 27 Jun 2024 22:26:35 +0200 Subject: [PATCH] feat(Stocard): Add `Hide offers tab` and `Hide story bubbles` patch (#3359) Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 12 +++++++++ .../stocard/layout/HideOffersTabPatch.kt | 27 +++++++++++++++++++ .../stocard/layout/HideStoryBubblesPatch.kt | 27 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/stocard/layout/HideStoryBubblesPatch.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 057f8cf9..c34624f3 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -1040,6 +1040,18 @@ public final class app/revanced/patches/spotify/navbar/PremiumNavbarTabResourceP public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } +public final class app/revanced/patches/stocard/layout/HideOffersTabPatch : app/revanced/patcher/patch/ResourcePatch { + public static final field INSTANCE Lapp/revanced/patches/stocard/layout/HideOffersTabPatch; + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V + public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V +} + +public final class app/revanced/patches/stocard/layout/HideStoryBubblesPatch : app/revanced/patcher/patch/ResourcePatch { + public static final field INSTANCE Lapp/revanced/patches/stocard/layout/HideStoryBubblesPatch; + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V + public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V +} + public final class app/revanced/patches/strava/subscription/UnlockSubscriptionPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/strava/subscription/UnlockSubscriptionPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt new file mode 100644 index 00000000..6b493c4b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt @@ -0,0 +1,27 @@ +package app.revanced.patches.stocard.layout + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.util.childElementsSequence +import app.revanced.util.getNode + +@Patch( + name = "Hide offers tab", + compatiblePackages = [CompatiblePackage("de.stocard.stocard")], +) +@Suppress("unused") +object HideOffersTabPatch : ResourcePatch() { + override fun execute(context: ResourceContext) { + context.document["res/menu/bottom_navigation_menu.xml"].use { document -> + document.getNode("menu").apply { + removeChild( + childElementsSequence().first { + it.attributes.getNamedItem("android:id")?.nodeValue?.contains("offer") ?: false + }, + ) + } + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoryBubblesPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoryBubblesPatch.kt new file mode 100644 index 00000000..eecdeb38 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoryBubblesPatch.kt @@ -0,0 +1,27 @@ +package app.revanced.patches.stocard.layout + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.util.getNode + +@Patch( + name = "Hide story bubbles", + compatiblePackages = [CompatiblePackage("de.stocard.stocard")], +) +@Suppress("unused") +object HideStoryBubblesPatch : ResourcePatch() { + override fun execute(context: ResourceContext) { + context.document["res/layout/rv_story_bubbles_list.xml"].use { document -> + document.getNode("androidx.recyclerview.widget.RecyclerView").apply { + arrayOf( + "android:layout_width", + "android:layout_height", + ).forEach { + attributes.getNamedItem(it).nodeValue = "0dp" + } + } + } + } +}