forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(X): Add
Open links as query
patch (ReVanced#2730)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/app/revanced/patches/twitter/misc/links/OpenLinksWithAppChooserPatch.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,35 @@ | ||
package app.revanced.patches.twitter.misc.links | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.twitter.misc.links.fingerprints.OpenLinkFingerprint | ||
import app.revanced.util.exception | ||
|
||
@Patch( | ||
name = "Open links with app chooser", | ||
description = "Instead of opening links directly, open them with an app chooser. " + | ||
"As a result you can select a browser to open the link with.", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = false, | ||
) | ||
@Suppress("unused") | ||
object OpenLinksWithAppChooserPatch : BytecodePatch( | ||
setOf(OpenLinkFingerprint), | ||
) { | ||
private const val METHOD_REFERENCE = | ||
"Lapp/revanced/integrations/twitter/patches/links/OpenLinksWithAppChooserPatch;->" + | ||
"openWithChooser(Landroid/content/Context;Landroid/content/Intent;)V" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
OpenLinkFingerprint.result?.mutableMethod?.addInstructions( | ||
0, | ||
""" | ||
invoke-static { p0, p1 }, $METHOD_REFERENCE | ||
return-void | ||
""", | ||
) ?: throw OpenLinkFingerprint.exception | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/app/revanced/patches/twitter/misc/links/fingerprints/OpenLinkFingerprint.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.twitter.misc.links.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
internal object OpenLinkFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
parameters = listOf("Landroid/content/Context;", "Landroid/content/Intent;", "Landroid/os/Bundle;"), | ||
) |