From 56b535b2a136d4b0afbddf2c8e251889c2555056 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 25 Jul 2023 01:36:28 +0200 Subject: [PATCH] feat(Sync for Reddit): add `Disable Sync for Lemmy bottom sheet` patch --- .../fingerprints/MainActivityOnCreate.kt | 9 +++++ .../DisableSyncForLemmyBottomSheetPatch.kt | 35 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/fingerprints/MainActivityOnCreate.kt create mode 100644 src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/patch/DisableSyncForLemmyBottomSheetPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/fingerprints/MainActivityOnCreate.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/fingerprints/MainActivityOnCreate.kt new file mode 100644 index 0000000000..6473502526 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/fingerprints/MainActivityOnCreate.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.reddit.customclients.syncforreddit.annoyances.startup.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object MainActivityOnCreate : MethodFingerprint( + customFingerprint = custom@{ method, classDef -> + classDef.type.endsWith("MainActivity;") && method.name == "onCreate" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/patch/DisableSyncForLemmyBottomSheetPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/patch/DisableSyncForLemmyBottomSheetPatch.kt new file mode 100644 index 0000000000..e47e6ea013 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/patch/DisableSyncForLemmyBottomSheetPatch.kt @@ -0,0 +1,35 @@ +package app.revanced.patches.reddit.customclients.syncforreddit.annoyances.startup.patch + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Package +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.reddit.customclients.syncforreddit.annoyances.startup.fingerprints.MainActivityOnCreate + +@Patch +@Name("Disable Sync for Lemmy bottom sheet") +@Description("Disables the bottom sheet at the startup that asks you to signup to \"Sync for Lemmy\".") +@Compatibility( + [ + Package("com.laurencedawson.reddit_sync", ["v23.06.30-13:39"]), + Package("com.laurencedawson.reddit_sync.pro"), // Version unknown. + Package("com.laurencedawson.reddit_sync.dev") // Version unknown. + ] +) +class DisableSyncForLemmyBottomSheetPatch : BytecodePatch(listOf(MainActivityOnCreate)) { + override fun execute(context: BytecodeContext): PatchResult { + MainActivityOnCreate.result?.mutableMethod?.apply { + val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1 + + removeInstruction(showBottomSheetIndex) + } + + return PatchResultSuccess() + } +} \ No newline at end of file