From 04b8c65d254fc3a9144f2ee6ab6e250526f163c8 Mon Sep 17 00:00:00 2001 From: Edgar Pireyn Date: Thu, 20 Jun 2024 19:01:35 +0200 Subject: [PATCH 1/3] Remove offers tab and offer stories --- .../patches/stocard/HideOfferTabPatch.kt | 18 ++++++++++++++++++ .../patches/stocard/HideStoriesPatch.kt | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt new file mode 100644 index 0000000000..2584f80c42 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.stocard + +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 + +@Patch(name = "Hide offers tab", compatiblePackages = [CompatiblePackage("de.stocard.stocard", ["10.50.0"])]) +object HideOfferTabPatch : ResourcePatch() { + override fun execute(context: ResourceContext) { + context.document["res/menu/bottom_navigation_menu.xml"].use { document -> + val menu = document.getElementsByTagName("menu").item(0) + menu.removeChild(menu.childElementsSequence() + .first { it.attributes.getNamedItem("android:id")?.nodeValue?.contains("offer") ?: false }) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt new file mode 100644 index 0000000000..3df57782b5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.stocard + +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 + +@Patch(name = "Hide story bubbles", compatiblePackages = [CompatiblePackage("de.stocard.stocard", ["10.50.0"])]) +object HideStoriesPatch : ResourcePatch() { + override fun execute(context: ResourceContext) { + context.document["res/layout/rv_story_bubbles_list.xml"].use { document -> + val view = document.getElementsByTagName("androidx.recyclerview.widget.RecyclerView").item(0) + view.attributes.getNamedItem("android:layout_width").nodeValue = "0dp" + view.attributes.getNamedItem("android:layout_height").nodeValue = "0dp" + } + } + +} \ No newline at end of file From fc22cf54b1212f62a9ec566ef2b992376e9c25e2 Mon Sep 17 00:00:00 2001 From: Edgar Pireyn Date: Thu, 20 Jun 2024 19:26:41 +0200 Subject: [PATCH 2/3] fix: Clean code and follow guidelines --- .../{HideOfferTabPatch.kt => layout/HideOffersTabPatch.kt} | 6 +++--- .../patches/stocard/{ => layout}/HideStoriesPatch.kt | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) rename src/main/kotlin/app/revanced/patches/stocard/{HideOfferTabPatch.kt => layout/HideOffersTabPatch.kt} (84%) rename src/main/kotlin/app/revanced/patches/stocard/{ => layout}/HideStoriesPatch.kt (89%) diff --git a/src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt rename to src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt index 2584f80c42..c2deecead4 100644 --- a/src/main/kotlin/app/revanced/patches/stocard/HideOfferTabPatch.kt +++ b/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.stocard +package app.revanced.patches.stocard.layout import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch @@ -6,8 +6,8 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.util.childElementsSequence -@Patch(name = "Hide offers tab", compatiblePackages = [CompatiblePackage("de.stocard.stocard", ["10.50.0"])]) -object HideOfferTabPatch : ResourcePatch() { +@Patch(name = "Hide offers tab", compatiblePackages = [CompatiblePackage("de.stocard.stocard")]) +object HideOffersTabPatch : ResourcePatch() { override fun execute(context: ResourceContext) { context.document["res/menu/bottom_navigation_menu.xml"].use { document -> val menu = document.getElementsByTagName("menu").item(0) diff --git a/src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt rename to src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.kt index 3df57782b5..e7c026e033 100644 --- a/src/main/kotlin/app/revanced/patches/stocard/HideStoriesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.stocard +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 -@Patch(name = "Hide story bubbles", compatiblePackages = [CompatiblePackage("de.stocard.stocard", ["10.50.0"])]) +@Patch(name = "Hide story bubbles", compatiblePackages = [CompatiblePackage("de.stocard.stocard")]) object HideStoriesPatch : ResourcePatch() { override fun execute(context: ResourceContext) { context.document["res/layout/rv_story_bubbles_list.xml"].use { document -> @@ -14,5 +14,4 @@ object HideStoriesPatch : ResourcePatch() { view.attributes.getNamedItem("android:layout_height").nodeValue = "0dp" } } - } \ No newline at end of file From 177a52ca380c615b352ce10355fa19f3fea79136 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 27 Jun 2024 13:28:29 +0200 Subject: [PATCH 3/3] refactor --- api/revanced-patches.api | 12 +++++++++ .../stocard/layout/HideOffersTabPatch.kt | 19 +++++++++---- .../stocard/layout/HideStoriesPatch.kt | 17 ------------ .../stocard/layout/HideStoryBubblesPatch.kt | 27 +++++++++++++++++++ 4 files changed, 53 insertions(+), 22 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.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 2eb9a62f35..bdb37b3a97 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -1034,6 +1034,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 index c2deecead4..6b493c4b15 100644 --- a/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt +++ b/src/main/kotlin/app/revanced/patches/stocard/layout/HideOffersTabPatch.kt @@ -5,14 +5,23 @@ 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")]) +@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 -> - val menu = document.getElementsByTagName("menu").item(0) - menu.removeChild(menu.childElementsSequence() - .first { it.attributes.getNamedItem("android:id")?.nodeValue?.contains("offer") ?: false }) + document.getNode("menu").apply { + removeChild( + childElementsSequence().first { + it.attributes.getNamedItem("android:id")?.nodeValue?.contains("offer") ?: false + }, + ) + } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.kt b/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.kt deleted file mode 100644 index e7c026e033..0000000000 --- a/src/main/kotlin/app/revanced/patches/stocard/layout/HideStoriesPatch.kt +++ /dev/null @@ -1,17 +0,0 @@ -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 - -@Patch(name = "Hide story bubbles", compatiblePackages = [CompatiblePackage("de.stocard.stocard")]) -object HideStoriesPatch : ResourcePatch() { - override fun execute(context: ResourceContext) { - context.document["res/layout/rv_story_bubbles_list.xml"].use { document -> - val view = document.getElementsByTagName("androidx.recyclerview.widget.RecyclerView").item(0) - view.attributes.getNamedItem("android:layout_width").nodeValue = "0dp" - view.attributes.getNamedItem("android:layout_height").nodeValue = "0dp" - } - } -} \ No newline at end of file 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 0000000000..eecdeb38d8 --- /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" + } + } + } + } +}