feat(YouTube - Theme): Add option for black and white splash screen animation (#5119)

This commit is contained in:
LisoUseInAIKyrios
2025-06-05 22:06:12 +02:00
committed by GitHub
parent 50b68f03d4
commit 42db0c2e36
7 changed files with 125 additions and 32 deletions

View File

@ -44,6 +44,19 @@ internal val themeHelperLightColorFingerprint = fingerprint {
}
}
internal const val GRADIENT_LOADING_SCREEN_AB_CONSTANT = 45412406L
internal val useGradientLoadingScreenFingerprint = fingerprint {
literal { GRADIENT_LOADING_SCREEN_AB_CONSTANT }
}
internal const val SPLASH_SCREEN_STYLE_FEATURE_FLAG = 269032877L
internal val splashScreenStyleFingerprint = fingerprint {
returns("V")
parameters("Landroid/os/Bundle;")
literal { SPLASH_SCREEN_STYLE_FEATURE_FLAG }
custom { method, classDef ->
method.name == "onCreate" && classDef.endsWith("/MainActivity;")
}
}

View File

@ -10,6 +10,7 @@ import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.BasePreference
import app.revanced.patches.shared.misc.settings.preference.InputType
import app.revanced.patches.shared.misc.settings.preference.ListPreference
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
@ -17,6 +18,7 @@ import app.revanced.patches.shared.misc.settings.preference.TextPreference
import app.revanced.patches.youtube.layout.seekbar.seekbarColorPatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
import app.revanced.patches.youtube.misc.playservice.is_19_47_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
@ -27,8 +29,6 @@ import org.w3c.dom.Element
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/theme/ThemePatch;"
internal const val GRADIENT_LOADING_SCREEN_AB_CONSTANT = 45412406L
val themePatch = bytecodePatch(
name = "Theme",
description = "Adds options for theming and applies a custom background theme (dark background theme defaults to amoled black).",
@ -232,15 +232,32 @@ val themePatch = bytecodePatch(
addResources("youtube", "layout.theme.themePatch")
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
SwitchPreference("revanced_gradient_loading_screen"),
SwitchPreference("revanced_gradient_loading_screen")
)
if (is_19_47_or_greater) {
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
ListPreference(
key = "splash_screen_animation_style",
summaryKey = null
)
)
}
useGradientLoadingScreenFingerprint.method.insertLiteralOverride(
GRADIENT_LOADING_SCREEN_AB_CONSTANT,
"$EXTENSION_CLASS_DESCRIPTOR->gradientLoadingScreenEnabled(Z)Z"
)
mapOf(
if (is_19_47_or_greater) {
// Lottie splash screen exists in earlier versions, but it may not be always on.
splashScreenStyleFingerprint.method.insertLiteralOverride(
SPLASH_SCREEN_STYLE_FEATURE_FLAG,
"$EXTENSION_CLASS_DESCRIPTOR->getLoadingScreenType(I)I"
)
}
arrayOf(
themeHelperLightColorFingerprint to lightThemeBackgroundColor,
themeHelperDarkColorFingerprint to darkThemeBackgroundColor,
).forEach { (fingerprint, color) ->