fix(YouTube - Custom branding icon): Splash animation background color is always white https://github.com/inotia00/ReVanced_Extended/issues/2892

This commit is contained in:
inotia00 2025-04-01 19:00:18 +09:00
parent 7e4a71b385
commit 22b98336d5
2 changed files with 36 additions and 45 deletions

View File

@ -218,8 +218,7 @@ val customBrandingIconPatch = resourcePatch(
} }
val styleList = mutableListOf( val styleList = mutableListOf(
Triple( Pair(
"values-v31",
"Base.Theme.YouTube.Launcher", "Base.Theme.YouTube.Launcher",
"@style/Theme.AppCompat.DayNight.NoActionBar" "@style/Theme.AppCompat.DayNight.NoActionBar"
), ),
@ -227,21 +226,15 @@ val customBrandingIconPatch = resourcePatch(
if (is_19_32_or_greater) { if (is_19_32_or_greater) {
styleList += listOf( styleList += listOf(
Triple( Pair(
"values-night-v31",
"Theme.YouTube.Home",
"@style/Base.V27.Theme.YouTube.Home"
),
Triple(
"values-v31",
"Theme.YouTube.Home", "Theme.YouTube.Home",
"@style/Base.V27.Theme.YouTube.Home" "@style/Base.V27.Theme.YouTube.Home"
), ),
) )
} }
styleList.forEach { (directory, nodeAttributeName, nodeAttributeParent) -> styleList.forEach { (nodeAttributeName, nodeAttributeParent) ->
document("res/$directory/styles.xml").use { document -> document("res/values-v31/styles.xml").use { document ->
val resourcesNode = val resourcesNode =
document.getElementsByTagName("resources").item(0) as Element document.getElementsByTagName("resources").item(0) as Element

View File

@ -1,11 +1,9 @@
package app.revanced.patches.youtube.utils.fix.splash package app.revanced.patches.youtube.utils.fix.splash
import app.revanced.patcher.patch.resourcePatch import app.revanced.patcher.patch.resourcePatch
import app.revanced.patches.youtube.utils.compatibility.Constants.YOUTUBE_PACKAGE_NAME
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
import app.revanced.patches.youtube.utils.settings.ResourceUtils.youtubePackageName import app.revanced.patches.youtube.utils.settings.ResourceUtils.restoreOldSplashAnimationIncluded
import app.revanced.util.findElementByAttributeValueOrThrow
import org.w3c.dom.Element import org.w3c.dom.Element
/** /**
@ -22,16 +20,13 @@ val darkModeSplashScreenPatch = resourcePatch(
) { ) {
dependsOn(versionCheckPatch) dependsOn(versionCheckPatch)
execute { finalize {
if (!is_19_32_or_greater) { if (!is_19_32_or_greater) {
return@execute return@finalize
} }
arrayOf( if (restoreOldSplashAnimationIncluded) {
"values-night", document("res/values-night/styles.xml").use { document ->
"values-night-v27",
).forEach { directory ->
document("res/$directory/styles.xml").use { document ->
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
val childNodes = resourcesNode.childNodes val childNodes = resourcesNode.childNodes
@ -45,38 +40,41 @@ val darkModeSplashScreenPatch = resourcePatch(
style.setAttribute("name", "Theme.YouTube.Home") style.setAttribute("name", "Theme.YouTube.Home")
style.setAttribute("parent", nodeAttributeParent) style.setAttribute("parent", nodeAttributeParent)
val colorSplashBackgroundColor = "@color/yt_black1" val windowItem = document.createElement("item")
arrayOf( windowItem.setAttribute("name", "android:windowBackground")
"android:navigationBarColor" to colorSplashBackgroundColor, windowItem.textContent = "@color/yt_black1"
"android:windowBackground" to colorSplashBackgroundColor, style.appendChild(windowItem)
"android:colorBackground" to colorSplashBackgroundColor,
"colorPrimaryDark" to colorSplashBackgroundColor,
"android:windowLightStatusBar" to "false",
).forEach { (name, value) ->
val styleItem = document.createElement("item")
styleItem.setAttribute("name", name)
styleItem.textContent = value
style.appendChild(styleItem)
}
resourcesNode.removeChild(node) resourcesNode.removeChild(node)
resourcesNode.appendChild(style) resourcesNode.appendChild(style)
} }
} }
} }
} } else {
} document("res/values-night-v27/styles.xml").use { document ->
// Create a night mode specific override for the splash screen background.
val style = document.createElement("style")
style.setAttribute("name", "Theme.YouTube.Home")
style.setAttribute("parent", "@style/Base.V27.Theme.YouTube.Home")
finalize { // Fix status and navigation bar showing white on some Android devices,
// GmsCore support included // such as SDK 28 Android 10 medium tablet.
if (youtubePackageName != YOUTUBE_PACKAGE_NAME) { val colorSplashBackgroundColor = "@color/yt_black1"
document("AndroidManifest.xml").use { document -> arrayOf(
val mainActivityElement = document.childNodes.findElementByAttributeValueOrThrow( "android:navigationBarColor" to colorSplashBackgroundColor,
"android:name", "android:windowBackground" to colorSplashBackgroundColor,
"com.google.android.apps.youtube.app.watchwhile.MainActivity", "android:colorBackground" to colorSplashBackgroundColor,
) "colorPrimaryDark" to colorSplashBackgroundColor,
"android:windowLightStatusBar" to "false",
).forEach { (name, value) ->
val styleItem = document.createElement("item")
styleItem.setAttribute("name", name)
styleItem.textContent = value
style.appendChild(styleItem)
}
mainActivityElement.setAttribute("android:launchMode", "singleTask") val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
resourcesNode.appendChild(style)
} }
} }
} }