From bb97a7986bfb29a8c1032b3bbb338cf0f59c14ea Mon Sep 17 00:00:00 2001 From: Aaron Veil <70171475+anddea@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:53:16 +0300 Subject: [PATCH] feat(YouTube - Custom branding icon): Add splash animation for MMT Co-Authored-By: KAZI MMT <82371061+kazimmt@users.noreply.github.com> --- .../branding/icon/CustomBrandingIconPatch.kt | 44 ++++++++++------- .../mmt/splash/drawable/$avd_anim__0.xml | 48 +++++++++++++++++++ .../mmt/splash/drawable/$avd_anim__1.xml | 10 ++++ .../mmt/splash/drawable/$avd_anim__2.xml | 10 ++++ .../mmt/splash/drawable/$avd_anim__3.xml | 11 +++++ .../mmt/splash/drawable/$avd_anim__4.xml | 11 +++++ .../branding/mmt/splash/drawable/avd_anim.xml | 8 ++++ .../branding/mmt/splash/values-v31/style.xml | 7 +++ 8 files changed, 132 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__0.xml create mode 100644 src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__1.xml create mode 100644 src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__2.xml create mode 100644 src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__3.xml create mode 100644 src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__4.xml create mode 100644 src/main/resources/youtube/branding/mmt/splash/drawable/avd_anim.xml create mode 100644 src/main/resources/youtube/branding/mmt/splash/values-v31/style.xml diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt index 9bc1720487..37499e4463 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt @@ -106,7 +106,7 @@ object CustomBrandingIconPatch : ResourcePatch() { values = availableIcon, title = "App icon", description = """ - The path to a folder must contain one or more of the following folders matching the DPI of your device: + The path to a folder containing the following folders: ${mipmapDirectories.joinToString("\n") { "- $it" }} @@ -121,7 +121,7 @@ object CustomBrandingIconPatch : ResourcePatch() { override fun execute(context: ResourceContext) { AppIcon?.let { appIcon -> - val appIconValue = appIcon.lowercase().replace(" ","_") + val appIconValue = appIcon.lowercase().replace(" ", "_") if (!availableIcon.containsValue(appIconValue)) { mipmapDirectories.map { directory -> ResourceGroup( @@ -163,13 +163,31 @@ object CustomBrandingIconPatch : ResourcePatch() { } // change splash icon. - drawableDirectories.map { directory -> - ResourceGroup( - directory, *drawableIconResourceFileNames - ) - }.let { resourceGroups -> - resourceGroups.forEach { - context.copyResources("$resourcePath/splash", it) + val drawableAnimResourceFileNames = Array(5) { index -> "\$avd_anim__$index.xml" } + + if (appIconValue == "mmt") { + (arrayOf( + ResourceGroup("values-v31", "style.xml"), + ResourceGroup("drawable", "avd_anim.xml", *drawableAnimResourceFileNames) + ) + drawableDirectories.map { ResourceGroup(it, *drawableIconResourceFileNames) }) + .forEach { context.copyResources("$resourcePath/splash", it) } + } else { + drawableDirectories.map { directory -> + ResourceGroup( + directory, *drawableIconResourceFileNames + ) + }.let { resourceGroups -> + resourceGroups.forEach { + context.copyResources("$resourcePath/splash", it) + } + } + + // disable splash animation. + context.xmlEditor["res/values-v31/styles.xml"].use { editor -> + val tags = editor.file.getElementsByTagName("item") + List(tags.length) { tags.item(it) as Element } + .filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") } + .forEach { it.parentNode.removeChild(it) } } } @@ -183,14 +201,6 @@ object CustomBrandingIconPatch : ResourcePatch() { context.copyResources("$resourcePath/monochrome", resourceGroup) } - // disable splash animation. - context.xmlEditor["res/values-v31/styles.xml"].use { editor -> - val tags = editor.file.getElementsByTagName("item") - List(tags.length) { tags.item(it) as Element } - .filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") } - .forEach { it.parentNode.removeChild(it) } - } - context.updatePatchStatusIcon(appIconValue) } } ?: throw PatchException("Invalid app icon path.") diff --git a/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__0.xml b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__0.xml new file mode 100644 index 0000000000..536c6071f0 --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__0.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + diff --git a/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__1.xml b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__1.xml new file mode 100644 index 0000000000..d429418bfc --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__1.xml @@ -0,0 +1,10 @@ + + diff --git a/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__2.xml b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__2.xml new file mode 100644 index 0000000000..be41663af3 --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__2.xml @@ -0,0 +1,10 @@ + + diff --git a/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__3.xml b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__3.xml new file mode 100644 index 0000000000..b91965d0c9 --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__3.xml @@ -0,0 +1,11 @@ + + diff --git a/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__4.xml b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__4.xml new file mode 100644 index 0000000000..bd8a269b34 --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/drawable/$avd_anim__4.xml @@ -0,0 +1,11 @@ + + diff --git a/src/main/resources/youtube/branding/mmt/splash/drawable/avd_anim.xml b/src/main/resources/youtube/branding/mmt/splash/drawable/avd_anim.xml new file mode 100644 index 0000000000..6a569c5b9a --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/drawable/avd_anim.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/src/main/resources/youtube/branding/mmt/splash/values-v31/style.xml b/src/main/resources/youtube/branding/mmt/splash/values-v31/style.xml new file mode 100644 index 0000000000..c7462f74ae --- /dev/null +++ b/src/main/resources/youtube/branding/mmt/splash/values-v31/style.xml @@ -0,0 +1,7 @@ + + + +