fix(YouTube - Theme): only set splash screen color if background colors are set
This commit is contained in:
parent
a808eca796
commit
f058db4ba4
|
@ -66,27 +66,31 @@ class ThemeResourcePatch : ResourcePatch {
|
||||||
addColorResource(context, "res/values-night/colors.xml", SPLASH_BACKGROUND_COLOR, it)
|
addColorResource(context, "res/values-night/colors.xml", SPLASH_BACKGROUND_COLOR, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit splash screen files and change the background color.
|
// Edit splash screen files and change the background color,
|
||||||
val splashScreenResourceFiles = listOf(
|
// if the background colors are set.
|
||||||
"res/drawable/quantum_launchscreen_youtube.xml",
|
if (darkThemeBackgroundColor != null && lightThemeBackgroundColor != null) {
|
||||||
"res/drawable-sw600dp/quantum_launchscreen_youtube.xml")
|
val splashScreenResourceFiles = listOf(
|
||||||
|
"res/drawable/quantum_launchscreen_youtube.xml",
|
||||||
|
"res/drawable-sw600dp/quantum_launchscreen_youtube.xml")
|
||||||
|
|
||||||
splashScreenResourceFiles.forEach editSplashScreen@ { resourceFile ->
|
splashScreenResourceFiles.forEach editSplashScreen@ { resourceFile ->
|
||||||
context.xmlEditor[resourceFile].use {
|
context.xmlEditor[resourceFile].use {
|
||||||
val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element
|
val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element
|
||||||
|
|
||||||
val childNodes = layerList.childNodes
|
val childNodes = layerList.childNodes
|
||||||
for (i in 0 until childNodes.length) {
|
for (i in 0 until childNodes.length) {
|
||||||
val node = childNodes.item(i)
|
val node = childNodes.item(i)
|
||||||
if (node is Element && node.hasAttribute("android:drawable")) {
|
if (node is Element && node.hasAttribute("android:drawable")) {
|
||||||
node.setAttribute("android:drawable", "@color/$SPLASH_BACKGROUND_COLOR")
|
node.setAttribute("android:drawable", "@color/$SPLASH_BACKGROUND_COLOR")
|
||||||
return@editSplashScreen
|
return@editSplashScreen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return PatchResultError("Failed to modify launch screen")
|
||||||
}
|
}
|
||||||
return PatchResultError("Failed to modify launch screen")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue