Skip to content

Commit

Permalink
feat: Improve option descriptions and titles
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Oct 12, 2023
1 parent 57dab3f commit 9f86daa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,50 @@ 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")
],
use = false
)
@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) {
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)

Expand Down

0 comments on commit 9f86daa

Please sign in to comment.