Skip to content

Commit

Permalink
feat(YouTube - Custom branding icon): Add splash animation for MMT
Browse files Browse the repository at this point in the history
Co-Authored-By: KAZI MMT <82371061+kazimmt@users.noreply.github.com>
  • Loading branch information
anddea and kazimmt committed Mar 29, 2024
1 parent f83954f commit bb97a79
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 17 deletions.
Expand Up @@ -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" }}
Expand All @@ -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(
Expand Down Expand Up @@ -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) }
}
}

Expand All @@ -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.")
Expand Down
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:name="avd_anim"
android:height="432.0dip"
android:width="432.0dip"
android:viewportWidth="432.0"
android:viewportHeight="432.0"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<path
android:name="background"
android:fillColor="#ff1a202e"
android:pathData="M 350.1 144.6 C 346.9 131.8 337.4 121.8 325.3 118.4 C 303.5 112.2 215.9 112.2 215.9 112.2 C 215.9 112.2 128.3 112.2 106.5 118.4 C 94.4 121.8 85 131.9 81.7 144.6 C 76 167.7 76 216 76 216 C 76 216 76 264.3 81.9 287.4 C 85.1 300.2 94.6 310.2 106.7 313.6 C 128.5 319.8 216.1 319.8 216.1 319.8 C 216.1 319.8 303.7 319.8 325.5 313.6 C 337.6 310.2 347 300.1 350.3 287.4 C 356 264.3 356 216 356 216 C 356 216 356 167.7 350.1 144.6 Z"
android:strokeAlpha="0.0"
android:fillType="evenOdd" />
<group
android:name="outer_red_shape">
<clip-path
android:name="outer_red"
android:pathData="M 216 293.7 C 213.4 293.7 151.6 293.6 135.6 289.1 C 126.2 286.4 118.7 278.6 116.3 268.7 C 112 251.8 112 217.5 112 216.1 C 112 214.7 112.1 180.4 116.3 163.5 C 118.8 153.6 126.2 145.7 135.6 143.1 C 151.6 138.6 213.3 138.5 216 138.5 C 218.7 138.5 280.4 138.6 296.4 143.1 C 305.8 145.8 313.3 153.6 315.7 163.5 C 319.9 180.4 320 214.6 320 216.1 C 320 217.6 319.9 251.8 315.7 268.7 C 313.2 278.6 305.8 286.5 296.4 289.1 C 280.4 293.6 218.6 293.7 216 293.7 Z M 216 142 C 215.3 142 152.1 142.1 136.6 146.5 C 128.4 148.8 122 155.6 119.8 164.3 C 115.6 180.8 115.6 215.6 115.6 216 C 115.6 216.4 115.7 251.2 119.8 267.7 C 122 276.4 128.4 283.2 136.6 285.5 C 152.1 289.9 215.3 290 216 290 C 216.7 290 279.9 289.9 295.4 285.5 C 303.6 283.2 310 276.4 312.2 267.7 C 316.4 251.2 316.4 216.4 316.4 216 C 316.4 215.6 316.3 180.8 312.2 164.3 C 310 155.6 303.6 148.8 295.4 146.5 C 279.9 142.1 216.7 142 216 142 Z" />
<path
android:name="red_circle"
android:fillColor="#ffff4151"
android:pathData="M 216 198.1 C 211.254 198.1 206.698 199.987 203.343 203.343 C 199.987 206.698 198.1 211.254 198.1 216 C 198.1 220.746 199.987 225.302 203.343 228.657 C 206.698 232.013 211.254 233.9 216 233.9 C 219.787 233.912 223.482 232.722 226.551 230.501 C 229.619 228.281 231.904 225.143 233.077 221.542 C 234.25 217.941 234.25 214.059 233.077 210.458 C 231.904 206.857 229.619 203.719 226.551 201.499 C 223.482 199.278 219.787 198.088 216 198.1 Z"
android:strokeAlpha="0.0"
android:fillType="evenOdd" />
</group>
<group
android:name="white_triangle">
<path
android:name="white_triangle_inside"
android:fillColor="#ffe5e9f0"
android:pathData="M -5.8 217.7 L -3.8 216.3 C -3.5 216.1 -3.5 215.8 -3.8 215.6 L -5.8 214.2 C -6.1 214 -6.3 214.1 -6.3 214.4 L -6.3 217.3 C -6.3 217.8 -6.1 217.9 -5.8 217.7 Z"
android:strokeAlpha="0.0" />
</group>
<group
android:name="red_arrow">
<clip-path
android:name="red_arrow_inside"
android:pathData="M 207.8 249.7 L 249.4 219.5 C 252 217.6 252 214.6 249.4 212.8 L 207.8 182.6 C 206.6 181.7 205.8 180.3 205.5 178.9 C 205.3 177.4 205.6 175.8 206.5 174.6 C 207.4 173.4 208.8 172.6 210.2 172.3 C 211.7 172.1 213.3 172.4 214.5 173.3 L 267.3 211.7 C 270.7 214.2 270.7 218.2 267.3 220.7 L 214.5 259 C 213.3 259.9 211.7 260.2 210.2 260 C 208.7 259.8 207.4 258.9 206.5 257.7 C 205.6 256.5 205.3 254.9 205.5 253.4 C 205.7 251.9 206.6 250.6 207.8 249.7 Z" />
<path
android:name="red_arrow_color"
android:fillColor="#ffff4151"
android:pathData="M 232.1 152.8 C 232.1 152.8 232.1 152.8 232.1 152.8 C 231.8 152.8 231.7 152.7 231.6 152.5 C 231.5 152.4 231.5 152.2 231.5 152 C 231.5 151.8 231.6 151.7 231.8 151.6 L 234.6 149.5 L 231.8 147.4 C 231.7 147.3 231.6 147.1 231.5 147 C 231.5 146.8 231.5 146.7 231.6 146.5 C 231.7 146.4 231.9 146.3 232 146.2 L 232.1 146.2 C 232.2 146.2 232.4 146.2 232.5 146.3 L 236.1 148.9 C 236.3 149 236.4 149.2 236.4 149.4 C 236.4 149.6 236.3 149.8 236.1 149.9 L 232.5 152.5 C 232.4 152.7 232.2 152.8 232.1 152.8 Z"
android:strokeAlpha="0.0"
android:fillType="evenOdd" />
</group>
</vector>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
android:interpolator="@android:anim/overshoot_interpolator"
android:duration="750"
android:valueFrom="M -0.3 213.8 C -0.4 213.4 -0.7 213.1 -1.1 213 C -1.8 212.8 -4.5 212.8 -4.5 212.8 C -4.5 212.8 -7.2 212.8 -7.9 213 C -8.3 213.1 -8.6 213.4 -8.7 213.8 C -8.9 214.5 -8.9 216 -8.9 216 C -8.9 216 -8.9 217.5 -8.7 218.2 C -8.6 218.6 -8.3 218.9 -7.9 219 C -7.2 219.2 -4.5 219.2 -4.5 219.2 C -4.5 219.2 -1.8 219.2 -1.1 219 C -0.7 218.9 -0.4 218.6 -0.3 218.2 C -0.1 217.5 -0.1 216 -0.1 216 C -0.1 216 -0.1 214.5 -0.3 213.8 Z"
android:valueTo="M 313.9 163.9 C 311.6 154.6 304.6 147.3 295.8 144.8 C 279.9 140.3 215.9 140.3 215.9 140.3 C 215.9 140.3 152 140.3 136 144.8 C 127.2 147.3 120.3 154.7 117.9 163.9 C 113.7 180.8 113.7 216 113.7 216 C 113.7 216 113.7 251.3 118 268.1 C 120.3 277.4 127.3 284.7 136.1 287.2 C 152 291.7 216 291.7 216 291.7 C 216 291.7 279.9 291.7 295.9 287.2 C 304.7 284.7 311.6 277.3 314 268.1 C 318.2 251.2 318.2 216 318.2 216 C 318.2 216 318.2 180.8 313.9 163.9 Z"
android:valueType="pathType"
android:propertyName="pathData"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt" />
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
android:interpolator="@android:interpolator/fast_out_linear_in"
android:duration="1500"
android:valueFrom="M 216 198.1 C 211.254 198.1 206.698 199.987 203.343 203.343 C 199.987 206.698 198.1 211.254 198.1 216 C 198.1 220.746 199.987 225.302 203.343 228.657 C 206.698 232.013 211.254 233.9 216 233.9 C 219.787 233.912 223.482 232.722 226.551 230.501 C 229.619 228.281 231.904 225.143 233.077 221.542 C 234.25 217.941 234.25 214.059 233.077 210.458 C 231.904 206.857 229.619 203.719 226.551 201.499 C 223.482 199.278 219.787 198.088 216 198.1 Z"
android:valueTo="M 216 -147.7 C 119.578 -147.7 27.006 -109.356 -41.175 -41.175 C -109.356 27.006 -147.7 119.578 -147.7 216 C -147.7 312.422 -109.356 404.994 -41.175 473.175 C 27.006 541.356 119.578 579.7 216 579.7 C 312.422 579.7 404.994 541.356 473.175 473.175 C 507.265 439.084 533.897 398.896 552.005 355.178 C 570.114 311.459 579.7 264.211 579.7 216 C 579.7 119.578 541.356 27.006 473.175 -41.175 C 404.994 -109.356 312.422 -147.7 216 -147.7 Z"
android:valueType="pathType"
android:propertyName="pathData"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt" />
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
android:interpolator="@android:interpolator/fast_out_slow_in"
android:duration="750"
android:startOffset="500"
android:valueFrom="M 216 145.7 L 302.3 152.8 L 265.3 74.5 Z"
android:valueTo="M -57.7 274.9 L 551.1 325.2 L 290.2 -227.2 Z"
android:valueType="pathType"
android:propertyName="pathData"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt" />
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
android:interpolator="@android:interpolator/fast_out_slow_in"
android:duration="750"
android:startOffset="250"
android:valueFrom="M -5.8 217.7 L -3.8 216.3 C -3.5 216.1 -3.5 215.8 -3.8 215.6 L -5.8 214.2 C -6.1 214 -6.3 214.1 -6.3 214.4 L -6.3 217.3 C -6.3 217.8 -6.1 217.9 -5.8 217.7 Z"
android:valueTo="M 184.4 255.9 L 230 223.7 C 236 219.5 236 212.6 230 208.4 L 184.4 176.2 C 178.4 172 173.6 174.5 173.6 181.8 L 173.6 250.3 C 173.6 257.6 178.4 260.1 184.4 255.9 Z"
android:valueType="pathType"
android:propertyName="pathData"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt" />
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector android:drawable="@drawable/$avd_anim__0"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
<target android:name="background" android:animation="@drawable/$avd_anim__1" />
<target android:name="red_circle" android:animation="@drawable/$avd_anim__2" />
<target android:name="red_arrow_color" android:animation="@drawable/$avd_anim__3" />
<target android:name="white_triangle_inside" android:animation="@drawable/$avd_anim__4" />
</animated-vector>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.YouTube.Launcher" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowSplashScreenAnimatedIcon">@drawable/avd_anim</item>
<item name="android:windowSplashScreenAnimationDuration">1000</item>
</style>
</resources>

0 comments on commit bb97a79

Please sign in to comment.