mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-21 16:57:18 +02:00
fix(YouTube): Splash screen background color does not change in dark mode if Theme
patch is excluded
This commit is contained in:
parent
32467937db
commit
d89491ef15
@ -6,8 +6,6 @@ import app.revanced.patches.shared.drawable.addDrawableColorHook
|
|||||||
import app.revanced.patches.shared.drawable.drawableColorHookPatch
|
import app.revanced.patches.shared.drawable.drawableColorHookPatch
|
||||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.extension.Constants.UTILS_PATH
|
import app.revanced.patches.youtube.utils.extension.Constants.UTILS_PATH
|
||||||
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
|
|
||||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
private const val SPLASH_SCREEN_COLOR_NAME = "splashScreenColor"
|
private const val SPLASH_SCREEN_COLOR_NAME = "splashScreenColor"
|
||||||
@ -18,10 +16,7 @@ val sharedThemePatch = resourcePatch(
|
|||||||
) {
|
) {
|
||||||
compatibleWith(COMPATIBLE_PACKAGE)
|
compatibleWith(COMPATIBLE_PACKAGE)
|
||||||
|
|
||||||
dependsOn(
|
dependsOn(drawableColorHookPatch)
|
||||||
drawableColorHookPatch,
|
|
||||||
versionCheckPatch,
|
|
||||||
)
|
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
addDrawableColorHook("$UTILS_PATH/DrawableColorPatch;->getLithoColor(I)I")
|
addDrawableColorHook("$UTILS_PATH/DrawableColorPatch;->getLithoColor(I)I")
|
||||||
@ -106,36 +101,5 @@ val sharedThemePatch = resourcePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_19_32_or_greater) {
|
|
||||||
// Fix the splash screen dark mode background color.
|
|
||||||
// In earlier versions of the app this is white and makes no sense for dark mode.
|
|
||||||
// This is only required for 19.32 and greater, but is applied to all targets.
|
|
||||||
// Only dark mode needs this fix as light mode correctly uses the custom color.
|
|
||||||
document("res/values-night/styles.xml").use { document ->
|
|
||||||
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
|
||||||
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 == "Theme.YouTube.Launcher" || nodeAttributeName == "Theme.YouTube.Launcher.Cairo") {
|
|
||||||
val nodeAttributeParent = node.getAttribute("parent")
|
|
||||||
|
|
||||||
val style = document.createElement("style")
|
|
||||||
style.setAttribute("name", "Theme.YouTube.Home")
|
|
||||||
style.setAttribute("parent", nodeAttributeParent)
|
|
||||||
|
|
||||||
val windowItem = document.createElement("item")
|
|
||||||
windowItem.setAttribute("name", "android:windowBackground")
|
|
||||||
windowItem.textContent = "@color/yt_black1"
|
|
||||||
style.appendChild(windowItem)
|
|
||||||
|
|
||||||
resourcesNode.removeChild(node)
|
|
||||||
resourcesNode.appendChild(style)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.fix.splash
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.resourcePatch
|
||||||
|
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
|
||||||
|
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
|
val darkModeSplashScreenPatch = resourcePatch(
|
||||||
|
description = "darkModeSplashScreenPatch"
|
||||||
|
) {
|
||||||
|
dependsOn(versionCheckPatch)
|
||||||
|
|
||||||
|
execute {
|
||||||
|
if (!is_19_32_or_greater) {
|
||||||
|
return@execute
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix the splash screen dark mode background color.
|
||||||
|
* In earlier versions of the app this is white and makes no sense for dark mode.
|
||||||
|
* This is only required for 19.32 and greater, but is applied to all targets.
|
||||||
|
* Only dark mode needs this fix as light mode correctly uses the custom color.
|
||||||
|
*
|
||||||
|
* This is a bug in unpatched YouTube.
|
||||||
|
* Should always be applied even if the `Theme` patch is excluded.
|
||||||
|
*/
|
||||||
|
document("res/values-night/styles.xml").use { document ->
|
||||||
|
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||||
|
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")
|
||||||
|
style.setAttribute("name", "Theme.YouTube.Home")
|
||||||
|
style.setAttribute("parent", nodeAttributeParent)
|
||||||
|
|
||||||
|
val windowItem = document.createElement("item")
|
||||||
|
windowItem.setAttribute("name", "android:windowBackground")
|
||||||
|
windowItem.textContent = "@color/yt_black1"
|
||||||
|
style.appendChild(windowItem)
|
||||||
|
|
||||||
|
resourcesNode.removeChild(node)
|
||||||
|
resourcesNode.appendChild(style)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PAC
|
|||||||
import app.revanced.patches.youtube.utils.extension.Constants.UTILS_PATH
|
import app.revanced.patches.youtube.utils.extension.Constants.UTILS_PATH
|
||||||
import app.revanced.patches.youtube.utils.extension.sharedExtensionPatch
|
import app.revanced.patches.youtube.utils.extension.sharedExtensionPatch
|
||||||
import app.revanced.patches.youtube.utils.fix.cairo.cairoSettingsPatch
|
import app.revanced.patches.youtube.utils.fix.cairo.cairoSettingsPatch
|
||||||
|
import app.revanced.patches.youtube.utils.fix.splash.darkModeSplashScreenPatch
|
||||||
import app.revanced.patches.youtube.utils.mainactivity.mainActivityResolvePatch
|
import app.revanced.patches.youtube.utils.mainactivity.mainActivityResolvePatch
|
||||||
import app.revanced.patches.youtube.utils.patch.PatchList.SETTINGS_FOR_YOUTUBE
|
import app.revanced.patches.youtube.utils.patch.PatchList.SETTINGS_FOR_YOUTUBE
|
||||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||||
@ -120,6 +121,7 @@ val settingsPatch = resourcePatch(
|
|||||||
dependsOn(
|
dependsOn(
|
||||||
settingsBytecodePatch,
|
settingsBytecodePatch,
|
||||||
cairoSettingsPatch,
|
cairoSettingsPatch,
|
||||||
|
darkModeSplashScreenPatch,
|
||||||
)
|
)
|
||||||
|
|
||||||
val insertPosition = stringOption(
|
val insertPosition = stringOption(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user