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 000000000..d46b6f1fd --- /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 000000000..d7938e56d --- /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 000000000..2f41a49a9 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 000000000..ff1f4be71 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 000000000..95e4117b4 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 000000000..7ca78b0b8 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 000000000..8b5fb108e 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 000000000..18c7e9da3 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 000000000..19863bec7 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 000000000..a8a728fdd 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 000000000..7a04bd17f 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 000000000..c1b3d6269 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 000000000..bdede993b 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 000000000..cf3a87472 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 000000000..66207dea7 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 000000000..36a2aa5ee 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 000000000..5be1dcc21 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 000000000..7384a7026 Binary files /dev/null and b/src/main/resources/icon/96/ic_launcher_round.png differ