mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 07:34:31 +02:00
minor improvements
This commit is contained in:
parent
c30e5baf18
commit
c09268f7ec
@ -11,5 +11,5 @@ import app.revanced.shared.patches.integrations.AbstractIntegrationsPatch
|
|||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
class IntegrationsPatch : AbstractIntegrationsPatch(
|
class IntegrationsPatch : AbstractIntegrationsPatch(
|
||||||
"Lapp/revanced/integrations/utils/ReVancedUtils;",
|
"Lapp/revanced/integrations/utils/ReVancedUtils;",
|
||||||
listOf(InitFingerprint),
|
listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint),
|
||||||
)
|
)
|
@ -14,6 +14,7 @@ import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatc
|
|||||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsBytecodePatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsBytecodePatch
|
||||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
|
import app.revanced.shared.patches.options.PatchOptions
|
||||||
import app.revanced.shared.patches.settings.AbstractSettingsResourcePatch
|
import app.revanced.shared.patches.settings.AbstractSettingsResourcePatch
|
||||||
import app.revanced.shared.util.resources.ResourceHelper
|
import app.revanced.shared.util.resources.ResourceHelper
|
||||||
import app.revanced.shared.util.resources.ResourceUtils
|
import app.revanced.shared.util.resources.ResourceUtils
|
||||||
@ -27,6 +28,7 @@ import org.w3c.dom.Element
|
|||||||
[
|
[
|
||||||
FixLocaleConfigErrorPatch::class,
|
FixLocaleConfigErrorPatch::class,
|
||||||
IntegrationsPatch::class,
|
IntegrationsPatch::class,
|
||||||
|
PatchOptions::class,
|
||||||
SharedResourcdIdPatch::class,
|
SharedResourcdIdPatch::class,
|
||||||
SettingsBytecodePatch::class
|
SettingsBytecodePatch::class
|
||||||
]
|
]
|
||||||
|
@ -127,7 +127,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
val instanceRegister = 0
|
val instanceRegister = 0
|
||||||
NextGenWatchLayoutFingerprint.result!!.mutableMethod.addInstruction(
|
NextGenWatchLayoutFingerprint.result!!.mutableMethod.addInstruction(
|
||||||
3, // after super call
|
3, // after super call
|
||||||
"invoke-static/range {p$instanceRegister}, Lapp/revanced/integrations/sponsorblock/PlayerController;->addSkipSponsorView15(Landroid/view/View;)V"
|
"invoke-static/range {p$instanceRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->addSkipSponsorView15(Landroid/view/View;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
BytecodeHelper.injectInit(context, "FirstRun", "initializationSB")
|
BytecodeHelper.injectInit(context, "FirstRun", "initializationSB")
|
||||||
|
@ -13,66 +13,69 @@ import org.w3c.dom.Element
|
|||||||
class GeneralThemeResourcePatch : ResourcePatch {
|
class GeneralThemeResourcePatch : ResourcePatch {
|
||||||
override fun execute(context: ResourceContext): PatchResult {
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
|
|
||||||
// copies the resource file to change the splash screen color
|
// edit the resource files to change the splash screen color
|
||||||
context.xmlEditor["res/values/attrs.xml"].use { editor ->
|
val attrsPath = "res/values/attrs.xml"
|
||||||
with(editor.file) {
|
val stylesPaths: List<String> = listOf(
|
||||||
val resourcesNode = getElementsByTagName("resources").item(0) as Element
|
"res/values/styles.xml", // Android 11 (and below)
|
||||||
|
"res/values-v31/styles.xml", // Android 12 (and above)
|
||||||
|
)
|
||||||
|
|
||||||
val newElement: Element = createElement("attr")
|
context.xmlEditor[attrsPath].use { editor ->
|
||||||
newElement.setAttribute("format", "reference")
|
val file = editor.file
|
||||||
newElement.setAttribute("name", "splashScreenColor")
|
|
||||||
|
|
||||||
resourcesNode.appendChild(newElement)
|
(file.getElementsByTagName("resources").item(0) as Element).appendChild(
|
||||||
}
|
file.createElement("attr").apply {
|
||||||
|
setAttribute("format", "reference")
|
||||||
|
setAttribute("name", "splashScreenColor")
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
stylesPaths.forEachIndexed { pathIndex, stylesPath ->
|
||||||
|
context.xmlEditor[stylesPath].use { editor ->
|
||||||
|
val file = editor.file
|
||||||
|
|
||||||
context.xmlEditor["res/values/styles.xml"].use { editor ->
|
val childNodes = (file.getElementsByTagName("resources").item(0) as Element).childNodes
|
||||||
with(editor.file) {
|
|
||||||
val resourcesNode = getElementsByTagName("resources").item(0) as Element
|
|
||||||
|
|
||||||
for (i in 0 until resourcesNode.childNodes.length) {
|
for (i in 0 until childNodes.length) {
|
||||||
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
|
val node = childNodes.item(i) as? Element ?: continue
|
||||||
|
val nodeAttributeName = node.getAttribute("name")
|
||||||
|
|
||||||
val newElement: Element = createElement("item")
|
file.createElement("item").apply {
|
||||||
newElement.setAttribute("name", "splashScreenColor")
|
setAttribute(
|
||||||
|
"name",
|
||||||
|
when (pathIndex) {
|
||||||
|
0 -> "splashScreenColor"
|
||||||
|
1 -> "android:windowSplashScreenBackground"
|
||||||
|
else -> "null"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
when (node.getAttribute("name")) {
|
appendChild(
|
||||||
"Base.Theme.YouTube.Launcher.Dark" -> {
|
file.createTextNode(
|
||||||
newElement.appendChild(createTextNode("@color/yt_black1"))
|
when (pathIndex) {
|
||||||
|
0 -> when (nodeAttributeName) {
|
||||||
|
"Base.Theme.YouTube.Launcher.Dark" -> "@color/yt_black1"
|
||||||
|
"Base.Theme.YouTube.Launcher.Light" -> "@color/yt_white1"
|
||||||
|
else -> "null"
|
||||||
|
}
|
||||||
|
1 -> when (nodeAttributeName) {
|
||||||
|
"Base.Theme.YouTube.Launcher" -> "?attr/splashScreenColor"
|
||||||
|
else -> "null"
|
||||||
|
}
|
||||||
|
else -> "null"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
node.appendChild(newElement)
|
if (this.textContent != "null")
|
||||||
}
|
node.appendChild(this)
|
||||||
"Base.Theme.YouTube.Launcher.Light" -> {
|
|
||||||
newElement.appendChild(createTextNode("@color/yt_white1"));
|
|
||||||
|
|
||||||
node.appendChild(newElement)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.xmlEditor["res/values-v31/styles.xml"].use { editor ->
|
arrayOf("drawable", "drawable-sw600dp").forEach { quantumLaunchscreenPath ->
|
||||||
with(editor.file) {
|
context.xmlEditor["res/$quantumLaunchscreenPath/quantum_launchscreen_youtube.xml"].use { editor ->
|
||||||
val resourcesNode = getElementsByTagName("resources").item(0) as Element
|
|
||||||
|
|
||||||
val newElement: Element = createElement("item")
|
|
||||||
newElement.setAttribute("name", "android:windowSplashScreenBackground")
|
|
||||||
|
|
||||||
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") {
|
|
||||||
newElement.appendChild(createTextNode("?attr/splashScreenColor"))
|
|
||||||
|
|
||||||
node.appendChild(newElement)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
arrayOf("drawable", "drawable-sw600dp").forEach { drawablePath ->
|
|
||||||
context.xmlEditor["res/$drawablePath/quantum_launchscreen_youtube.xml"].use { editor ->
|
|
||||||
val resourcesNode = editor.file.getElementsByTagName("item").item(0) as Element
|
val resourcesNode = editor.file.getElementsByTagName("item").item(0) as Element
|
||||||
|
|
||||||
if (resourcesNode.attributes.getNamedItem("android:drawable") != null)
|
if (resourcesNode.attributes.getNamedItem("android:drawable") != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user