mirror of
https://github.com/revanced/revanced-patches
synced 2025-01-20 23:07:32 +01:00
feat(theme): arbitrary background color for light theme (#565)
This commit is contained in:
parent
10e028626f
commit
da40e7e0cf
@ -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.",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user