Skip to content

Commit

Permalink
feat(ticktick): unlock-themes patch (#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
FineFindus committed Nov 13, 2022
1 parent 34c73b7 commit ade2263
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
}
)
Original file line number Diff line number Diff line change
@@ -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"
}
)
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit ade2263

Please sign in to comment.