fix(YouTube - Theme): allow setting no background color

This commit is contained in:
oSumAtrIX 2023-07-21 00:10:39 +02:00
parent dfb7d7b3dd
commit 8a4e77a290
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -45,8 +45,8 @@ class ThemeResourcePatch : ResourcePatch {
node.textContent = when (node.getAttribute("name")) {
"yt_black0", "yt_black1", "yt_black1_opacity95", "yt_black1_opacity98", "yt_black2", "yt_black3",
"yt_black4", "yt_status_bar_background_dark", "material_grey_850" -> darkThemeBackgroundColor
?: continue
"yt_black4", "yt_status_bar_background_dark", "material_grey_850"
-> darkThemeBackgroundColor ?: continue
"yt_white1", "yt_white1_opacity95", "yt_white1_opacity98",
"yt_white2", "yt_white3", "yt_white4",
@ -58,10 +58,13 @@ class ThemeResourcePatch : ResourcePatch {
}
// Add a dynamic background color to the colors.xml file.
addResourceColor(context, "res/values/colors.xml",
SPLASH_BACKGROUND_COLOR, lightThemeBackgroundColor!!)
addResourceColor(context, "res/values-night/colors.xml",
SPLASH_BACKGROUND_COLOR, darkThemeBackgroundColor!!)
lightThemeBackgroundColor?.let {
addColorResource(context, "res/values/colors.xml", SPLASH_BACKGROUND_COLOR, it)
}
darkThemeBackgroundColor?.let {
addColorResource(context, "res/values-night/colors.xml", SPLASH_BACKGROUND_COLOR, it)
}
// Edit splash screen files and change the background color.
val splashScreenResourceFiles = listOf(
@ -87,7 +90,7 @@ class ThemeResourcePatch : ResourcePatch {
return PatchResultSuccess()
}
private fun addResourceColor(
private fun addColorResource(
context: ResourceContext,
resourceFile: String,
colorName: String,