mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
fix(YouTube - Custom branding icon): Remove unnecessary hooks
This commit is contained in:
parent
35e6c26823
commit
edccd61e6b
@ -217,16 +217,30 @@ val customBrandingIconPatch = resourcePatch(
|
||||
}
|
||||
}
|
||||
|
||||
val styleMap = mutableMapOf<String, String>()
|
||||
styleMap["Base.Theme.YouTube.Launcher"] =
|
||||
"@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
val styleList = if (is_19_32_or_greater)
|
||||
listOf(
|
||||
Triple(
|
||||
"values-night-v31",
|
||||
"Theme.YouTube.Home",
|
||||
"@style/Base.V27.Theme.YouTube.Home"
|
||||
),
|
||||
Triple(
|
||||
"values-v31",
|
||||
"Theme.YouTube.Home",
|
||||
"@style/Base.V27.Theme.YouTube.Home"
|
||||
),
|
||||
)
|
||||
else
|
||||
listOf(
|
||||
Triple(
|
||||
"values-v31",
|
||||
"Base.Theme.YouTube.Launcher",
|
||||
"@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
),
|
||||
)
|
||||
|
||||
if (is_19_32_or_greater) {
|
||||
styleMap["Theme.YouTube.Home"] = "@style/Base.V27.Theme.YouTube.Home"
|
||||
}
|
||||
|
||||
styleMap.forEach { (nodeAttributeName, nodeAttributeParent) ->
|
||||
document("res/values-v31/styles.xml").use { document ->
|
||||
styleList.forEach { (directory, nodeAttributeName, nodeAttributeParent) ->
|
||||
document("res/$directory/styles.xml").use { document ->
|
||||
val resourcesNode =
|
||||
document.getElementsByTagName("resources").item(0) as Element
|
||||
|
||||
@ -234,21 +248,23 @@ val customBrandingIconPatch = resourcePatch(
|
||||
style.setAttribute("name", nodeAttributeName)
|
||||
style.setAttribute("parent", nodeAttributeParent)
|
||||
|
||||
val primaryItem = document.createElement("item")
|
||||
primaryItem.setAttribute("name", "android:windowSplashScreenAnimatedIcon")
|
||||
primaryItem.textContent = "@drawable/avd_anim"
|
||||
val secondaryItem = document.createElement("item")
|
||||
secondaryItem.setAttribute(
|
||||
val splashScreenAnimatedIcon = document.createElement("item")
|
||||
splashScreenAnimatedIcon.setAttribute("name", "android:windowSplashScreenAnimatedIcon")
|
||||
splashScreenAnimatedIcon.textContent = "@drawable/avd_anim"
|
||||
|
||||
// Deprecated in Android 13+
|
||||
val splashScreenAnimationDuration = document.createElement("item")
|
||||
splashScreenAnimationDuration.setAttribute(
|
||||
"name",
|
||||
"android:windowSplashScreenAnimationDuration"
|
||||
)
|
||||
secondaryItem.textContent = if (appIcon.startsWith("revancify"))
|
||||
splashScreenAnimationDuration.textContent = if (appIcon.startsWith("revancify"))
|
||||
"1500"
|
||||
else
|
||||
"1000"
|
||||
|
||||
style.appendChild(primaryItem)
|
||||
style.appendChild(secondaryItem)
|
||||
style.appendChild(splashScreenAnimatedIcon)
|
||||
style.appendChild(splashScreenAnimationDuration)
|
||||
|
||||
resourcesNode.appendChild(style)
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
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.restoreOldSplashAnimationIncluded
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.youtubePackageName
|
||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
import org.w3c.dom.Element
|
||||
|
||||
/**
|
||||
@ -23,57 +19,21 @@ val darkModeSplashScreenPatch = resourcePatch(
|
||||
) {
|
||||
dependsOn(versionCheckPatch)
|
||||
|
||||
finalize {
|
||||
execute {
|
||||
if (!is_19_32_or_greater) {
|
||||
return@finalize
|
||||
return@execute
|
||||
}
|
||||
|
||||
// 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",
|
||||
)
|
||||
|
||||
mainActivityElement.setAttribute("android:launchMode", "singleTask")
|
||||
}
|
||||
}
|
||||
|
||||
if (restoreOldSplashAnimationIncluded) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
document("res/values-night-v27/styles.xml").use { document ->
|
||||
arrayOf(
|
||||
"values-night" to "@style/Base.V23.Theme.YouTube.Home",
|
||||
"values-night-v27" to "@style/Base.V27.Theme.YouTube.Home",
|
||||
).forEach { (directory, parent) ->
|
||||
document("res/$directory/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")
|
||||
style.setAttribute("parent", parent)
|
||||
|
||||
// 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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user