build: Bump dependencies

This commit also migrates away from deprecated to new APIs
This commit is contained in:
oSumAtrIX
2024-02-21 04:07:32 +01:00
parent ff8b58b645
commit 376dda6e81
38 changed files with 464 additions and 456 deletions
@@ -10,7 +10,7 @@ import org.w3c.dom.Element
@Patch(
name = "Custom theme",
description = "Applies a custom theme.",
compatiblePackages = [CompatiblePackage("com.spotify.music")]
compatiblePackages = [CompatiblePackage("com.spotify.music")],
)
@Suppress("unused")
object CustomThemePatch : ResourcePatch() {
@@ -19,7 +19,7 @@ object CustomThemePatch : ResourcePatch() {
default = "@android:color/black",
title = "Primary background color",
description = "The background color. Can be a hex color or a resource reference.",
required = true
required = true,
)
private var backgroundColorSecondary by stringPatchOption(
@@ -27,7 +27,7 @@ object CustomThemePatch : ResourcePatch() {
default = "#ff282828",
title = "Secondary background color",
description = "The secondary background color. (e.g. search box, artist & podcast). Can be a hex color or a resource reference.",
required = true
required = true,
)
private var accentColor by stringPatchOption(
@@ -35,16 +35,17 @@ object CustomThemePatch : ResourcePatch() {
default = "#ff1ed760",
title = "Accent color",
description = "The accent color ('Spotify green' by default). Can be a hex color or a resource reference.",
required = true
required = true,
)
private var accentColorPressed by stringPatchOption(
key = "accentColorPressed",
default = "#ff169c46",
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
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) {
@@ -53,24 +54,26 @@ object CustomThemePatch : ResourcePatch() {
val accentColor = accentColor!!
val accentColorPressed = accentColorPressed!!
context.xmlEditor["res/values/colors.xml"].use { editor ->
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element
context.document["res/values/colors.xml"].use { document ->
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
for (i in 0 until resourcesNode.childNodes.length) {
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
node.textContent = when (node.getAttribute("name")) {
"dark_base_background_elevated_base", "design_dark_default_color_background",
"design_dark_default_color_surface", "gray_7", "gray_background", "gray_layer",
"sthlm_blk" -> backgroundColor
node.textContent =
when (node.getAttribute("name")) {
"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
"gray_15" -> backgroundColorSecondary
"dark_brightaccent_background_base", "dark_base_text_brightaccent", "green_light" -> accentColor
"dark_brightaccent_background_base", "dark_base_text_brightaccent", "green_light" -> accentColor
"dark_brightaccent_background_press" -> accentColorPressed
else -> continue
}
"dark_brightaccent_background_press" -> accentColorPressed
else -> continue
}
}
}
}