1
1
package app.revanced.patches.youtube.utils.fix.splash
2
2
3
3
import app.revanced.patcher.patch.resourcePatch
4
- import app.revanced.patches.youtube.utils.compatibility.Constants.YOUTUBE_PACKAGE_NAME
5
4
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
6
5
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
9
7
import org.w3c.dom.Element
10
8
11
9
/* *
@@ -22,16 +20,13 @@ val darkModeSplashScreenPatch = resourcePatch(
22
20
) {
23
21
dependsOn(versionCheckPatch)
24
22
25
- execute {
23
+ finalize {
26
24
if (! is_19_32_or_greater) {
27
- return @execute
25
+ return @finalize
28
26
}
29
27
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 ->
35
30
val resourcesNode = document.getElementsByTagName(" resources" ).item(0 ) as Element
36
31
val childNodes = resourcesNode.childNodes
37
32
@@ -45,38 +40,41 @@ val darkModeSplashScreenPatch = resourcePatch(
45
40
style.setAttribute(" name" , " Theme.YouTube.Home" )
46
41
style.setAttribute(" parent" , nodeAttributeParent)
47
42
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)
61
47
62
48
resourcesNode.removeChild(node)
63
49
resourcesNode.appendChild(style)
64
50
}
65
51
}
66
52
}
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" )
69
59
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
+ }
78
75
79
- mainActivityElement.setAttribute(" android:launchMode" , " singleTask" )
76
+ val resourcesNode = document.getElementsByTagName(" resources" ).item(0 ) as Element
77
+ resourcesNode.appendChild(style)
80
78
}
81
79
}
82
80
}
0 commit comments