diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/AgendaDaysWidgetUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/AgendaDaysWidgetUnlockFingerprint.kt new file mode 100644 index 00000000..33277fe7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/AgendaDaysWidgetUnlockFingerprint.kt @@ -0,0 +1,5 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object AgendaDaysWidgetUnlockFingerprint : MethodUnlockFingerprint("AgendaDaysWidgetConfigureActivity") diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarBigWidgetUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarBigWidgetUnlockFingerprint.kt new file mode 100644 index 00000000..4245820d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarBigWidgetUnlockFingerprint.kt @@ -0,0 +1,5 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object CalendarBigWidgetUnlockFingerprint : MethodUnlockFingerprint("CalendarBigWidgetConfigureActivity") diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarWideDayEventsWidgetUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarWideDayEventsWidgetUnlockFingerprint.kt new file mode 100644 index 00000000..adf3b82a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarWideDayEventsWidgetUnlockFingerprint.kt @@ -0,0 +1,4 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +object CalendarWideDayEventsWidgetUnlockFingerprint : + MethodUnlockFingerprint("CalendarWideDayEventsWidgetConfigureActivity") diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarWideTimelineWidgetUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarWideTimelineWidgetUnlockFingerprint.kt new file mode 100644 index 00000000..3b7bb2ed --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/CalendarWideTimelineWidgetUnlockFingerprint.kt @@ -0,0 +1,6 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object CalendarWideTimelineWidgetUnlockFingerprint : + MethodUnlockFingerprint("CalendarWideTimelineWidgetConfigureActivity") diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/MethodUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/MethodUnlockFingerprint.kt new file mode 100644 index 00000000..c85e6c92 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/MethodUnlockFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +abstract class MethodUnlockFingerprint(private val className: String) : MethodFingerprint( + "L", + strings = listOf("binding.addButton"), + customFingerprint = { methodDef -> + methodDef.definingClass.endsWith("/$className;") + } +) + diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/ScreentimeSmallWidgetUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/ScreentimeSmallWidgetUnlockFingerprint.kt new file mode 100644 index 00000000..f2c0252d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/ScreentimeSmallWidgetUnlockFingerprint.kt @@ -0,0 +1,5 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object ScreentimeSmallWidgetUnlockFingerprint : MethodUnlockFingerprint("ScreentimeSmallWidgetConfigureActivity") diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/WeatherWidgetUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/WeatherWidgetUnlockFingerprint.kt new file mode 100644 index 00000000..17bd9e95 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/fingerprints/WeatherWidgetUnlockFingerprint.kt @@ -0,0 +1,3 @@ +package app.revanced.patches.twelvewidgets.unlock.fingerprints + +object WeatherWidgetUnlockFingerprint : MethodUnlockFingerprint("WeatherWidgetConfigureActivity") diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt new file mode 100644 index 00000000..8a188600 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt @@ -0,0 +1,54 @@ +package app.revanced.patches.twelvewidgets.unlock.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.* +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.twelvewidgets.unlock.fingerprints.* + +@Patch +@Name("unlock-paid-widgets") +@Description("Unlocks paid widgets of the app") +@Compatibility([Package("com.dci.dev.androidtwelvewidgets")]) +@Version("0.0.1") +class UnlockPaidWidgetsPatch : BytecodePatch( + listOf( + AgendaDaysWidgetUnlockFingerprint, + CalendarBigWidgetUnlockFingerprint, + CalendarWideDayEventsWidgetUnlockFingerprint, + CalendarWideTimelineWidgetUnlockFingerprint, + ScreentimeSmallWidgetUnlockFingerprint, + WeatherWidgetUnlockFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + listOf( + AgendaDaysWidgetUnlockFingerprint, + CalendarBigWidgetUnlockFingerprint, + CalendarWideDayEventsWidgetUnlockFingerprint, + CalendarWideTimelineWidgetUnlockFingerprint, + ScreentimeSmallWidgetUnlockFingerprint, + WeatherWidgetUnlockFingerprint + ).map { fingerprint -> + fingerprint.result?.mutableMethod ?: return fingerprint.toErrorResult() + }.forEach { method -> + method.apply { + removeInstructions(4, 2) + addInstructions( + implementation?.instructions?.size!!, """ + const/4 v1, 0x0 + invoke-virtual {v0, v1}, Landroid/view/View;->setVisibility(I)V + return-object v0 + """ + ) + } + } + + return PatchResultSuccess() + } +}