You've already forked revanced-patcher
mirror of
https://github.com/revanced/revanced-patcher
synced 2025-09-06 16:38:50 +02:00
Compare commits
4 Commits
v19.1.1-de
...
v19.2.0-de
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d03591b735 | ||
![]() |
4a9184597b | ||
![]() |
0a482f8c9a | ||
![]() |
e7dacfba8c |
@@ -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)
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -2,6 +2,6 @@ rootProject.name = "revanced-patcher"
|
||||
|
||||
buildCache {
|
||||
local {
|
||||
isEnabled = !System.getenv().containsKey("CI")
|
||||
isEnabled = "CI" !in System.getenv()
|
||||
}
|
||||
}
|
||||
|
@@ -80,6 +80,7 @@ open class PatchOption<T>(
|
||||
if (!validator(value)) throw PatchOptionException.ValueValidationException(value, this)
|
||||
}
|
||||
|
||||
|
||||
override fun toString() = value.toString()
|
||||
|
||||
operator fun getValue(
|
||||
@@ -120,7 +121,7 @@ open class PatchOption<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<String>.(String?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -129,7 +130,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Int?>.(Int?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -163,7 +164,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Boolean?>.(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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Float?>.(Float?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -224,7 +232,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Long?>.(Long?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -258,7 +266,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Array<String>?>.(Array<String>?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -292,7 +300,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Array<Int>?>.(Array<Int>?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -326,7 +334,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Array<Boolean>?>.(Array<Boolean>?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -360,7 +368,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Array<Float>?>.(Array<Float>?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -394,7 +402,7 @@ open class PatchOption<T>(
|
||||
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<T>(
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
validator: PatchOption<Array<Long>?>.(Array<Long>?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
) = registerNewPatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
@@ -428,8 +436,42 @@ open class PatchOption<T>(
|
||||
required,
|
||||
"LongArray",
|
||||
validator,
|
||||
).also { registerOption(it) }
|
||||
)
|
||||
|
||||
private fun <P : Patch<*>> 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
|
||||
*/
|
||||
fun <P : Patch<*>, T> P.registerNewPatchOption(
|
||||
key: String,
|
||||
default: T? = null,
|
||||
values: Map<String, T?>? = null,
|
||||
title: String? = null,
|
||||
description: String? = null,
|
||||
required: Boolean = false,
|
||||
valueType: String,
|
||||
validator: PatchOption<T>.(T?) -> Boolean = { true },
|
||||
) = PatchOption(
|
||||
key,
|
||||
default,
|
||||
values,
|
||||
title,
|
||||
description,
|
||||
required,
|
||||
valueType,
|
||||
validator,
|
||||
).also(options::register)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user