feat: add deprecated & options to patches.json
This commit is contained in:
parent
ecc9086940
commit
4b917b21b7
|
@ -12,16 +12,23 @@ This section explains the JSON format for the [patches.json](patches.json) file.
|
|||
|
||||
The file contains an array of objects, each object representing a patch. The object contains the following properties:
|
||||
|
||||
| key | description |
|
||||
|-------------------------------|------------------------------------------------------------------------------------------------------------------|
|
||||
| `name` | The name of the patch. |
|
||||
| `description` | The description of the patch. |
|
||||
| `version` | The version of the patch. |
|
||||
| `excluded` | Whether a patch is excluded by default. If `true`, the patch must never be included by default. |
|
||||
| `dependencies` | An array of dependencies, which are patch names. |
|
||||
| `compatiblePackages` | An array of packages compatible with this patch. |
|
||||
| `compatiblePackages.name` | The name of the package. |
|
||||
| `compatiblePackages.versions` | An array of versions of the package compatible with this patch. If empty, all versions are seemingly compatible. |
|
||||
| key | description |
|
||||
|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `name` | The name of the patch. |
|
||||
| `description` | The description of the patch. |
|
||||
| `version` | The version of the patch. |
|
||||
| `excluded` | Whether the patch is excluded by default. If `true`, the patch must never be included by default. |
|
||||
| `deprecated` | Whether the patch is deprecated. |
|
||||
| `options` | An array of options for this patch. |
|
||||
| `options.key` | The key of the option. |
|
||||
| `options.title` | The title of the option. |
|
||||
| `options.description` | The description of the option. |
|
||||
| `options.required` | Whether the option is required. |
|
||||
| `options.choices?` | An array of choices of the option. This may be `null` if this option has no choices. The element type of this array may be any type. It can be a `String`, `Int` or something else. |
|
||||
| `dependencies` | An array of dependencies, which are patch names. |
|
||||
| `compatiblePackages` | An array of packages compatible with this patch. |
|
||||
| `compatiblePackages.name` | The name of the package. |
|
||||
| `compatiblePackages.versions` | An array of versions of the package compatible with this patch. If empty, all versions are seemingly compatible. |
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -32,6 +39,8 @@ Example:
|
|||
"description": "Adds the ability to remember the video quality you chose in the video quality flyout.",
|
||||
"version": "0.0.1",
|
||||
"excluded": false,
|
||||
"deprecated": false,
|
||||
"options": [],
|
||||
"dependencies": [
|
||||
"integrations",
|
||||
"video-id-hook"
|
||||
|
@ -46,24 +55,67 @@ Example:
|
|||
"17.27.39",
|
||||
"17.28.34",
|
||||
"17.29.34",
|
||||
"17.32.35"
|
||||
"17.32.35",
|
||||
"17.33.42"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "client-spoof",
|
||||
"description": "Spoofs the YouTube or Vanced client to prevent playback issues.",
|
||||
"name": "theme",
|
||||
"description": "Enables a custom theme.",
|
||||
"version": "0.0.1",
|
||||
"excluded": false,
|
||||
"dependencies": [],
|
||||
"deprecated": false,
|
||||
"options": [
|
||||
{
|
||||
"key": "theme",
|
||||
"title": "Theme",
|
||||
"description": "Select a theme.",
|
||||
"required": true,
|
||||
"choices": [
|
||||
"Amoled"
|
||||
]
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
"locale-config-fix"
|
||||
],
|
||||
"compatiblePackages": [
|
||||
{
|
||||
"name": "com.google.android.youtube",
|
||||
"versions": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "custom-branding",
|
||||
"description": "Changes the YouTube launcher icon and name to your choice (defaults to ReVanced).",
|
||||
"version": "0.0.1",
|
||||
"excluded": false,
|
||||
"deprecated": false,
|
||||
"options": [
|
||||
{
|
||||
"key": "appName",
|
||||
"title": "Application Name",
|
||||
"description": "The name of the application it will show on your home screen.",
|
||||
"required": true,
|
||||
"choices": null
|
||||
},
|
||||
{
|
||||
"name": "com.vanced.android.youtube",
|
||||
"key": "appIconPath",
|
||||
"title": "Application Icon Path",
|
||||
"description": "A path to the icon of the application.",
|
||||
"required": false,
|
||||
"choices": null
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
"locale-config-fix"
|
||||
],
|
||||
"compatiblePackages": [
|
||||
{
|
||||
"name": "com.google.android.youtube",
|
||||
"versions": []
|
||||
}
|
||||
]
|
||||
|
|
|
@ -3,14 +3,17 @@ package app.revanced.meta.json
|
|||
import app.revanced.meta.Bundle
|
||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||
import app.revanced.patcher.extensions.PatchExtensions.dependencies
|
||||
import app.revanced.patcher.extensions.PatchExtensions.deprecated
|
||||
import app.revanced.patcher.extensions.PatchExtensions.description
|
||||
import app.revanced.patcher.extensions.PatchExtensions.include
|
||||
import app.revanced.patcher.extensions.PatchExtensions.options
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.extensions.PatchExtensions.version
|
||||
import com.google.gson.Gson
|
||||
import app.revanced.patcher.patch.PatchOption
|
||||
import com.google.gson.GsonBuilder
|
||||
import java.io.File
|
||||
|
||||
private val gson = Gson()
|
||||
private val gson = GsonBuilder().serializeNulls().create()
|
||||
|
||||
fun generateJson(bundle: Bundle) {
|
||||
val patches = bundle.map {
|
||||
|
@ -19,6 +22,20 @@ fun generateJson(bundle: Bundle) {
|
|||
it.description ?: "This patch has no description.",
|
||||
it.version ?: "0.0.0",
|
||||
!it.include,
|
||||
it.deprecated != null,
|
||||
it.options?.map { option ->
|
||||
Option(
|
||||
option.key,
|
||||
option.title,
|
||||
option.description,
|
||||
option.required,
|
||||
option.let { lo ->
|
||||
if (lo is PatchOption.ListOption<*>) {
|
||||
lo.options.toMutableList().toTypedArray()
|
||||
} else null
|
||||
}
|
||||
)
|
||||
}?.toTypedArray() ?: emptyArray(),
|
||||
it.dependencies?.map { dep ->
|
||||
dep.java.patchName
|
||||
}?.toTypedArray() ?: emptyArray(),
|
||||
|
|
|
@ -7,6 +7,8 @@ data class JsonPatch(
|
|||
val description: String,
|
||||
val version: String,
|
||||
val excluded: Boolean,
|
||||
val deprecated: Boolean,
|
||||
val options: Array<Option>,
|
||||
val dependencies: Array<String>,
|
||||
val compatiblePackages: Array<CompatiblePackage>,
|
||||
)
|
||||
|
@ -14,4 +16,12 @@ data class JsonPatch(
|
|||
data class CompatiblePackage(
|
||||
val name: String,
|
||||
val versions: Array<String>,
|
||||
)
|
||||
|
||||
data class Option(
|
||||
val key: String,
|
||||
val title: String,
|
||||
val description: String,
|
||||
val required: Boolean,
|
||||
val choices: Array<*>?,
|
||||
)
|
Loading…
Reference in a new issue