feat: custom-branding
patch
@ -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
|
@ -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()
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 5.0 KiB |
BIN
src/main/resources/icon/144/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
src/main/resources/icon/144/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 6.1 KiB |
BIN
src/main/resources/icon/192/ic_launcher.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/main/resources/icon/192/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 2.1 KiB |
BIN
src/main/resources/icon/72/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
src/main/resources/icon/72/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 343 B |
After Width: | Height: | Size: 2.9 KiB |
BIN
src/main/resources/icon/96/ic_launcher.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
src/main/resources/icon/96/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 4.6 KiB |