Skip to content

Commit ae4b947

Browse files
authored
fix(Custom branding): Update ReVanced logo sizing (#6029)
1 parent 83ccd9d commit ae4b947

File tree

51 files changed

+95
-12
lines changed

Some content is hidden

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

51 files changed

+95
-12
lines changed

β€Žpatches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingPatch.ktβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ val customBrandingPatch = baseCustomBrandingPatch(
6767
"adaptiveproduct_youtube_music_2024_q4_foreground_color_108",
6868
"ic_launcher_release",
6969
),
70+
monochromeIconFileNames = arrayOf("ic_app_icons_themed_youtube_music.xml"),
7071

7172
block = {
7273
dependsOn(disableSplashAnimationPatch)

β€Žpatches/src/main/kotlin/app/revanced/patches/shared/layout/branding/BaseCustomBrandingPatch.ktβ€Ž

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import java.util.logging.Logger
1515
private const val REVANCED_ICON = "ReVanced*Logo" // Can never be a valid path.
1616

1717
internal val mipmapDirectories = arrayOf(
18-
"xxxhdpi",
19-
"xxhdpi",
20-
"xhdpi",
21-
"hdpi",
18+
// Target app does not have ldpi icons.
2219
"mdpi",
20+
"hdpi",
21+
"xhdpi",
22+
"xxhdpi",
23+
"xxxhdpi",
2324
).map { "mipmap-$it" }.toTypedArray()
2425

2526
private fun formatResourceFileList(resourceNames: Array<String>) = resourceNames.joinToString("\n") { "- $it" }
@@ -52,6 +53,7 @@ internal fun baseCustomBrandingPatch(
5253
appNameValues: Map<String, String>,
5354
resourceFolder: String,
5455
iconResourceFileNames: Array<String>,
56+
monochromeIconFileNames: Array<String>,
5557
block: ResourcePatchBuilder.() -> Unit = {},
5658
executeBlock: ResourcePatchContext.() -> Unit = {}
5759
): ResourcePatch = resourcePatch(
@@ -84,14 +86,17 @@ internal fun baseCustomBrandingPatch(
8486
Each of these folders must contain the following files:
8587
8688
${formatResourceFileList(iconResourceFileNamesPng)}
89+
90+
Optionally, a 'drawable' folder with the monochrome icon files:
91+
92+
${formatResourceFileList(monochromeIconFileNames)}
8793
""".trimIndentMultiline(),
8894
)
8995

9096
block()
9197

9298
execute {
93-
// Change the app icon and launch screen.
94-
val iconResourceGroups = mipmapDirectories.map { directory ->
99+
val mipmapIconResourceGroups = mipmapDirectories.map { directory ->
95100
ResourceGroup(
96101
directory,
97102
*iconResourceFileNamesPng,
@@ -100,24 +105,46 @@ internal fun baseCustomBrandingPatch(
100105

101106
val iconPathTrimmed = iconPath!!.trim()
102107
if (iconPathTrimmed == REVANCED_ICON) {
103-
iconResourceGroups.forEach {
104-
copyResources(resourceFolder, it)
108+
// Replace mipmap icons with preset patch icons.
109+
mipmapIconResourceGroups.forEach { groupResources ->
110+
copyResources(resourceFolder, groupResources)
111+
}
112+
113+
// Replace monochrome icons.
114+
monochromeIconFileNames.forEach { fileName ->
115+
copyResources(
116+
resourceFolder,
117+
ResourceGroup("drawable", fileName)
118+
)
105119
}
106120
} else {
107121
val filePath = File(iconPathTrimmed)
108122
val resourceDirectory = get("res")
109123

110-
iconResourceGroups.forEach { group ->
111-
val fromDirectory = filePath.resolve(group.resourceDirectoryName)
112-
val toDirectory = resourceDirectory.resolve(group.resourceDirectoryName)
124+
// Replace
125+
mipmapIconResourceGroups.forEach { groupResources ->
126+
val groupResourceDirectoryName = groupResources.resourceDirectoryName
127+
val fromDirectory = filePath.resolve(groupResourceDirectoryName)
128+
val toDirectory = resourceDirectory.resolve(groupResourceDirectoryName)
113129

114-
group.resources.forEach { iconFileName ->
130+
groupResources.resources.forEach { iconFileName ->
115131
Files.write(
116132
toDirectory.resolve(iconFileName).toPath(),
117133
fromDirectory.resolve(iconFileName).readBytes(),
118134
)
119135
}
120136
}
137+
138+
// Copy all monochrome icons if provided.
139+
monochromeIconFileNames.forEach { fileName ->
140+
val replacementMonochrome = filePath.resolve("drawable").resolve(fileName)
141+
if (replacementMonochrome.exists()) {
142+
Files.write(
143+
resourceDirectory.resolve("drawable").resolve(fileName).toPath(),
144+
replacementMonochrome.readBytes(),
145+
)
146+
}
147+
}
121148
}
122149

123150
// Change the app name.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ val customBrandingPatch = baseCustomBrandingPatch(
2727
"ic_launcher",
2828
"ic_launcher_round",
2929
),
30+
monochromeIconFileNames = arrayOf(
31+
"adaptive_monochrome_ic_youtube_launcher.xml",
32+
"ringo2_adaptive_monochrome_ic_youtube_launcher.xml"
33+
),
3034

3135
block = {
3236
compatibleWith(
1021 Bytes
877 Bytes
591 Bytes
517 Bytes
1.33 KB
1.18 KB
2.57 KB

0 commit comments

Comments
Β (0)