feat: Improve option descriptions and titles

This commit is contained in:
oSumAtrIX 2023-10-12 02:15:41 +02:00
parent 57dab3fd30
commit 9f86daa822
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 33 additions and 20 deletions

View file

@ -12,7 +12,7 @@ import java.nio.file.Files
@Patch(
name = "Custom branding",
description = "Changes the YouTube launcher icon and name to your choice (defaults to ReVanced).",
description = "Changes the app icon and name to your choice (defaults to YouTube ReVanced and the ReVanced logo).",
compatiblePackages = [
CompatiblePackage("com.google.android.youtube")
],
@ -20,19 +20,42 @@ import java.nio.file.Files
)
@Suppress("unused")
object CustomBrandingPatch : ResourcePatch() {
private val iconResourceFileNames = arrayOf(
"adaptiveproduct_youtube_background_color_108",
"adaptiveproduct_youtube_foreground_color_108",
"ic_launcher",
"ic_launcher_round"
).map { "$it.png" }.toTypedArray()
private val mipmapDirectories = arrayOf(
"xxxhdpi",
"xxhdpi",
"xhdpi",
"hdpi",
"mdpi"
).map { "mipmap-$it" }
private var appName by stringPatchOption(
key = "appName",
default = "YouTube ReVanced",
title = "Application Name",
description = "The name of the application it will show on your home screen.",
title = "App name",
description = "The name of the app.",
required = true
)
private var iconPath by stringPatchOption(
key = "iconPath",
default = null,
title = "App Icon Path",
description = "A path containing mipmap resource folders with icons."
title = "App icon path",
description = """
The path to a folder containing the following folders:
${mipmapDirectories.joinToString("\n") { "- $it" }}
Each of these folders has to have the following files:
${iconResourceFileNames.joinToString("\n") { "- $it" }}
""".trimIndent()
)
override fun execute(context: ResourceContext) {
@ -55,24 +78,14 @@ object CustomBrandingPatch : ResourcePatch() {
} ?: resourceGroups.forEach { context.copyResources("branding", it) }
}
val iconResourceFileNames = arrayOf(
"adaptiveproduct_youtube_background_color_108",
"adaptiveproduct_youtube_foreground_color_108",
"ic_launcher",
"ic_launcher_round"
).map { "$it.png" }.toTypedArray()
fun createGroup(directory: String) = ResourceUtils.ResourceGroup(
directory, *iconResourceFileNames
)
// change the app icon
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi")
.map { "mipmap-$it" }
.map(::createGroup)
.let(::copyResources)
// Change the app icon.
mipmapDirectories.map(::createGroup).let(::copyResources)
// change the name of the app
// Change the app name.
val manifest = context["AndroidManifest.xml"]
manifest.writeText(
manifest.readText()

View file

@ -23,14 +23,14 @@ object ThemeBytecodePatch : BytecodePatch() {
internal val darkThemeBackgroundColor by stringPatchOption(
key = "darkThemeBackgroundColor",
default = "@android:color/black",
title = "Background color for the dark theme",
title = "Dark theme background color",
description = "The background color of the dark theme. Can be a hex color or a resource reference.",
)
internal val lightThemeBackgroundColor by stringPatchOption(
key = "lightThemeBackgroundColor",
default = "@android:color/white",
title = "Background color for the light theme",
title = "Light theme background color",
description = "The background color of the light theme. Can be a hex color or a resource reference.",
)