Skip to content

Commit

Permalink
fix(YouTube - Theme): allow setting no background color
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jul 20, 2023
1 parent dfb7d7b commit 8a4e77a
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand All @@ -87,7 +90,7 @@ class ThemeResourcePatch : ResourcePatch {
return PatchResultSuccess()
}

private fun addResourceColor(
private fun addColorResource(
context: ResourceContext,
resourceFile: String,
colorName: String,
Expand Down

0 comments on commit 8a4e77a

Please sign in to comment.