diff --git a/.idea/misc.xml b/.idea/misc.xml index f1854e4b53..e086a70c4e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/annotations/DisableScreenshotPopupCompatibility.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/annotations/DisableScreenshotPopupCompatibility.kt new file mode 100644 index 0000000000..d0620b564f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/annotations/DisableScreenshotPopupCompatibility.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.reddit.layout.disablescreenshotpopup.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.reddit.frontpage")]) +@Target(AnnotationTarget.CLASS) +internal annotation class DisableScreenshotPopupCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/fingerprints/DisableScreenshotPopupFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/fingerprints/DisableScreenshotPopupFingerprint.kt new file mode 100644 index 0000000000..de74945c2f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/fingerprints/DisableScreenshotPopupFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object DisableScreenshotPopupFingerprint : MethodFingerprint( + "V", + parameters = listOf("Landroidx/compose/runtime/", "I"), + customFingerprint = custom@{ methodDef, classDef -> + if (!classDef.type.endsWith("\$ScreenshotTakenBannerKt\$lambda-1\$1;")) + return@custom false + + methodDef.name == "invoke" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt new file mode 100644 index 0000000000..6c6c652b85 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.reddit.layout.disablescreenshotpopup.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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.layout.disablescreenshotpopup.annotations.DisableScreenshotPopupCompatibility +import app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints.DisableScreenshotPopupFingerprint + +@Patch +@Name("disable-screenshot-popup") +@Description("Disables the popup that shows up when taking a screenshot.") +@DisableScreenshotPopupCompatibility +@Version("0.0.1") +class DisableScreenshotPopupPatch : BytecodePatch( + listOf(DisableScreenshotPopupFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + DisableScreenshotPopupFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") + ?: return DisableScreenshotPopupFingerprint.toErrorResult() + + return PatchResultSuccess() + } +}