From b20240aa5da2b90c1922bcf7350e95ce3b6c56e0 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sun, 15 Dec 2024 14:44:06 +0900 Subject: [PATCH] feat(YouTube - Custom branding icon): Restrict the version that can use the patch option `Restore old splash animation` to 19.16.39 (deprecated) --- .../branding/icon/CustomBrandingIconPatch.kt | 25 +++++++++++-------- .../utils/playservice/VersionCheckPatch.kt | 3 +++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt index d0dbfaeaa..abdb313a7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.resourcePatch import app.revanced.patcher.patch.stringOption import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_BRANDING_ICON_FOR_YOUTUBE +import app.revanced.patches.youtube.utils.playservice.is_19_17_or_greater import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusIcon @@ -129,7 +130,7 @@ val customBrandingIconPatch = resourcePatch( key = "restoreOldSplashAnimation", default = true, title = "Restore old splash animation", - description = "Restore the old style splash animation.", + description = "Restore the old style splash animation. Supports from YouTube 18.29.38 to YouTube 19.16.39.", required = true, ) @@ -178,17 +179,21 @@ val customBrandingIconPatch = resourcePatch( // Change splash screen. if (restoreOldSplashAnimationOption == true) { - oldSplashAnimationResourceGroups.let { resourceGroups -> - resourceGroups.forEach { - copyResources("$appIconResourcePath/splash", it) + if (!is_19_17_or_greater) { + oldSplashAnimationResourceGroups.let { resourceGroups -> + resourceGroups.forEach { + copyResources("$appIconResourcePath/splash", it) + } } - } - copyXmlNode( - "$appIconResourcePath/splash", - "values-v31/styles.xml", - "resources" - ) + copyXmlNode( + "$appIconResourcePath/splash", + "values-v31/styles.xml", + "resources" + ) + } else { + println("WARNING: Restore old splash animation is not supported in this version. Use YouTube 19.16.39 or earlier.") + } } updatePatchStatusIcon(appIcon) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/playservice/VersionCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/playservice/VersionCheckPatch.kt index 6ab15d409..9ed174ff0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/playservice/VersionCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/playservice/VersionCheckPatch.kt @@ -19,6 +19,8 @@ var is_19_02_or_greater = false private set var is_19_15_or_greater = false private set +var is_19_17_or_greater = false + private set var is_19_23_or_greater = false private set var is_19_25_or_greater = false @@ -67,6 +69,7 @@ val versionCheckPatch = resourcePatch( is_18_49_or_greater = 235000000 <= playStoreServicesVersion is_19_02_or_greater = 240204000 < playStoreServicesVersion is_19_15_or_greater = 241602000 <= playStoreServicesVersion + is_19_17_or_greater = 241802000 <= playStoreServicesVersion is_19_23_or_greater = 242402000 <= playStoreServicesVersion is_19_25_or_greater = 242599000 <= playStoreServicesVersion is_19_26_or_greater = 242705000 <= playStoreServicesVersion