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>()
|
val styleList = if (is_19_32_or_greater)
|
||||||
styleMap["Base.Theme.YouTube.Launcher"] =
|
listOf(
|
||||||
"@style/Theme.AppCompat.DayNight.NoActionBar"
|
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) {
|
styleList.forEach { (directory, nodeAttributeName, nodeAttributeParent) ->
|
||||||
styleMap["Theme.YouTube.Home"] = "@style/Base.V27.Theme.YouTube.Home"
|
document("res/$directory/styles.xml").use { document ->
|
||||||
}
|
|
||||||
|
|
||||||
styleMap.forEach { (nodeAttributeName, nodeAttributeParent) ->
|
|
||||||
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
|
||||||
|
|
||||||
@ -234,21 +248,23 @@ val customBrandingIconPatch = resourcePatch(
|
|||||||
style.setAttribute("name", nodeAttributeName)
|
style.setAttribute("name", nodeAttributeName)
|
||||||
style.setAttribute("parent", nodeAttributeParent)
|
style.setAttribute("parent", nodeAttributeParent)
|
||||||
|
|
||||||
val primaryItem = document.createElement("item")
|
val splashScreenAnimatedIcon = document.createElement("item")
|
||||||
primaryItem.setAttribute("name", "android:windowSplashScreenAnimatedIcon")
|
splashScreenAnimatedIcon.setAttribute("name", "android:windowSplashScreenAnimatedIcon")
|
||||||
primaryItem.textContent = "@drawable/avd_anim"
|
splashScreenAnimatedIcon.textContent = "@drawable/avd_anim"
|
||||||
val secondaryItem = document.createElement("item")
|
|
||||||
secondaryItem.setAttribute(
|
// Deprecated in Android 13+
|
||||||
|
val splashScreenAnimationDuration = document.createElement("item")
|
||||||
|
splashScreenAnimationDuration.setAttribute(
|
||||||
"name",
|
"name",
|
||||||
"android:windowSplashScreenAnimationDuration"
|
"android:windowSplashScreenAnimationDuration"
|
||||||
)
|
)
|
||||||
secondaryItem.textContent = if (appIcon.startsWith("revancify"))
|
splashScreenAnimationDuration.textContent = if (appIcon.startsWith("revancify"))
|
||||||
"1500"
|
"1500"
|
||||||
else
|
else
|
||||||
"1000"
|
"1000"
|
||||||
|
|
||||||
style.appendChild(primaryItem)
|
style.appendChild(splashScreenAnimatedIcon)
|
||||||
style.appendChild(secondaryItem)
|
style.appendChild(splashScreenAnimationDuration)
|
||||||
|
|
||||||
resourcesNode.appendChild(style)
|
resourcesNode.appendChild(style)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
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.restoreOldSplashAnimationIncluded
|
|
||||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.youtubePackageName
|
|
||||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,57 +19,21 @@ val darkModeSplashScreenPatch = resourcePatch(
|
|||||||
) {
|
) {
|
||||||
dependsOn(versionCheckPatch)
|
dependsOn(versionCheckPatch)
|
||||||
|
|
||||||
finalize {
|
execute {
|
||||||
if (!is_19_32_or_greater) {
|
if (!is_19_32_or_greater) {
|
||||||
return@finalize
|
return@execute
|
||||||
}
|
}
|
||||||
|
|
||||||
// GmsCore support included
|
arrayOf(
|
||||||
if (youtubePackageName != YOUTUBE_PACKAGE_NAME) {
|
"values-night" to "@style/Base.V23.Theme.YouTube.Home",
|
||||||
document("AndroidManifest.xml").use { document ->
|
"values-night-v27" to "@style/Base.V27.Theme.YouTube.Home",
|
||||||
val mainActivityElement = document.childNodes.findElementByAttributeValueOrThrow(
|
).forEach { (directory, parent) ->
|
||||||
"android:name",
|
document("res/$directory/styles.xml").use { document ->
|
||||||
"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 ->
|
|
||||||
// Create a night mode specific override for the splash screen background.
|
// Create a night mode specific override for the splash screen background.
|
||||||
val style = document.createElement("style")
|
val style = document.createElement("style")
|
||||||
style.setAttribute("name", "Theme.YouTube.Home")
|
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"
|
val colorSplashBackgroundColor = "@color/yt_black1"
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"android:navigationBarColor" to colorSplashBackgroundColor,
|
"android:navigationBarColor" to colorSplashBackgroundColor,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user