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")!! context.copyXmlNode("youtube/materialyou/host", "values-v31/colors.xml", "resources")
val relativePath = context.xmlEditor["res/values-v31/colors.xml"]
"resources".copyXmlNode(
context.xmlEditor[sourcePath],
relativePath
)
/* /*
* Add settings * Add settings

View File

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