mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-24 18:55:49 +01:00
feat: Improve option descriptions and titles
This commit is contained in:
parent
57dab3fd30
commit
9f86daa822
@ -12,7 +12,7 @@ import java.nio.file.Files
|
|||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Custom branding",
|
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 = [
|
compatiblePackages = [
|
||||||
CompatiblePackage("com.google.android.youtube")
|
CompatiblePackage("com.google.android.youtube")
|
||||||
],
|
],
|
||||||
@ -20,19 +20,42 @@ import java.nio.file.Files
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object CustomBrandingPatch : ResourcePatch() {
|
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(
|
private var appName by stringPatchOption(
|
||||||
key = "appName",
|
key = "appName",
|
||||||
default = "YouTube ReVanced",
|
default = "YouTube ReVanced",
|
||||||
title = "Application Name",
|
title = "App name",
|
||||||
description = "The name of the application it will show on your home screen.",
|
description = "The name of the app.",
|
||||||
required = true
|
required = true
|
||||||
)
|
)
|
||||||
|
|
||||||
private var iconPath by stringPatchOption(
|
private var iconPath by stringPatchOption(
|
||||||
key = "iconPath",
|
key = "iconPath",
|
||||||
default = null,
|
default = null,
|
||||||
title = "App Icon Path",
|
title = "App icon path",
|
||||||
description = "A path containing mipmap resource folders with icons."
|
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) {
|
override fun execute(context: ResourceContext) {
|
||||||
@ -55,24 +78,14 @@ object CustomBrandingPatch : ResourcePatch() {
|
|||||||
} ?: resourceGroups.forEach { context.copyResources("branding", it) }
|
} ?: 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(
|
fun createGroup(directory: String) = ResourceUtils.ResourceGroup(
|
||||||
directory, *iconResourceFileNames
|
directory, *iconResourceFileNames
|
||||||
)
|
)
|
||||||
|
|
||||||
// change the app icon
|
// Change the app icon.
|
||||||
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi")
|
mipmapDirectories.map(::createGroup).let(::copyResources)
|
||||||
.map { "mipmap-$it" }
|
|
||||||
.map(::createGroup)
|
|
||||||
.let(::copyResources)
|
|
||||||
|
|
||||||
// change the name of the app
|
// Change the app name.
|
||||||
val manifest = context["AndroidManifest.xml"]
|
val manifest = context["AndroidManifest.xml"]
|
||||||
manifest.writeText(
|
manifest.writeText(
|
||||||
manifest.readText()
|
manifest.readText()
|
||||||
|
@ -23,14 +23,14 @@ object ThemeBytecodePatch : BytecodePatch() {
|
|||||||
internal val darkThemeBackgroundColor by stringPatchOption(
|
internal val darkThemeBackgroundColor by stringPatchOption(
|
||||||
key = "darkThemeBackgroundColor",
|
key = "darkThemeBackgroundColor",
|
||||||
default = "@android:color/black",
|
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.",
|
description = "The background color of the dark theme. Can be a hex color or a resource reference.",
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val lightThemeBackgroundColor by stringPatchOption(
|
internal val lightThemeBackgroundColor by stringPatchOption(
|
||||||
key = "lightThemeBackgroundColor",
|
key = "lightThemeBackgroundColor",
|
||||||
default = "@android:color/white",
|
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.",
|
description = "The background color of the light theme. Can be a hex color or a resource reference.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user