mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-24 10:52:10 +02:00
fix(YouTube - Theme): Resolve dark mode startup crash with Android 9.0 (Match with ReVanced)
This commit is contained in:
parent
1a0b32b8d5
commit
6b1e45f234
@ -24,29 +24,30 @@ val darkModeSplashScreenPatch = resourcePatch(
|
|||||||
* This is a bug in unpatched YouTube.
|
* This is a bug in unpatched YouTube.
|
||||||
* Should always be applied even if the `Theme` patch is excluded.
|
* Should always be applied even if the `Theme` patch is excluded.
|
||||||
*/
|
*/
|
||||||
document("res/values-night/styles.xml").use { document ->
|
document("res/values-night-v27/styles.xml").use { document ->
|
||||||
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
// Create a night mode specific override for the splash screen background.
|
||||||
val childNodes = resourcesNode.childNodes
|
|
||||||
|
|
||||||
for (i in 0 until childNodes.length) {
|
|
||||||
val node = childNodes.item(i) as? Element ?: continue
|
|
||||||
val nodeAttributeName = node.getAttribute("name")
|
|
||||||
if (nodeAttributeName.startsWith("Theme.YouTube.Launcher")) {
|
|
||||||
val nodeAttributeParent = node.getAttribute("parent")
|
|
||||||
|
|
||||||
val style = document.createElement("style")
|
val style = document.createElement("style")
|
||||||
style.setAttribute("name", "Theme.YouTube.Home")
|
style.setAttribute("name", "Theme.YouTube.Home")
|
||||||
style.setAttribute("parent", nodeAttributeParent)
|
style.setAttribute("parent", "@style/Base.V27.Theme.YouTube.Home")
|
||||||
|
|
||||||
val windowItem = document.createElement("item")
|
// Fix status and navigation bar showing white on some Android devices,
|
||||||
windowItem.setAttribute("name", "android:windowBackground")
|
// such as SDK 28 Android 10 medium tablet.
|
||||||
windowItem.textContent = "@color/yt_black1"
|
val colorSplashBackgroundColor = "@color/yt_black1"
|
||||||
style.appendChild(windowItem)
|
arrayOf(
|
||||||
|
"android:navigationBarColor" to colorSplashBackgroundColor,
|
||||||
|
"android:windowBackground" to colorSplashBackgroundColor,
|
||||||
|
"android:colorBackground" to colorSplashBackgroundColor,
|
||||||
|
"colorPrimaryDark" to colorSplashBackgroundColor,
|
||||||
|
"android:windowLightStatusBar" to "false",
|
||||||
|
).forEach { (name, value) ->
|
||||||
|
val styleItem = document.createElement("item")
|
||||||
|
styleItem.setAttribute("name", name)
|
||||||
|
styleItem.textContent = value
|
||||||
|
style.appendChild(styleItem)
|
||||||
|
}
|
||||||
|
|
||||||
resourcesNode.removeChild(node)
|
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||||
resourcesNode.appendChild(style)
|
resourcesNode.appendChild(style)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user