diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SendTypingIndicatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SendTypingIndicatorFingerprint.kt new file mode 100644 index 0000000000..cff25ae299 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SendTypingIndicatorFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.messenger.inputfield.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.dexbacked.value.DexBackedStringEncodedValue + +object SendTypingIndicatorFingerprint : MethodFingerprint( + returnType = "V", + parameters = listOf(), + customFingerprint = { methodDef, classDef -> + methodDef.name == "run" && classDef.fields.any { + it.name == "__redex_internal_original_name" + && (it.initialValue as? DexBackedStringEncodedValue)?.value == "ConversationTypingContext\$sendActiveStateRunnable\$1" + } + } +) diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt new file mode 100644 index 0000000000..d25d46ed94 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt @@ -0,0 +1,29 @@ +package app.revanced.patches.messenger.inputfield.patch + +import app.revanced.extensions.toErrorResult +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.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.replaceInstruction +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.messenger.inputfield.fingerprints.SendTypingIndicatorFingerprint + +@Patch +@Name("disable-typing-indicator") +@Description("Disables the indicator while typing a message") +@Compatibility([Package("com.facebook.orca")]) +@Version("0.0.1") +class DisableTypingIndicator : BytecodePatch(listOf(SendTypingIndicatorFingerprint)) { + override fun execute(context: BytecodeContext): PatchResult { + SendTypingIndicatorFingerprint.result?.mutableMethod?.replaceInstruction(0, "return-void") + ?: throw SendTypingIndicatorFingerprint.toErrorResult() + + return PatchResultSuccess() + } +}