mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
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:
parent
7e4a71b385
commit
22b98336d5
@ -218,8 +218,7 @@ val customBrandingIconPatch = resourcePatch(
|
||||
}
|
||||
|
||||
val styleList = mutableListOf(
|
||||
Triple(
|
||||
"values-v31",
|
||||
Pair(
|
||||
"Base.Theme.YouTube.Launcher",
|
||||
"@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
),
|
||||
@ -227,21 +226,15 @@ val customBrandingIconPatch = resourcePatch(
|
||||
|
||||
if (is_19_32_or_greater) {
|
||||
styleList += listOf(
|
||||
Triple(
|
||||
"values-night-v31",
|
||||
"Theme.YouTube.Home",
|
||||
"@style/Base.V27.Theme.YouTube.Home"
|
||||
),
|
||||
Triple(
|
||||
"values-v31",
|
||||
Pair(
|
||||
"Theme.YouTube.Home",
|
||||
"@style/Base.V27.Theme.YouTube.Home"
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
styleList.forEach { (directory, nodeAttributeName, nodeAttributeParent) ->
|
||||
document("res/$directory/styles.xml").use { document ->
|
||||
styleList.forEach { (nodeAttributeName, nodeAttributeParent) ->
|
||||
document("res/values-v31/styles.xml").use { document ->
|
||||
val resourcesNode =
|
||||
document.getElementsByTagName("resources").item(0) as Element
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package app.revanced.patches.youtube.utils.fix.splash
|
||||
|
||||
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.versionCheckPatch
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.youtubePackageName
|
||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.restoreOldSplashAnimationIncluded
|
||||
import org.w3c.dom.Element
|
||||
|
||||
/**
|
||||
@ -22,16 +20,13 @@ val darkModeSplashScreenPatch = resourcePatch(
|
||||
) {
|
||||
dependsOn(versionCheckPatch)
|
||||
|
||||
execute {
|
||||
finalize {
|
||||
if (!is_19_32_or_greater) {
|
||||
return@execute
|
||||
return@finalize
|
||||
}
|
||||
|
||||
arrayOf(
|
||||
"values-night",
|
||||
"values-night-v27",
|
||||
).forEach { directory ->
|
||||
document("res/$directory/styles.xml").use { document ->
|
||||
if (restoreOldSplashAnimationIncluded) {
|
||||
document("res/values-night/styles.xml").use { document ->
|
||||
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||
val childNodes = resourcesNode.childNodes
|
||||
|
||||
@ -45,38 +40,41 @@ val darkModeSplashScreenPatch = resourcePatch(
|
||||
style.setAttribute("name", "Theme.YouTube.Home")
|
||||
style.setAttribute("parent", nodeAttributeParent)
|
||||
|
||||
val colorSplashBackgroundColor = "@color/yt_black1"
|
||||
arrayOf(
|
||||
"android:navigationBarColor" to colorSplashBackgroundColor,
|
||||
"android:windowBackground" to colorSplashBackgroundColor,
|
||||
"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)
|
||||
}
|
||||
val windowItem = document.createElement("item")
|
||||
windowItem.setAttribute("name", "android:windowBackground")
|
||||
windowItem.textContent = "@color/yt_black1"
|
||||
style.appendChild(windowItem)
|
||||
|
||||
resourcesNode.removeChild(node)
|
||||
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 {
|
||||
// GmsCore support included
|
||||
if (youtubePackageName != YOUTUBE_PACKAGE_NAME) {
|
||||
document("AndroidManifest.xml").use { document ->
|
||||
val mainActivityElement = document.childNodes.findElementByAttributeValueOrThrow(
|
||||
"android:name",
|
||||
"com.google.android.apps.youtube.app.watchwhile.MainActivity",
|
||||
)
|
||||
// Fix status and navigation bar showing white on some Android devices,
|
||||
// such as SDK 28 Android 10 medium tablet.
|
||||
val colorSplashBackgroundColor = "@color/yt_black1"
|
||||
arrayOf(
|
||||
"android:navigationBarColor" to colorSplashBackgroundColor,
|
||||
"android:windowBackground" to colorSplashBackgroundColor,
|
||||
"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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user