From 716825f232bf1aab3a97723968562aa6dbdb20b1 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 1 Dec 2023 23:10:23 +0100 Subject: [PATCH 1/7] fix: Accept `PatchSet` in `PatchesConsumer#acceptPatches` This deprecates accepting `List>` --- api/revanced-patcher.api | 6 ++++++ src/main/kotlin/app/revanced/patcher/Patcher.kt | 2 +- src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/revanced-patcher.api b/api/revanced-patcher.api index 573e5fe..42c78a4 100644 --- a/api/revanced-patcher.api +++ b/api/revanced-patcher.api @@ -44,6 +44,7 @@ public final class app/revanced/patcher/Patcher : app/revanced/patcher/Integrati public fun (Lapp/revanced/patcher/PatcherOptions;)V public fun acceptIntegrations (Ljava/util/List;)V public fun acceptPatches (Ljava/util/List;)V + public fun acceptPatches (Ljava/util/Set;)V public synthetic fun apply (Ljava/lang/Object;)Ljava/lang/Object; public fun apply (Z)Lkotlinx/coroutines/flow/Flow; public fun close ()V @@ -99,6 +100,11 @@ public final class app/revanced/patcher/PatcherResult$PatchedDexFile { public abstract interface class app/revanced/patcher/PatchesConsumer { public abstract fun acceptPatches (Ljava/util/List;)V + public abstract fun acceptPatches (Ljava/util/Set;)V +} + +public final class app/revanced/patcher/PatchesConsumer$DefaultImpls { + public static fun acceptPatches (Lapp/revanced/patcher/PatchesConsumer;Ljava/util/List;)V } public final class app/revanced/patcher/data/BytecodeContext : app/revanced/patcher/data/Context { diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index 2c9f67c..86b2a1a 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -46,7 +46,7 @@ class Patcher( * @param patches The [Patch]es to add. */ @Suppress("NAME_SHADOWING") - override fun acceptPatches(patches: List>) { + override fun acceptPatches(patches: PatchSet) { /** * Add dependencies of a [Patch] recursively to [PatcherContext.allPatches]. * If a [Patch] is already in [PatcherContext.allPatches], it will not be added again. diff --git a/src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt b/src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt index 91b83b9..24533bb 100644 --- a/src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt +++ b/src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt @@ -4,5 +4,7 @@ import app.revanced.patcher.patch.Patch @FunctionalInterface interface PatchesConsumer { - fun acceptPatches(patches: List>) + @Deprecated("Use acceptPatches(PatchSet) instead.", ReplaceWith("acceptPatches(patches.toSet())")) + fun acceptPatches(patches: List>) = acceptPatches(patches.toSet()) + fun acceptPatches(patches: PatchSet) } From f8baabbcec12e2809361941442a53558d7107ab3 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 1 Dec 2023 23:13:49 +0100 Subject: [PATCH 2/7] build: Bump dependencies --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f23b645..85941e6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ android = "4.1.1.4" kotlin-reflect = "1.9.10" apktool-lib = "2.9.1" -kotlin-test = "1.9.10" +kotlin-test = "1.9.20" kotlinx-coroutines-core = "1.7.3" multidexlib2 = "3.0.3.r3" smali = "3.0.3" From 2d7fffd4ecac48e3f83f4f437029326b6ae5093a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 1 Dec 2023 22:15:43 +0000 Subject: [PATCH 3/7] chore(release): 19.1.1-dev.1 [skip ci] ## [19.1.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.1.1-dev.1) (2023-12-01) ### Bug Fixes * Accept `PatchSet` in `PatchesConsumer#acceptPatches` ([716825f](https://github.com/ReVanced/revanced-patcher/commit/716825f232bf1aab3a97723968562aa6dbdb20b1)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 569ec8f..7d00e70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [19.1.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.1.1-dev.1) (2023-12-01) + + +### Bug Fixes + +* Accept `PatchSet` in `PatchesConsumer#acceptPatches` ([716825f](https://github.com/ReVanced/revanced-patcher/commit/716825f232bf1aab3a97723968562aa6dbdb20b1)) + # [19.1.0](https://github.com/ReVanced/revanced-patcher/compare/v19.0.0...v19.1.0) (2023-12-01) diff --git a/gradle.properties b/gradle.properties index 1408393..ba42b11 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true kotlin.code.style = official -version = 19.1.0 +version = 19.1.1-dev.1 From e7dacfba8c86fde4c40173c53268564b42331eb4 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 10 Dec 2023 21:57:10 +0100 Subject: [PATCH 4/7] build: Simplify enabling local build cache --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 0c24b32..37f0d02 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,6 +2,6 @@ rootProject.name = "revanced-patcher" buildCache { local { - isEnabled = !System.getenv().containsKey("CI") + isEnabled = "CI" !in System.getenv() } } From 0a482f8c9a2d496e254fc138e6e9289a68583d0b Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 22 Dec 2023 03:09:42 +0100 Subject: [PATCH 5/7] refactor: Reduce duplicate code by using a common function to register options --- .../patcher/patch/options/PatchOption.kt | 86 ++++++++++++++----- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt index ad0f6fe..518065b 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt @@ -80,6 +80,7 @@ open class PatchOption( if (!validator(value)) throw PatchOptionException.ValueValidationException(value, this) } + override fun toString() = value.toString() operator fun getValue( @@ -120,7 +121,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption.(String?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -129,7 +130,7 @@ open class PatchOption( required, "String", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with an integer value and add it to the current [Patch]. @@ -154,7 +155,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption.(Int?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -163,7 +164,7 @@ open class PatchOption( required, "Int", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with a boolean value and add it to the current [Patch]. @@ -188,9 +189,16 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption.(Boolean?) -> Boolean = { true }, - ) = PatchOption(key, default, values, title, description, required, "Boolean", validator).also { - registerOption(it) - } + ) = registerNewPatchOption( + key, + default, + values, + title, + description, + required, + "Boolean", + validator, + ) /** * Create a new [PatchOption] with a float value and add it to the current [Patch]. @@ -215,7 +223,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption.(Float?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -224,7 +232,7 @@ open class PatchOption( required, "Float", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with a long value and add it to the current [Patch]. @@ -249,7 +257,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption.(Long?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -258,7 +266,7 @@ open class PatchOption( required, "Long", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with a string array value and add it to the current [Patch]. @@ -283,7 +291,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption?>.(Array?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -292,7 +300,7 @@ open class PatchOption( required, "StringArray", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with an integer array value and add it to the current [Patch]. @@ -317,7 +325,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption?>.(Array?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -326,7 +334,7 @@ open class PatchOption( required, "IntArray", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with a boolean array value and add it to the current [Patch]. @@ -351,7 +359,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption?>.(Array?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -360,7 +368,7 @@ open class PatchOption( required, "BooleanArray", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with a float array value and add it to the current [Patch]. @@ -385,7 +393,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption?>.(Array?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -394,7 +402,7 @@ open class PatchOption( required, "FloatArray", validator, - ).also { registerOption(it) } + ) /** * Create a new [PatchOption] with a long array value and add it to the current [Patch]. @@ -419,7 +427,7 @@ open class PatchOption( description: String? = null, required: Boolean = false, validator: PatchOption?>.(Array?) -> Boolean = { true }, - ) = PatchOption( + ) = registerNewPatchOption( key, default, values, @@ -428,8 +436,42 @@ open class PatchOption( required, "LongArray", validator, - ).also { registerOption(it) } + ) - private fun

> P.registerOption(option: PatchOption<*>) = option.also { options.register(it) } + /** + * Create a new [PatchOption] with a string set value and add it to the current [Patch]. + * + * @param key The identifier. + * @param default The default value. + * @param values The set of guaranteed valid values identified by their string representation. + * @param title The title. + * @param description A description. + * @param required Whether the option is required. + * @param valueType The type of the option value (to handle type erasure). + * @param validator The function to validate the option value. + * + * @return The created [PatchOption]. + * + * @see PatchOption + */ + private fun

, T> P.registerNewPatchOption( + key: String, + default: T? = null, + values: Map? = null, + title: String? = null, + description: String? = null, + required: Boolean = false, + valueType: String, + validator: PatchOption.(T?) -> Boolean = { true }, + ) = PatchOption( + key, + default, + values, + title, + description, + required, + valueType, + validator, + ).also(options::register) } } From 4a9184597be99cd458496cce0ee68994e6b8735c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 22 Dec 2023 03:20:50 +0100 Subject: [PATCH 6/7] feat: Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options --- api/revanced-patcher.api | 2 ++ .../kotlin/app/revanced/patcher/patch/options/PatchOption.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/revanced-patcher.api b/api/revanced-patcher.api index 42c78a4..5c2d9ff 100644 --- a/api/revanced-patcher.api +++ b/api/revanced-patcher.api @@ -335,6 +335,8 @@ public final class app/revanced/patcher/patch/options/PatchOption$PatchExtension public static synthetic fun longArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption; public final fun longPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption; public static synthetic fun longPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption; + public final fun registerNewPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;Lkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption; + public static synthetic fun registerNewPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption; public final fun stringArrayPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption; public static synthetic fun stringArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption; public final fun stringPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption; diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt index 518065b..cc0d130 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt @@ -454,7 +454,7 @@ open class PatchOption( * * @see PatchOption */ - private fun

, T> P.registerNewPatchOption( + fun

, T> P.registerNewPatchOption( key: String, default: T? = null, values: Map? = null, From d03591b73550df74bba85590d1d153839c4412ca Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 22 Dec 2023 02:23:04 +0000 Subject: [PATCH 7/7] chore(release): 19.2.0-dev.1 [skip ci] # [19.2.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.1-dev.1...v19.2.0-dev.1) (2023-12-22) ### Features * Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options ([4a91845](https://github.com/ReVanced/revanced-patcher/commit/4a9184597be99cd458496cce0ee68994e6b8735c)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d00e70..91a4893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [19.2.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.1-dev.1...v19.2.0-dev.1) (2023-12-22) + + +### Features + +* Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options ([4a91845](https://github.com/ReVanced/revanced-patcher/commit/4a9184597be99cd458496cce0ee68994e6b8735c)) + ## [19.1.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.1.1-dev.1) (2023-12-01) diff --git a/gradle.properties b/gradle.properties index ba42b11..6ab48ba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true kotlin.code.style = official -version = 19.1.1-dev.1 +version = 19.2.0-dev.1