mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(YouTube - MaterialYou): Theme not applied to notification dots in YouTube 19.34.42+
This commit is contained in:
@ -6,9 +6,9 @@ import app.revanced.patches.youtube.utils.patch.PatchList.MATERIALYOU
|
|||||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
|
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
|
||||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusTheme
|
import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusTheme
|
||||||
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||||
import app.revanced.util.ResourceGroup
|
|
||||||
import app.revanced.util.copyResources
|
|
||||||
import app.revanced.util.copyXmlNode
|
import app.revanced.util.copyXmlNode
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val materialYouPatch = resourcePatch(
|
val materialYouPatch = resourcePatch(
|
||||||
@ -24,25 +24,118 @@ val materialYouPatch = resourcePatch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
arrayOf(
|
fun patchXmlFile(
|
||||||
ResourceGroup(
|
fromDir: String,
|
||||||
"drawable-night-v31",
|
toDir: String,
|
||||||
"new_content_dot_background.xml"
|
xmlFileName: String,
|
||||||
),
|
parentNode: String,
|
||||||
ResourceGroup(
|
targetNode: String? = null,
|
||||||
"drawable-v31",
|
attribute: String,
|
||||||
"new_content_count_background.xml",
|
newValue: String
|
||||||
"new_content_dot_background.xml"
|
) {
|
||||||
),
|
val resourceDirectory = get("res")
|
||||||
ResourceGroup(
|
val fromDirectory = resourceDirectory.resolve(fromDir)
|
||||||
"layout-v31",
|
val toDirectory = resourceDirectory.resolve(toDir)
|
||||||
"new_content_count.xml"
|
|
||||||
)
|
if (!toDirectory.isDirectory) Files.createDirectories(toDirectory.toPath())
|
||||||
).forEach {
|
|
||||||
get("res/${it.resourceDirectoryName}").mkdirs()
|
val fromXmlFile = fromDirectory.resolve(xmlFileName)
|
||||||
copyResources("youtube/materialyou", it)
|
val toXmlFile = toDirectory.resolve(xmlFileName)
|
||||||
|
|
||||||
|
if (!fromXmlFile.exists()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!toXmlFile.exists()) {
|
||||||
|
Files.copy(
|
||||||
|
fromXmlFile.toPath(),
|
||||||
|
toXmlFile.toPath()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
document("res/$toDir/$xmlFileName").use { document ->
|
||||||
|
val parentList = document.getElementsByTagName(parentNode).item(0) as Element
|
||||||
|
|
||||||
|
if (targetNode != null) {
|
||||||
|
for (i in 0 until parentList.childNodes.length) {
|
||||||
|
val node = parentList.childNodes.item(i) as? Element ?: continue
|
||||||
|
|
||||||
|
if (node.nodeName == targetNode && node.hasAttribute(attribute)) {
|
||||||
|
node.getAttributeNode(attribute).textContent = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (parentList.hasAttribute(attribute)) {
|
||||||
|
parentList.getAttributeNode(attribute).textContent = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patchXmlFile(
|
||||||
|
"drawable",
|
||||||
|
"drawable-night-v31",
|
||||||
|
"new_content_dot_background.xml",
|
||||||
|
"shape",
|
||||||
|
"solid",
|
||||||
|
"android:color",
|
||||||
|
"@android:color/system_accent1_100"
|
||||||
|
)
|
||||||
|
patchXmlFile(
|
||||||
|
"drawable",
|
||||||
|
"drawable-night-v31",
|
||||||
|
"new_content_dot_background_cairo.xml",
|
||||||
|
"shape",
|
||||||
|
"solid",
|
||||||
|
"android:color",
|
||||||
|
"@android:color/system_accent1_100"
|
||||||
|
)
|
||||||
|
patchXmlFile(
|
||||||
|
"drawable",
|
||||||
|
"drawable-v31",
|
||||||
|
"new_content_dot_background.xml",
|
||||||
|
"shape",
|
||||||
|
"solid",
|
||||||
|
"android:color",
|
||||||
|
"@android:color/system_accent1_200"
|
||||||
|
)
|
||||||
|
patchXmlFile(
|
||||||
|
"drawable",
|
||||||
|
"drawable-v31",
|
||||||
|
"new_content_dot_background_cairo.xml",
|
||||||
|
"shape",
|
||||||
|
"solid",
|
||||||
|
"android:color",
|
||||||
|
"@android:color/system_accent1_200"
|
||||||
|
)
|
||||||
|
patchXmlFile(
|
||||||
|
"drawable",
|
||||||
|
"drawable-v31",
|
||||||
|
"new_content_count_background.xml",
|
||||||
|
"shape",
|
||||||
|
"solid",
|
||||||
|
"android:color",
|
||||||
|
"@android:color/system_accent1_100"
|
||||||
|
)
|
||||||
|
patchXmlFile(
|
||||||
|
"drawable",
|
||||||
|
"drawable-v31",
|
||||||
|
"new_content_count_background_cairo.xml",
|
||||||
|
"shape",
|
||||||
|
"solid",
|
||||||
|
"android:color",
|
||||||
|
"@android:color/system_accent1_100"
|
||||||
|
)
|
||||||
|
patchXmlFile(
|
||||||
|
"layout",
|
||||||
|
"layout-v31",
|
||||||
|
"new_content_count.xml",
|
||||||
|
"TextView",
|
||||||
|
null,
|
||||||
|
"android:textColor",
|
||||||
|
"@android:color/system_neutral1_900"
|
||||||
|
)
|
||||||
|
|
||||||
copyXmlNode("youtube/materialyou/host", "values-v31/colors.xml", "resources")
|
copyXmlNode("youtube/materialyou/host", "values-v31/colors.xml", "resources")
|
||||||
|
|
||||||
updatePatchStatusTheme("MaterialYou")
|
updatePatchStatusTheme("MaterialYou")
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape android:shape="oval"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<solid android:color="@android:color/system_accent1_100" />
|
|
||||||
<stroke android:width="@dimen/new_content_badge_stroke_width" android:color="?ytBrandBackgroundSolid" />
|
|
||||||
</shape>
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape android:shape="rectangle"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<solid android:color="@android:color/system_accent1_100" />
|
|
||||||
<stroke android:width="@dimen/new_content_badge_stroke_width" android:color="?ytBrandBackgroundSolid" />
|
|
||||||
<corners android:radius="@dimen/new_content_count_radius" />
|
|
||||||
</shape>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape android:shape="oval"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<solid android:color="@android:color/system_accent1_200" />
|
|
||||||
<stroke android:width="@dimen/new_content_badge_stroke_width" android:color="?ytBrandBackgroundSolid" />
|
|
||||||
</shape>
|
|
@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TextView android:textSize="12.0sp" android:textColor="@android:color/system_neutral1_900" android:gravity="center" android:id="@id/new_content_count" android:background="@drawable/new_content_count_background" android:paddingTop="0.0dip" android:paddingBottom="0.0dip" android:layout_width="wrap_content" android:layout_height="20.0sp" android:minWidth="20.0sp" android:includeFontPadding="false" android:paddingStart="6.0sp" android:paddingEnd="6.0sp"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
Reference in New Issue
Block a user