From 9f86daa82271591bcaa9144d300a4810458fdd28 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 12 Oct 2023 02:15:41 +0200 Subject: [PATCH] feat: Improve option descriptions and titles --- .../layout/branding/CustomBrandingPatch.kt | 49 ++++++++++++------- .../layout/theme/ThemeBytecodePatch.kt | 4 +- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt index 433d1a345..68926b6aa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt @@ -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() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt index 680a8d93a..6ad1057e6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt @@ -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.", )