From e27f56c8a34d41167b290f47280276c1c6003876 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 20 Feb 2024 22:30:50 +0100 Subject: [PATCH] feat(YouTube - Custom branding): Improve patch option description --- .../layout/branding/CustomBrandingPatch.kt | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 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 587e0d4eb..19aa116b5 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 @@ -15,9 +15,9 @@ import java.nio.file.Files name = "Custom branding", description = "Applies a custom app name and icon. Defaults to \"YouTube ReVanced\" and the ReVanced logo.", compatiblePackages = [ - CompatiblePackage("com.google.android.youtube") + CompatiblePackage("com.google.android.youtube"), ], - use = false + use = false, ) @Suppress("unused") object CustomBrandingPatch : ResourcePatch() { @@ -28,7 +28,7 @@ object CustomBrandingPatch : ResourcePatch() { "adaptiveproduct_youtube_background_color_108", "adaptiveproduct_youtube_foreground_color_108", "ic_launcher", - "ic_launcher_round" + "ic_launcher_round", ).map { "$it.png" }.toTypedArray() private val mipmapDirectories = arrayOf( @@ -36,7 +36,7 @@ object CustomBrandingPatch : ResourcePatch() { "xxhdpi", "xhdpi", "hdpi", - "mdpi" + "mdpi", ).map { "mipmap-$it" } private var appName by stringPatchOption( @@ -49,7 +49,7 @@ object CustomBrandingPatch : ResourcePatch() { "YouTube" to "YouTube", ), title = "App name", - description = "The name of the app." + description = "The name of the app.", ) private var icon by stringPatchOption( @@ -58,14 +58,16 @@ object CustomBrandingPatch : ResourcePatch() { values = mapOf("ReVanced Logo" to REVANCED_ICON), title = "App icon", description = """ - The path to a folder containing the following folders: + The icon to apply to the app. + + If a path to a folder is provided, the folder must contain the following folders: ${mipmapDirectories.joinToString("\n") { "- $it" }} - Each of these folders has to have the following files: + Each of these folders must contain the following files: ${iconResourceFileNames.joinToString("\n") { "- $it" }} - """.trimIndentMultiline() + """.trimIndentMultiline(), ) override fun execute(context: ResourceContext) { @@ -73,7 +75,8 @@ object CustomBrandingPatch : ResourcePatch() { // Change the app icon. mipmapDirectories.map { directory -> ResourceGroup( - directory, *iconResourceFileNames + directory, + *iconResourceFileNames, ) }.let { resourceGroups -> if (icon != REVANCED_ICON) { @@ -87,11 +90,13 @@ object CustomBrandingPatch : ResourcePatch() { group.resources.forEach { iconFileName -> Files.write( toDirectory.resolve(iconFileName).toPath(), - fromDirectory.resolve(iconFileName).readBytes() + fromDirectory.resolve(iconFileName).readBytes(), ) } } - } else resourceGroups.forEach { context.copyResources("custom-branding", it) } + } else { + resourceGroups.forEach { context.copyResources("custom-branding", it) } + } } } @@ -102,8 +107,8 @@ object CustomBrandingPatch : ResourcePatch() { manifest.readText() .replace( "android:label=\"@string/application_name", - "android:label=\"$name" - ) + "android:label=\"$name", + ), ) } }