refactor(photomath): HideUpdatePopupPatch

This commit is contained in:
Pun Butrach
2026-01-12 17:22:27 +07:00
parent 70328c5a65
commit be005c533a
2 changed files with 22 additions and 18 deletions

View File

@@ -1,21 +1,25 @@
package app.revanced.patches.photomath.misc.annoyances
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.accessFlags
import app.revanced.patcher.definingClass
import app.revanced.patcher.fingerprint
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal val hideUpdatePopupFingerprint = fingerprint {
internal val BytecodePatchContext.hideUpdatePopupMethod by gettingFirstMutableMethodDeclaratively {
accessFlags(AccessFlags.FINAL, AccessFlags.PUBLIC)
returns("V")
opcodes(
Opcode.CONST_HIGH16,
Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.alpha(1.0f)
Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST_WIDE_16,
Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.setDuration(1000L)
returnType("V")
definingClass("Lcom/microblink/photomath/main/activity/MainActivity;")
instructions(
Opcode.CONST_HIGH16(),
Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.alpha(1.0f)
Opcode.MOVE_RESULT_OBJECT(),
Opcode.CONST_WIDE_16(),
Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.setDuration(1000L)
)
custom { method, _ ->
// The popup is shown only in the main activity
method.definingClass == "Lcom/microblink/photomath/main/activity/MainActivity;"
}
}

View File

@@ -1,20 +1,20 @@
package app.revanced.patches.photomath.misc.annoyances
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch
import app.revanced.patcher.patch.creatingBytecodePatch
import app.revanced.patches.photomath.detection.signature.`Signature detection`
@Suppress("unused")
val hideUpdatePopupPatch = bytecodePatch(
name = "Hide update popup",
val `Hide update popup` by creatingBytecodePatch(
description = "Prevents the update popup from showing up.",
) {
dependsOn(signatureDetectionPatch)
dependsOn(`Signature detection`)
compatibleWith("com.microblink.photomath")
apply {
hideUpdatePopupFingerprint.method.addInstructions(
hideUpdatePopupMethod.addInstructions(
2, // Insert after the null check.
"return-void",
)