-
-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reddit): add
disable-screenshot-popup
patch (#2387)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...s/reddit/layout/disablescreenshotpopup/annotations/DisableScreenshotPopupCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
14 changes: 14 additions & 0 deletions
14
...es/reddit/layout/disablescreenshotpopup/fingerprints/DisableScreenshotPopupFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
) |
30 changes: 30 additions & 0 deletions
30
...evanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |