Skip to content

Commit 22b9833

Browse files
committed
fix(YouTube - Custom branding icon): Splash animation background color is always white inotia00/ReVanced_Extended#2892
1 parent 7e4a71b commit 22b9833

File tree

2 files changed

+36
-45
lines changed

2 files changed

+36
-45
lines changed

patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,30 +218,23 @@ val customBrandingIconPatch = resourcePatch(
218218
}
219219

220220
val styleList = mutableListOf(
221-
Triple(
222-
"values-v31",
221+
Pair(
223222
"Base.Theme.YouTube.Launcher",
224223
"@style/Theme.AppCompat.DayNight.NoActionBar"
225224
),
226225
)
227226

228227
if (is_19_32_or_greater) {
229228
styleList += listOf(
230-
Triple(
231-
"values-night-v31",
232-
"Theme.YouTube.Home",
233-
"@style/Base.V27.Theme.YouTube.Home"
234-
),
235-
Triple(
236-
"values-v31",
229+
Pair(
237230
"Theme.YouTube.Home",
238231
"@style/Base.V27.Theme.YouTube.Home"
239232
),
240233
)
241234
}
242235

243-
styleList.forEach { (directory, nodeAttributeName, nodeAttributeParent) ->
244-
document("res/$directory/styles.xml").use { document ->
236+
styleList.forEach { (nodeAttributeName, nodeAttributeParent) ->
237+
document("res/values-v31/styles.xml").use { document ->
245238
val resourcesNode =
246239
document.getElementsByTagName("resources").item(0) as Element
247240

patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/splash/DarkModeSplashScreenPatch.kt

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package app.revanced.patches.youtube.utils.fix.splash
22

33
import app.revanced.patcher.patch.resourcePatch
4-
import app.revanced.patches.youtube.utils.compatibility.Constants.YOUTUBE_PACKAGE_NAME
54
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
65
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
7-
import app.revanced.patches.youtube.utils.settings.ResourceUtils.youtubePackageName
8-
import app.revanced.util.findElementByAttributeValueOrThrow
6+
import app.revanced.patches.youtube.utils.settings.ResourceUtils.restoreOldSplashAnimationIncluded
97
import org.w3c.dom.Element
108

119
/**
@@ -22,16 +20,13 @@ val darkModeSplashScreenPatch = resourcePatch(
2220
) {
2321
dependsOn(versionCheckPatch)
2422

25-
execute {
23+
finalize {
2624
if (!is_19_32_or_greater) {
27-
return@execute
25+
return@finalize
2826
}
2927

30-
arrayOf(
31-
"values-night",
32-
"values-night-v27",
33-
).forEach { directory ->
34-
document("res/$directory/styles.xml").use { document ->
28+
if (restoreOldSplashAnimationIncluded) {
29+
document("res/values-night/styles.xml").use { document ->
3530
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
3631
val childNodes = resourcesNode.childNodes
3732

@@ -45,38 +40,41 @@ val darkModeSplashScreenPatch = resourcePatch(
4540
style.setAttribute("name", "Theme.YouTube.Home")
4641
style.setAttribute("parent", nodeAttributeParent)
4742

48-
val colorSplashBackgroundColor = "@color/yt_black1"
49-
arrayOf(
50-
"android:navigationBarColor" to colorSplashBackgroundColor,
51-
"android:windowBackground" to colorSplashBackgroundColor,
52-
"android:colorBackground" to colorSplashBackgroundColor,
53-
"colorPrimaryDark" to colorSplashBackgroundColor,
54-
"android:windowLightStatusBar" to "false",
55-
).forEach { (name, value) ->
56-
val styleItem = document.createElement("item")
57-
styleItem.setAttribute("name", name)
58-
styleItem.textContent = value
59-
style.appendChild(styleItem)
60-
}
43+
val windowItem = document.createElement("item")
44+
windowItem.setAttribute("name", "android:windowBackground")
45+
windowItem.textContent = "@color/yt_black1"
46+
style.appendChild(windowItem)
6147

6248
resourcesNode.removeChild(node)
6349
resourcesNode.appendChild(style)
6450
}
6551
}
6652
}
67-
}
68-
}
53+
} else {
54+
document("res/values-night-v27/styles.xml").use { document ->
55+
// Create a night mode specific override for the splash screen background.
56+
val style = document.createElement("style")
57+
style.setAttribute("name", "Theme.YouTube.Home")
58+
style.setAttribute("parent", "@style/Base.V27.Theme.YouTube.Home")
6959

70-
finalize {
71-
// GmsCore support included
72-
if (youtubePackageName != YOUTUBE_PACKAGE_NAME) {
73-
document("AndroidManifest.xml").use { document ->
74-
val mainActivityElement = document.childNodes.findElementByAttributeValueOrThrow(
75-
"android:name",
76-
"com.google.android.apps.youtube.app.watchwhile.MainActivity",
77-
)
60+
// Fix status and navigation bar showing white on some Android devices,
61+
// such as SDK 28 Android 10 medium tablet.
62+
val colorSplashBackgroundColor = "@color/yt_black1"
63+
arrayOf(
64+
"android:navigationBarColor" to colorSplashBackgroundColor,
65+
"android:windowBackground" to colorSplashBackgroundColor,
66+
"android:colorBackground" to colorSplashBackgroundColor,
67+
"colorPrimaryDark" to colorSplashBackgroundColor,
68+
"android:windowLightStatusBar" to "false",
69+
).forEach { (name, value) ->
70+
val styleItem = document.createElement("item")
71+
styleItem.setAttribute("name", name)
72+
styleItem.textContent = value
73+
style.appendChild(styleItem)
74+
}
7875

79-
mainActivityElement.setAttribute("android:launchMode", "singleTask")
76+
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
77+
resourcesNode.appendChild(style)
8078
}
8179
}
8280
}

0 commit comments

Comments
 (0)