diff --git a/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/annotations/UnlockThemesCompatibility.kt b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/annotations/UnlockThemesCompatibility.kt new file mode 100644 index 000000000..cc096640e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/annotations/UnlockThemesCompatibility.kt @@ -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 diff --git a/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/fingerprints/CheckLockedThemesFingerprint.kt b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/fingerprints/CheckLockedThemesFingerprint.kt new file mode 100644 index 000000000..0d6f167a9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/fingerprints/CheckLockedThemesFingerprint.kt @@ -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" + } +) diff --git a/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/fingerprints/SetThemeFingerprint.kt b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/fingerprints/SetThemeFingerprint.kt new file mode 100644 index 000000000..d9d3dc447 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/fingerprints/SetThemeFingerprint.kt @@ -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" + } +) diff --git a/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt new file mode 100644 index 000000000..e1b6664e7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt @@ -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() + } +}