Skip to content

Commit bb97a79

Browse files
anddeakazimmt
andcommitted
feat(YouTube - Custom branding icon): Add splash animation for MMT
Co-Authored-By: KAZI MMT <[email protected]>
1 parent f83954f commit bb97a79

File tree

8 files changed

+132
-17
lines changed

8 files changed

+132
-17
lines changed

src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt

+27-17
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ object CustomBrandingIconPatch : ResourcePatch() {
106106
values = availableIcon,
107107
title = "App icon",
108108
description = """
109-
The path to a folder must contain one or more of the following folders matching the DPI of your device:
109+
The path to a folder containing the following folders:
110110
111111
${mipmapDirectories.joinToString("\n") { "- $it" }}
112112
@@ -121,7 +121,7 @@ object CustomBrandingIconPatch : ResourcePatch() {
121121

122122
override fun execute(context: ResourceContext) {
123123
AppIcon?.let { appIcon ->
124-
val appIconValue = appIcon.lowercase().replace(" ","_")
124+
val appIconValue = appIcon.lowercase().replace(" ", "_")
125125
if (!availableIcon.containsValue(appIconValue)) {
126126
mipmapDirectories.map { directory ->
127127
ResourceGroup(
@@ -163,13 +163,31 @@ object CustomBrandingIconPatch : ResourcePatch() {
163163
}
164164

165165
// change splash icon.
166-
drawableDirectories.map { directory ->
167-
ResourceGroup(
168-
directory, *drawableIconResourceFileNames
169-
)
170-
}.let { resourceGroups ->
171-
resourceGroups.forEach {
172-
context.copyResources("$resourcePath/splash", it)
166+
val drawableAnimResourceFileNames = Array(5) { index -> "\$avd_anim__$index.xml" }
167+
168+
if (appIconValue == "mmt") {
169+
(arrayOf(
170+
ResourceGroup("values-v31", "style.xml"),
171+
ResourceGroup("drawable", "avd_anim.xml", *drawableAnimResourceFileNames)
172+
) + drawableDirectories.map { ResourceGroup(it, *drawableIconResourceFileNames) })
173+
.forEach { context.copyResources("$resourcePath/splash", it) }
174+
} else {
175+
drawableDirectories.map { directory ->
176+
ResourceGroup(
177+
directory, *drawableIconResourceFileNames
178+
)
179+
}.let { resourceGroups ->
180+
resourceGroups.forEach {
181+
context.copyResources("$resourcePath/splash", it)
182+
}
183+
}
184+
185+
// disable splash animation.
186+
context.xmlEditor["res/values-v31/styles.xml"].use { editor ->
187+
val tags = editor.file.getElementsByTagName("item")
188+
List(tags.length) { tags.item(it) as Element }
189+
.filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") }
190+
.forEach { it.parentNode.removeChild(it) }
173191
}
174192
}
175193

@@ -183,14 +201,6 @@ object CustomBrandingIconPatch : ResourcePatch() {
183201
context.copyResources("$resourcePath/monochrome", resourceGroup)
184202
}
185203

186-
// disable splash animation.
187-
context.xmlEditor["res/values-v31/styles.xml"].use { editor ->
188-
val tags = editor.file.getElementsByTagName("item")
189-
List(tags.length) { tags.item(it) as Element }
190-
.filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") }
191-
.forEach { it.parentNode.removeChild(it) }
192-
}
193-
194204
context.updatePatchStatusIcon(appIconValue)
195205
}
196206
} ?: throw PatchException("Invalid app icon path.")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector
3+
android:name="avd_anim"
4+
android:height="432.0dip"
5+
android:width="432.0dip"
6+
android:viewportWidth="432.0"
7+
android:viewportHeight="432.0"
8+
xmlns:android="http://schemas.android.com/apk/res/android"
9+
xmlns:aapt="http://schemas.android.com/aapt">
10+
<path
11+
android:name="background"
12+
android:fillColor="#ff1a202e"
13+
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"
14+
android:strokeAlpha="0.0"
15+
android:fillType="evenOdd" />
16+
<group
17+
android:name="outer_red_shape">
18+
<clip-path
19+
android:name="outer_red"
20+
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" />
21+
<path
22+
android:name="red_circle"
23+
android:fillColor="#ffff4151"
24+
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"
25+
android:strokeAlpha="0.0"
26+
android:fillType="evenOdd" />
27+
</group>
28+
<group
29+
android:name="white_triangle">
30+
<path
31+
android:name="white_triangle_inside"
32+
android:fillColor="#ffe5e9f0"
33+
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"
34+
android:strokeAlpha="0.0" />
35+
</group>
36+
<group
37+
android:name="red_arrow">
38+
<clip-path
39+
android:name="red_arrow_inside"
40+
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" />
41+
<path
42+
android:name="red_arrow_color"
43+
android:fillColor="#ffff4151"
44+
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"
45+
android:strokeAlpha="0.0"
46+
android:fillType="evenOdd" />
47+
</group>
48+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<objectAnimator
3+
android:interpolator="@android:anim/overshoot_interpolator"
4+
android:duration="750"
5+
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"
6+
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"
7+
android:valueType="pathType"
8+
android:propertyName="pathData"
9+
xmlns:android="http://schemas.android.com/apk/res/android"
10+
xmlns:aapt="http://schemas.android.com/aapt" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<objectAnimator
3+
android:interpolator="@android:interpolator/fast_out_linear_in"
4+
android:duration="1500"
5+
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"
6+
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"
7+
android:valueType="pathType"
8+
android:propertyName="pathData"
9+
xmlns:android="http://schemas.android.com/apk/res/android"
10+
xmlns:aapt="http://schemas.android.com/aapt" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<objectAnimator
3+
android:interpolator="@android:interpolator/fast_out_slow_in"
4+
android:duration="750"
5+
android:startOffset="500"
6+
android:valueFrom="M 216 145.7 L 302.3 152.8 L 265.3 74.5 Z"
7+
android:valueTo="M -57.7 274.9 L 551.1 325.2 L 290.2 -227.2 Z"
8+
android:valueType="pathType"
9+
android:propertyName="pathData"
10+
xmlns:android="http://schemas.android.com/apk/res/android"
11+
xmlns:aapt="http://schemas.android.com/aapt" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<objectAnimator
3+
android:interpolator="@android:interpolator/fast_out_slow_in"
4+
android:duration="750"
5+
android:startOffset="250"
6+
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"
7+
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"
8+
android:valueType="pathType"
9+
android:propertyName="pathData"
10+
xmlns:android="http://schemas.android.com/apk/res/android"
11+
xmlns:aapt="http://schemas.android.com/aapt" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<animated-vector android:drawable="@drawable/$avd_anim__0"
3+
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
4+
<target android:name="background" android:animation="@drawable/$avd_anim__1" />
5+
<target android:name="red_circle" android:animation="@drawable/$avd_anim__2" />
6+
<target android:name="red_arrow_color" android:animation="@drawable/$avd_anim__3" />
7+
<target android:name="white_triangle_inside" android:animation="@drawable/$avd_anim__4" />
8+
</animated-vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="Base.Theme.YouTube.Launcher" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
4+
<item name="android:windowSplashScreenAnimatedIcon">@drawable/avd_anim</item>
5+
<item name="android:windowSplashScreenAnimationDuration">1000</item>
6+
</style>
7+
</resources>

0 commit comments

Comments
 (0)