diff --git a/patches/api/patches.api b/patches/api/patches.api index 04e8b64e2b..3f725225af 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -288,6 +288,10 @@ public final class app/revanced/patches/music/interaction/permanentshuffle/Perma public static final fun getPermanentShufflePatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/music/layout/branding/CustomBrandingMusicPatchKt { + public static final fun getCustomBrandingPatch ()Lapp/revanced/patcher/patch/ResourcePatch; +} + public final class app/revanced/patches/music/layout/compactheader/HideCategoryBarKt { public static final fun getHideCategoryBar ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingMusicPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingMusicPatch.kt new file mode 100644 index 0000000000..71651b43f9 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingMusicPatch.kt @@ -0,0 +1,128 @@ +package app.revanced.patches.music.layout.branding + +import app.revanced.patcher.patch.resourcePatch +import app.revanced.patcher.patch.stringOption +import app.revanced.util.ResourceGroup +import app.revanced.util.Utils.trimIndentMultiline +import app.revanced.util.copyResources +import java.io.File +import java.nio.file.Files + +private const val REVANCED_ICON = "ReVanced*Logo" // Can never be a valid path. +private const val APP_NAME = "YT Music" + +private val iconResourceFileNames = arrayOf( + "adaptiveproduct_youtube_music_background_color_108", + "adaptiveproduct_youtube_music_foreground_color_108", + "ic_launcher", + "ic_launcher_round", +).map { "$it.png" }.toTypedArray() + +private val iconResourceFileNamesNew = mapOf( + "adaptiveproduct_youtube_music_foreground_color_108" to "adaptiveproduct_youtube_music_2024_q4_foreground_color_108", + "adaptiveproduct_youtube_music_background_color_108" to "adaptiveproduct_youtube_music_2024_q4_background_color_108", +) + +private val mipmapDirectories = arrayOf( + "xxxhdpi", + "xxhdpi", + "xhdpi", + "hdpi", + "mdpi", +).map { "mipmap-$it" } + +@Suppress("unused") +val customBrandingPatch = resourcePatch( + name = "Custom Music branding", + description = "Applies a custom app name and icon. Defaults to \"YT Music ReVanced\" and the ReVanced logo.", + use = true, +) { + compatibleWith("com.google.android.apps.youtube.music") + + val appName by stringOption( + key = "appName", + default = APP_NAME, + values = mapOf( + "YouTube Music ReVanced" to APP_NAME, + "YTM ReVanced" to "YTM ReVanced", + "YTM" to "YTM", + "YouTube Music" to "YouTube Music", + ), + title = "App name", + description = "The name of the app.", + ) + + val icon by stringOption( + key = "iconPath", + default = REVANCED_ICON, + values = mapOf("ReVanced Logo" to REVANCED_ICON), + title = "App icon", + description = """ + The icon to apply to the app. + + If a path to a folder is provided, the folder must contain the following folders: + + ${mipmapDirectories.joinToString("\n") { "- $it" }} + + Each of these folders must contain the following files: + + ${iconResourceFileNames.joinToString("\n") { "- $it" }} + """.trimIndentMultiline(), + ) + + execute { + icon?.let { icon -> + // Change the app icon. + mipmapDirectories.map { directory -> + ResourceGroup( + directory, + *iconResourceFileNames, + ) + }.let { resourceGroups -> + if (icon != REVANCED_ICON) { + val path = File(icon) + val resourceDirectory = get("res") + + resourceGroups.forEach { group -> + val fromDirectory = path.resolve(group.resourceDirectoryName) + val toDirectory = resourceDirectory.resolve(group.resourceDirectoryName) + + group.resources.forEach { iconFileName -> + Files.write( + toDirectory.resolve(iconFileName).toPath(), + fromDirectory.resolve(iconFileName).readBytes(), + ) + } + } + } else { + resourceGroups.forEach { copyResources("branding/music", it) } + } + } + + val resourceDirectory = get("res") + + mipmapDirectories.forEach { directory -> + val targetDirectory = resourceDirectory.resolve(directory) + + iconResourceFileNamesNew.forEach { (old, new) -> + val oldFile = targetDirectory.resolve("$old.png") + val newFile = targetDirectory.resolve("$new.png") + + Files.write(newFile.toPath(), oldFile.readBytes()) + } + } + } + + appName?.let { name -> + // Change the app name. + val manifest = get("AndroidManifest.xml") + manifest.writeText( + manifest.readText() + .replace( + "android:label=\"@string/application_name", + "android:label=\"$name", + ), + ) + } + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt index db37550c80..ff87c392c2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt @@ -11,7 +11,7 @@ import java.io.File import java.nio.file.Files private const val REVANCED_ICON = "ReVanced*Logo" // Can never be a valid path. -private const val APP_NAME = "YouTube ReVanced" +private const val APP_NAME = "YouTube" private val iconResourceFileNames = arrayOf( "adaptiveproduct_youtube_background_color_108", @@ -37,7 +37,7 @@ private val mipmapDirectories = arrayOf( val customBrandingPatch = resourcePatch( name = "Custom branding", description = "Applies a custom app name and icon. Defaults to \"YouTube ReVanced\" and the ReVanced logo.", - use = false, + use = true, ) { dependsOn(versionCheckPatch) @@ -99,7 +99,7 @@ val customBrandingPatch = resourcePatch( } } } else { - resourceGroups.forEach { copyResources("custom-branding", it) } + resourceGroups.forEach { copyResources("branding/youtube", it) } } } diff --git a/patches/src/main/resources/branding/music/mipmap-hdpi/adaptiveproduct_youtube_music_background_color_108.png b/patches/src/main/resources/branding/music/mipmap-hdpi/adaptiveproduct_youtube_music_background_color_108.png new file mode 100644 index 0000000000..53043c7871 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-hdpi/adaptiveproduct_youtube_music_background_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-hdpi/adaptiveproduct_youtube_music_foreground_color_108.png b/patches/src/main/resources/branding/music/mipmap-hdpi/adaptiveproduct_youtube_music_foreground_color_108.png new file mode 100644 index 0000000000..692e1a4b9b Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-hdpi/adaptiveproduct_youtube_music_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-hdpi/ic_launcher.png b/patches/src/main/resources/branding/music/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..cf4f563474 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-hdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-hdpi/ic_launcher_round.png b/patches/src/main/resources/branding/music/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000..6471e7f8db Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-hdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-mdpi/adaptiveproduct_youtube_music_background_color_108.png b/patches/src/main/resources/branding/music/mipmap-mdpi/adaptiveproduct_youtube_music_background_color_108.png new file mode 100644 index 0000000000..0e64b7036a Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-mdpi/adaptiveproduct_youtube_music_background_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-mdpi/adaptiveproduct_youtube_music_foreground_color_108.png b/patches/src/main/resources/branding/music/mipmap-mdpi/adaptiveproduct_youtube_music_foreground_color_108.png new file mode 100644 index 0000000000..1bf53c5708 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-mdpi/adaptiveproduct_youtube_music_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-mdpi/ic_launcher.png b/patches/src/main/resources/branding/music/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..0f06a77a24 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-mdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-mdpi/ic_launcher_round.png b/patches/src/main/resources/branding/music/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000..24be686432 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-mdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xhdpi/adaptiveproduct_youtube_music_background_color_108.png b/patches/src/main/resources/branding/music/mipmap-xhdpi/adaptiveproduct_youtube_music_background_color_108.png new file mode 100644 index 0000000000..4369f55e64 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xhdpi/adaptiveproduct_youtube_music_background_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xhdpi/adaptiveproduct_youtube_music_foreground_color_108.png b/patches/src/main/resources/branding/music/mipmap-xhdpi/adaptiveproduct_youtube_music_foreground_color_108.png new file mode 100644 index 0000000000..468bb77115 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xhdpi/adaptiveproduct_youtube_music_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xhdpi/ic_launcher.png b/patches/src/main/resources/branding/music/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..773aff3172 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xhdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xhdpi/ic_launcher_round.png b/patches/src/main/resources/branding/music/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..0f14b5da1e Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxhdpi/adaptiveproduct_youtube_music_background_color_108.png b/patches/src/main/resources/branding/music/mipmap-xxhdpi/adaptiveproduct_youtube_music_background_color_108.png new file mode 100644 index 0000000000..c8fce4e56e Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxhdpi/adaptiveproduct_youtube_music_background_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxhdpi/adaptiveproduct_youtube_music_foreground_color_108.png b/patches/src/main/resources/branding/music/mipmap-xxhdpi/adaptiveproduct_youtube_music_foreground_color_108.png new file mode 100644 index 0000000000..1ba76096dc Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxhdpi/adaptiveproduct_youtube_music_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxhdpi/ic_launcher.png b/patches/src/main/resources/branding/music/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..ddd660f295 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxhdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxhdpi/ic_launcher_round.png b/patches/src/main/resources/branding/music/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..ddd660f295 Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxxhdpi/adaptiveproduct_youtube_music_background_color_108.png b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/adaptiveproduct_youtube_music_background_color_108.png new file mode 100644 index 0000000000..ebfe90059b Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/adaptiveproduct_youtube_music_background_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxxhdpi/adaptiveproduct_youtube_music_foreground_color_108.png b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/adaptiveproduct_youtube_music_foreground_color_108.png new file mode 100644 index 0000000000..079992ad6c Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/adaptiveproduct_youtube_music_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxxhdpi/ic_launcher.png b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..2fa295313c Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/music/mipmap-xxxhdpi/ic_launcher_round.png b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..2fa295313c Binary files /dev/null and b/patches/src/main/resources/branding/music/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-hdpi/adaptiveproduct_youtube_background_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-hdpi/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 0000000000..53043c7871 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-hdpi/adaptiveproduct_youtube_background_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-hdpi/adaptiveproduct_youtube_foreground_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-hdpi/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 0000000000..928cde3567 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-hdpi/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-hdpi/ic_launcher.png b/patches/src/main/resources/branding/youtube/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..236f0174a0 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-hdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-hdpi/ic_launcher_round.png b/patches/src/main/resources/branding/youtube/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000..7f03ad1890 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-hdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-mdpi/adaptiveproduct_youtube_background_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-mdpi/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 0000000000..0e64b7036a Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-mdpi/adaptiveproduct_youtube_background_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-mdpi/adaptiveproduct_youtube_foreground_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-mdpi/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 0000000000..fb91274d0e Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-mdpi/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-mdpi/ic_launcher.png b/patches/src/main/resources/branding/youtube/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..6c18103ce9 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-mdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-mdpi/ic_launcher_round.png b/patches/src/main/resources/branding/youtube/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000..09e398eea4 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-mdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xhdpi/adaptiveproduct_youtube_background_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 0000000000..4369f55e64 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/adaptiveproduct_youtube_background_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xhdpi/adaptiveproduct_youtube_foreground_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 0000000000..596108cfdc Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xhdpi/ic_launcher.png b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..4d44c41763 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xhdpi/ic_launcher_round.png b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..1434c23f47 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/adaptiveproduct_youtube_background_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 0000000000..c8fce4e56e Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/adaptiveproduct_youtube_background_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/adaptiveproduct_youtube_foreground_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 0000000000..84cb768679 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/ic_launcher.png b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..9bc55a4424 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/ic_launcher_round.png b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..b3840991ef Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/adaptiveproduct_youtube_background_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 0000000000..ebfe90059b Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/adaptiveproduct_youtube_background_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/adaptiveproduct_youtube_foreground_color_108.png b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 0000000000..060319c6de Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/ic_launcher.png b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..72196f51a5 Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/ic_launcher_round.png b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..83ec576fcd Binary files /dev/null and b/patches/src/main/resources/branding/youtube/mipmap-xxxhdpi/ic_launcher_round.png differ