Skip to content

Commit ee06ec6

Browse files
anddearufusin
authored andcommitted
feat(YouTube - Custom branding icon): Add more icons
- Add more custom branding icons: AFN, Vanced - Add header icons - Revert back `Add splash animation` to enable MMT splash
1 parent b7d10e9 commit ee06ec6

File tree

321 files changed

+41
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+41
-30
lines changed

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

+37-30
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,27 @@ object CustomBrandingIconPatch : ResourcePatch() {
6565
private const val DEFAULT_ICON_KEY = "Revancify Blue"
6666

6767
private val availableIcon = mapOf(
68+
"AFN Blue" to "afn_blue",
69+
"AFN Red" to "afn_red",
6870
"MMT" to "mmt",
6971
DEFAULT_ICON_KEY to "revancify_blue",
70-
"Revancify Red" to "revancify_red"
72+
"Revancify Red" to "revancify_red",
73+
"Vanced Black" to "vanced_black",
74+
"Vanced Light" to "vanced_light"
7175
)
7276

7377
private val drawableIconResourceFileNames = arrayOf(
78+
"product_logo_youtube_color_24",
79+
"product_logo_youtube_color_36",
80+
"product_logo_youtube_color_144",
81+
"product_logo_youtube_color_192",
82+
"yt_premium_wordmark_header_dark",
83+
"yt_premium_wordmark_header_light",
84+
"yt_wordmark_header_dark",
85+
"yt_wordmark_header_light"
86+
).map { "$it.png" }.toTypedArray()
87+
88+
private val drawableIconResourceFileNamesRevancify = arrayOf(
7489
"product_logo_youtube_color_24",
7590
"product_logo_youtube_color_36",
7691
"product_logo_youtube_color_144",
@@ -165,41 +180,33 @@ object CustomBrandingIconPatch : ResourcePatch() {
165180
// change splash icon.
166181
val drawableAnimResourceFileNames = Array(5) { index -> "\$avd_anim__$index.xml" }
167182

168-
if (appIconValue == "mmt") {
169-
(arrayOf(
170-
ResourceGroup("drawable", "avd_anim.xml", *drawableAnimResourceFileNames)
171-
) + drawableDirectories.map { ResourceGroup(it, *drawableIconResourceFileNames) })
172-
.forEach { context.copyResources("$resourcePath/splash", it) }
173-
} else {
174-
drawableDirectories.map { directory ->
175-
ResourceGroup(
176-
directory, *drawableIconResourceFileNames
177-
)
178-
}.let { resourceGroups ->
179-
resourceGroups.forEach {
180-
context.copyResources("$resourcePath/splash", it)
181-
}
182-
}
183+
val splashResourceGroups: Array<Array<ResourceGroup>> = when (appIconValue) {
184+
"mmt" -> arrayOf(arrayOf(ResourceGroup("drawable", "avd_anim.xml", *drawableAnimResourceFileNames))
185+
.plus(drawableDirectories.map { ResourceGroup(it, *drawableIconResourceFileNames) }))
186+
"revancify_blue", "revancify_red" -> arrayOf(drawableDirectories.map { ResourceGroup(it, *drawableIconResourceFileNamesRevancify) }.toTypedArray())
187+
else -> arrayOf(drawableDirectories.map { ResourceGroup(it, *drawableIconResourceFileNames) }.toTypedArray())
188+
}
183189

184-
// disable splash animation.
190+
splashResourceGroups.forEach { group ->
191+
group.forEach { context.copyResources("$resourcePath/splash", it) }
192+
}
193+
194+
// monochrome
195+
val monochromeIcon = ResourceGroup("drawable", "adaptive_monochrome_ic_youtube_launcher.xml")
196+
if (appIconValue in listOf("mmt", "revancify_blue", "revancify_red")) {
197+
context.copyResources("$resourcePath/monochrome", monochromeIcon)
198+
}
199+
200+
// disable splash animation
201+
if (appIconValue != "mmt") {
185202
context.xmlEditor["res/values-v31/styles.xml"].use { editor ->
186-
val tags = editor.file.getElementsByTagName("item")
187-
List(tags.length) { tags.item(it) as Element }
188-
.filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") }
203+
val nodeList = editor.file.getElementsByTagName("item")
204+
val tags = (0 until nodeList.length).map { nodeList.item(it) as Element }
205+
tags.filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") }
189206
.forEach { it.parentNode.removeChild(it) }
190207
}
191208
}
192209

193-
// change monochrome icon.
194-
arrayOf(
195-
ResourceGroup(
196-
"drawable",
197-
"adaptive_monochrome_ic_youtube_launcher.xml"
198-
)
199-
).forEach { resourceGroup ->
200-
context.copyResources("$resourcePath/monochrome", resourceGroup)
201-
}
202-
203210
context.updatePatchStatusIcon(appIconValue)
204211
}
205212
} ?: throw PatchException("Invalid app icon path.")

0 commit comments

Comments
Β (0)