feat(ticktick): unlock-themes patch (#1028)

This commit is contained in:
Jonathan 2022-11-13 02:22:40 +01:00 committed by GitHub
parent 7e6b453401
commit 7f1fedcddd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,9 @@
package app.revanced.patches.ticktick.misc.themeunlock.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.ticktick.task")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class UnlockThemesCompatibility

View file

@ -0,0 +1,15 @@
package app.revanced.patches.ticktick.misc.themeunlock.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.ticktick.misc.themeunlock.annotations.UnlockThemesCompatibility
@Name("check-locked-theme-fingerprint")
@UnlockThemesCompatibility
@Version("0.0.1")
object CheckLockedThemesFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("Theme;") && methodDef.name == "isLockedTheme"
}
)

View file

@ -0,0 +1,15 @@
package app.revanced.patches.ticktick.misc.themeunlock.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.ticktick.misc.themeunlock.annotations.UnlockThemesCompatibility
@Name("set-theme-fingerprint")
@UnlockThemesCompatibility
@Version("0.0.1")
object SetThemeFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("ThemePreviewActivity;") && methodDef.name == "lambda\$updateUserBtn\$1"
}
)

View file

@ -0,0 +1,43 @@
package app.revanced.patches.ticktick.misc.themeunlock.patch
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.addInstructions
import app.revanced.patcher.extensions.removeInstructions
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.ticktick.misc.themeunlock.annotations.UnlockThemesCompatibility
import app.revanced.patches.ticktick.misc.themeunlock.fingerprints.CheckLockedThemesFingerprint
import app.revanced.patches.ticktick.misc.themeunlock.fingerprints.SetThemeFingerprint
@Patch
@Name("unlock-themes")
@Description("Unlocks all themes.")
@UnlockThemesCompatibility
@Version("0.0.1")
class UnlockProPatch : BytecodePatch(
listOf(
CheckLockedThemesFingerprint,
SetThemeFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val lockedThemesMethod = CheckLockedThemesFingerprint.result!!.mutableMethod
lockedThemesMethod.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
)
val setThemeMethod = SetThemeFingerprint.result!!.mutableMethod
setThemeMethod.removeInstructions(0, 9)
return PatchResultSuccess()
}
}