fix(YouTube - Theme): Change method to fix dark theme in YouTube 19.32+

This commit is contained in:
inotia00 2025-03-26 15:00:26 +09:00
parent 5c743c299a
commit df41f035b6

View File

@ -1,9 +1,12 @@
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
/**
@ -25,6 +28,19 @@ val darkModeSplashScreenPatch = resourcePatch(
return@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",
)
mainActivityElement.setAttribute("android:launchMode", "singleTask")
}
return@finalize
}
if (restoreOldSplashAnimationIncluded) {
document("res/values-night/styles.xml").use { document ->
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element