From 869ec26966f7750c45355ac0acc18b81a2abce87 Mon Sep 17 00:00:00 2001 From: Advyte <104263903+4dvyte@users.noreply.github.com> Date: Wed, 22 Nov 2023 01:43:58 +0530 Subject: [PATCH] fix(Spotify - Custom theme): Add more background surfaces coloring options (#3285) Co-authored-by: oSumAtrIX --- .../spotify/layout/theme/CustomThemePatch.kt | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt b/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt index 3869182a1..6a0ae9ed4 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt @@ -17,25 +17,42 @@ object CustomThemePatch : ResourcePatch() { private var backgroundColor by stringPatchOption( key = "backgroundColor", default = "@android:color/black", - title = "Background color", + title = "Primary background color", description = "The background color. Can be a hex color or a resource reference.", + required = true + ) + + private var backgroundColorSecondary by stringPatchOption( + key = "backgroundColorSecondary", + default = "#ff282828", + title = "Secondary background color", + description = "The secondary background color. Can be a hex color or a resource reference.", + required = true ) private var accentColor by stringPatchOption( key = "accentColor", default = "#ff1ed760", title = "Accent color", - description = "The accent color ('spotify green' by default). Can be a hex color or a resource reference.", + description = "The accent color ('Spotify green' by default). Can be a hex color or a resource reference.", + required = true ) - private var accentPressedColor by stringPatchOption( - key = "accentPressedColor", + private var accentColorPressed by stringPatchOption( + key = "accentColorPressed", default = "#ff169c46", - title = "Pressed accent for the dark theme", - description = "The color when accented buttons are pressed, by default slightly darker than accent. Can be a hex color or a resource reference." + title = "Pressed dark theme accent color", + description = "The color when accented buttons are pressed, by default slightly darker than accent. " + + "Can be a hex color or a resource reference.", + required = true ) override fun execute(context: ResourceContext) { + val backgroundColor = backgroundColor!! + val backgroundColorSecondary = backgroundColorSecondary!! + val accentColor = accentColor!! + val accentColorPressed = accentColorPressed!! + context.xmlEditor["res/values/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element @@ -43,12 +60,18 @@ object CustomThemePatch : ResourcePatch() { val node = resourcesNode.childNodes.item(i) as? Element ?: continue node.textContent = when (node.getAttribute("name")) { - "gray_7" -> backgroundColor!! - "dark_brightaccent_background_base", "dark_base_text_brightaccent", "green_light" -> accentColor!! - "dark_brightaccent_background_press" -> accentPressedColor!! + "dark_base_background_elevated_base", "design_dark_default_color_background", + "design_dark_default_color_surface", "gray_7", "gray_background", "gray_layer", + "sthlm_blk" -> backgroundColor + + "gray_15" -> backgroundColorSecondary + + "dark_brightaccent_background_base", "dark_base_text_brightaccent", "green_light" -> accentColor + + "dark_brightaccent_background_press" -> accentColorPressed else -> continue } } } } -} \ No newline at end of file +}