fix: materialyou patch is broken

This commit is contained in:
inotia00 2023-02-22 01:19:31 +09:00
parent 0bf27dd2a6
commit fa741d87d1
2 changed files with 12 additions and 15 deletions

View File

@ -58,13 +58,7 @@ class MaterialYouPatch : ResourcePatch {
}
}
val sourcePath = this.javaClass.classLoader.getResourceAsStream("youtube/materialyou/host/values-v31/colors.xml")!!
val relativePath = context.xmlEditor["res/values-v31/colors.xml"]
"resources".copyXmlNode(
context.xmlEditor[sourcePath],
relativePath
)
context.copyXmlNode("youtube/materialyou/host", "values-v31/colors.xml", "resources")
/*
* Add settings

View File

@ -44,15 +44,18 @@ internal object IconHelper {
iconName
)
this.xmlEditor["res/values-v31/styles.xml"].use { editor ->
with(editor.file) {
val resourcesNode = getElementsByTagName("resources").item(0) as Element
this.xmlEditor["res/values-v31/styles.xml"].use { dom ->
val applicationNode = dom
.file
.getElementsByTagName("resources")
.item(0) as Element
for (i in 0 until resourcesNode.childNodes.length) {
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
if (node.getAttribute("name") == "Base.Theme.YouTube.Launcher") {
node.removeChild(node.childNodes.item(0))
applicationNode.getElementsByTagName("style").also { list ->
for (i in 0 until list.length) {
val element = list.item(i) as? Element ?: continue
if (element.getAttribute("name") == "Base.Theme.YouTube.Launcher") {
element.removeChild(element.firstChild)
break
}
}
}