From da40e7e0cf266edc89353e62b9821b450f8f0295 Mon Sep 17 00:00:00 2001 From: Pranshu Goyal <78131793+datnerdguy@users.noreply.github.com> Date: Thu, 22 Sep 2022 02:31:23 +0530 Subject: [PATCH] feat(theme): arbitrary background color for light theme (#565) --- .../youtube/layout/theme/patch/ThemePatch.kt | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt index 05fd896d8..5989624dc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt @@ -23,7 +23,8 @@ import org.w3c.dom.Element @Version("0.0.1") class ThemePatch : ResourcePatch() { override fun execute(data: ResourceData): PatchResult { - val backgroundColor = backgroundColor!! + val darkThemeBackgroundColor = darkThemeBackgroundColor!! + val lightThemeBackgroundColor = lightThemeBackgroundColor!! data.xmlEditor["res/values/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element @@ -33,7 +34,11 @@ class ThemePatch : ResourcePatch() { node.textContent = when (node.getAttribute("name")) { "yt_black1", "yt_black1_opacity95", "yt_black2", "yt_black3", "yt_black4", - "yt_status_bar_background_dark" -> backgroundColor + "yt_status_bar_background_dark" -> darkThemeBackgroundColor + + "yt_white1", "yt_white1_opacity95", "yt_white2", "yt_white3", + "yt_white4" -> lightThemeBackgroundColor + else -> continue } } @@ -43,7 +48,7 @@ class ThemePatch : ResourcePatch() { } companion object : OptionsContainer() { - var backgroundColor: String? by option( + var darkThemeBackgroundColor: String? by option( PatchOption.StringOption( key = "darkThemeBackgroundColor", default = "@android:color/black", @@ -51,5 +56,14 @@ class ThemePatch : ResourcePatch() { description = "The background color of the dark theme. Can be a hex color or a resource reference.", ) ) + + var lightThemeBackgroundColor: String? by option( + PatchOption.StringOption( + key = "lightThemeBackgroundColor", + default = "@android:color/white", + title = "Background color for the light theme", + description = "The background color of the light theme. Can be a hex color or a resource reference.", + ) + ) } } \ No newline at end of file