Skip to content

Commit 8b30f38

Browse files
committed
refactor
1 parent d272ff4 commit 8b30f38

File tree

23 files changed

+33
-23
lines changed

23 files changed

+33
-23
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ val customBrandingPatch = baseCustomBrandingPatch(
7171
adaptiveIconFileNames = arrayOf(
7272
"adaptiveproduct_youtube_music_2024_q4_background_color_108.xml",
7373
"adaptiveproduct_youtube_music_2024_q4_foreground_color_108.xml",
74-
),
74+
),
75+
legacyIconResourceFileNames = arrayOf("ic_launcher_release"),
7576

7677
block = {
7778
dependsOn(disableSplashAnimationPatch)

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ internal fun baseCustomBrandingPatch(
5555
iconResourceFileNames: Array<String>,
5656
monochromeIconFileNames: Array<String>,
5757
adaptiveIconFileNames: Array<String>,
58+
legacyIconResourceFileNames: Array<String>,
5859
block: ResourcePatchBuilder.() -> Unit = {},
5960
executeBlock: ResourcePatchContext.() -> Unit = {}
6061
): ResourcePatch = resourcePatch(
@@ -63,6 +64,7 @@ internal fun baseCustomBrandingPatch(
6364
use = false,
6465
) {
6566
val iconResourceFileNamesPng = iconResourceFileNames.map { "$it.png" }.toTypedArray<String>()
67+
val legacyIconResourceFileNamesPng = legacyIconResourceFileNames.map { "$it.png" }.toTypedArray<String>()
6668

6769
val appName by stringOption(
6870
key = "appName",
@@ -97,40 +99,43 @@ internal fun baseCustomBrandingPatch(
9799
block()
98100

99101
execute {
100-
val mipmapIconResourceGroups = mipmapDirectories.map { directory ->
101-
ResourceGroup(
102-
directory,
103-
*iconResourceFileNamesPng,
104-
)
105-
}
106-
107102
val iconPathTrimmed = iconPath!!.trim()
108103
if (iconPathTrimmed == REVANCED_ICON) {
109-
// Replace mipmap icons with preset patch icons.
104+
val mipmapIconResourceGroups = mipmapDirectories.map { directory ->
105+
ResourceGroup(
106+
directory,
107+
*legacyIconResourceFileNamesPng,
108+
)
109+
}
110+
111+
// Copy monochrome icons.
112+
copyResources(
113+
resourceFolder,
114+
ResourceGroup("drawable", *monochromeIconFileNames)
115+
)
116+
117+
// Copy legacy icons.
110118
mipmapIconResourceGroups.forEach { groupResources ->
111119
copyResources(resourceFolder, groupResources)
112120
}
113121

114-
// Replace monochrome icons.
115-
monochromeIconFileNames.forEach { fileName ->
116-
copyResources(
117-
resourceFolder,
118-
ResourceGroup("drawable", fileName)
122+
// Copy adaptive icons.
123+
copyResources(
124+
resourceFolder,
125+
ResourceGroup("mipmap-anydpi", *adaptiveIconFileNames)
126+
)
127+
} else {
128+
val mipmapIconResourceGroups = mipmapDirectories.map { directory ->
129+
ResourceGroup(
130+
directory,
131+
*iconResourceFileNamesPng,
119132
)
120133
}
121134

122-
// Add SVG adaptive icon.
123-
adaptiveIconFileNames.forEach { fileName ->
124-
copyResources(
125-
resourceFolder,
126-
ResourceGroup("mipmap-anydpi", fileName)
127-
)
128-
}
129-
} else {
130135
val filePath = File(iconPathTrimmed)
131136
val resourceDirectory = get("res")
132137

133-
// Replace
138+
// Replace mipmap icons.
134139
mipmapIconResourceGroups.forEach { groupResources ->
135140
val groupResourceDirectoryName = groupResources.resourceDirectoryName
136141
val fromDirectory = filePath.resolve(groupResourceDirectoryName)

β€Ž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
@@ -35,6 +35,10 @@ val customBrandingPatch = baseCustomBrandingPatch(
3535
"adaptiveproduct_youtube_background_color_108.xml",
3636
"adaptiveproduct_youtube_foreground_color_108.xml",
3737
),
38+
legacyIconResourceFileNames = arrayOf(
39+
"ic_launcher",
40+
"ic_launcher_round",
41+
),
3842

3943
block = {
4044
compatibleWith(

0 commit comments

Comments
Β (0)