diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/icon/annotations/CustomBrandingCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/icon/annotations/CustomBrandingCompatibility.kt new file mode 100644 index 00000000..d46b6f1f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/icon/annotations/CustomBrandingCompatibility.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.layout.icon.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [Package( + "com.google.android.youtube", arrayOf() + )] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class CustomBrandingCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/icon/patch/CustomBrandingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/icon/patch/CustomBrandingPatch.kt new file mode 100644 index 00000000..d7938e56 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/icon/patch/CustomBrandingPatch.kt @@ -0,0 +1,56 @@ +package app.revanced.patches.youtube.layout.icon.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.implementation.ResourceData +import app.revanced.patcher.patch.annotations.Dependencies +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.implementation.ResourcePatch +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultError +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patches.youtube.layout.icon.annotations.CustomBrandingCompatibility +import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch +import java.nio.file.Files + +@Patch +@Dependencies( + dependencies = [FixLocaleConfigErrorPatch::class] +) +@Name("custom-branding") +@Description("Change the branding of YouTube.") +@CustomBrandingCompatibility +@Version("0.0.1") +class CustomBrandingPatch : ResourcePatch() { + override fun execute(data: ResourceData): PatchResult { + val resDirectory = data.get("res") + if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") + + val iconNames = arrayOf( + "adaptiveproduct_youtube_background_color_108", + "adaptiveproduct_youtube_foreground_color_108", + "ic_launcher", + "ic_launcher_round" + ) + + mapOf( + "mipmap-xxxhdpi" to 192, + "mipmap-xxhdpi" to 144, + "mipmap-xhdpi" to 96, + "mipmap-hdpi" to 72, + "mipmap-mdpi" to 48 + ).forEach { (iconDirectory, size) -> + iconNames.forEach iconLoop@{ iconName -> + val iconFile = this.javaClass.classLoader.getResourceAsStream("$size/$iconName.png") + ?: return PatchResultError("The icon $iconName can not be found.") + + Files.write( + resDirectory.resolve(iconDirectory).resolve("$iconName.png").toPath(), iconFile.readAllBytes() + ) + } + } + + return PatchResultSuccess() + } +} diff --git a/src/main/resources/icon/144/adaptiveproduct_youtube_background_color_108.png b/src/main/resources/icon/144/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 00000000..2f41a49a Binary files /dev/null and b/src/main/resources/icon/144/adaptiveproduct_youtube_background_color_108.png differ diff --git a/src/main/resources/icon/144/adaptiveproduct_youtube_foreground_color_108.png b/src/main/resources/icon/144/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 00000000..ff1f4be7 Binary files /dev/null and b/src/main/resources/icon/144/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/src/main/resources/icon/144/ic_launcher.png b/src/main/resources/icon/144/ic_launcher.png new file mode 100644 index 00000000..95e4117b Binary files /dev/null and b/src/main/resources/icon/144/ic_launcher.png differ diff --git a/src/main/resources/icon/144/ic_launcher_round.png b/src/main/resources/icon/144/ic_launcher_round.png new file mode 100644 index 00000000..7ca78b0b Binary files /dev/null and b/src/main/resources/icon/144/ic_launcher_round.png differ diff --git a/src/main/resources/icon/192/adaptiveproduct_youtube_background_color_108.png b/src/main/resources/icon/192/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 00000000..8b5fb108 Binary files /dev/null and b/src/main/resources/icon/192/adaptiveproduct_youtube_background_color_108.png differ diff --git a/src/main/resources/icon/192/adaptiveproduct_youtube_foreground_color_108.png b/src/main/resources/icon/192/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 00000000..18c7e9da Binary files /dev/null and b/src/main/resources/icon/192/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/src/main/resources/icon/192/ic_launcher.png b/src/main/resources/icon/192/ic_launcher.png new file mode 100644 index 00000000..19863bec Binary files /dev/null and b/src/main/resources/icon/192/ic_launcher.png differ diff --git a/src/main/resources/icon/192/ic_launcher_round.png b/src/main/resources/icon/192/ic_launcher_round.png new file mode 100644 index 00000000..a8a728fd Binary files /dev/null and b/src/main/resources/icon/192/ic_launcher_round.png differ diff --git a/src/main/resources/icon/72/adaptiveproduct_youtube_background_color_108.png b/src/main/resources/icon/72/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 00000000..7a04bd17 Binary files /dev/null and b/src/main/resources/icon/72/adaptiveproduct_youtube_background_color_108.png differ diff --git a/src/main/resources/icon/72/adaptiveproduct_youtube_foreground_color_108.png b/src/main/resources/icon/72/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 00000000..c1b3d626 Binary files /dev/null and b/src/main/resources/icon/72/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/src/main/resources/icon/72/ic_launcher.png b/src/main/resources/icon/72/ic_launcher.png new file mode 100644 index 00000000..bdede993 Binary files /dev/null and b/src/main/resources/icon/72/ic_launcher.png differ diff --git a/src/main/resources/icon/72/ic_launcher_round.png b/src/main/resources/icon/72/ic_launcher_round.png new file mode 100644 index 00000000..cf3a8747 Binary files /dev/null and b/src/main/resources/icon/72/ic_launcher_round.png differ diff --git a/src/main/resources/icon/96/adaptiveproduct_youtube_background_color_108.png b/src/main/resources/icon/96/adaptiveproduct_youtube_background_color_108.png new file mode 100644 index 00000000..66207dea Binary files /dev/null and b/src/main/resources/icon/96/adaptiveproduct_youtube_background_color_108.png differ diff --git a/src/main/resources/icon/96/adaptiveproduct_youtube_foreground_color_108.png b/src/main/resources/icon/96/adaptiveproduct_youtube_foreground_color_108.png new file mode 100644 index 00000000..36a2aa5e Binary files /dev/null and b/src/main/resources/icon/96/adaptiveproduct_youtube_foreground_color_108.png differ diff --git a/src/main/resources/icon/96/ic_launcher.png b/src/main/resources/icon/96/ic_launcher.png new file mode 100644 index 00000000..5be1dcc2 Binary files /dev/null and b/src/main/resources/icon/96/ic_launcher.png differ diff --git a/src/main/resources/icon/96/ic_launcher_round.png b/src/main/resources/icon/96/ic_launcher_round.png new file mode 100644 index 00000000..7384a702 Binary files /dev/null and b/src/main/resources/icon/96/ic_launcher_round.png differ