Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca3438b640 | ||
|
|
5121c3d45b | ||
|
|
666b241a53 |
@@ -1,3 +1,10 @@
|
||||
## [2.92.1](https://github.com/revanced/revanced-patches/compare/v2.92.0...v2.92.1) (2022-10-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/custom-branding:** use proper scaled icons ([24b5bcd](https://github.com/revanced/revanced-patches/commit/24b5bcdd703474c940fd436a37f0ae924d8b8c74))
|
||||
|
||||
# [2.92.0](https://github.com/revanced/revanced-patches/compare/v2.91.0...v2.92.0) (2022-10-26)
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 2.92.0
|
||||
version = 2.92.1
|
||||
|
||||
@@ -9,9 +9,9 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.layout.branding.icon.annotations.CustomBrandingCompatibility
|
||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||
import app.revanced.util.resources.ResourceUtils
|
||||
import app.revanced.util.resources.ResourceUtils.copyResources
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Files
|
||||
|
||||
@Patch
|
||||
@@ -22,36 +22,43 @@ import java.nio.file.Files
|
||||
@Version("0.0.1")
|
||||
class CustomBrandingPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
val resDirectory = context["res"]
|
||||
if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.")
|
||||
fun copyResources(resourceGroups: List<ResourceUtils.ResourceGroup>) {
|
||||
iconPath?.let { iconPathString ->
|
||||
val iconPath = File(iconPathString)
|
||||
val resourceDirectory = context["res"]
|
||||
|
||||
// Icon branding
|
||||
val iconNames = arrayOf(
|
||||
resourceGroups.forEach { group ->
|
||||
val fromDirectory = iconPath.resolve(group.resourceDirectoryName)
|
||||
val toDirectory = resourceDirectory.resolve(group.resourceDirectoryName)
|
||||
|
||||
group.resources.forEach { iconFileName ->
|
||||
Files.write(
|
||||
toDirectory.resolve(iconFileName).toPath(),
|
||||
fromDirectory.resolve(iconFileName).readBytes()
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: resourceGroups.forEach { context.copyResources("branding", it) }
|
||||
}
|
||||
|
||||
val iconResourceFileNames = arrayOf(
|
||||
"adaptiveproduct_youtube_background_color_108",
|
||||
"adaptiveproduct_youtube_foreground_color_108",
|
||||
"ic_launcher",
|
||||
"ic_launcher_round"
|
||||
).map { "$it.png" }.toTypedArray()
|
||||
|
||||
fun createGroup(directory: String) = ResourceUtils.ResourceGroup(
|
||||
directory, *iconResourceFileNames
|
||||
)
|
||||
|
||||
mapOf(
|
||||
"xxxhdpi" to 192,
|
||||
"xxhdpi" to 144,
|
||||
"xhdpi" to 96,
|
||||
"hdpi" to 72,
|
||||
"mdpi" to 48
|
||||
).forEach { (iconDirectory, size) ->
|
||||
iconNames.forEach { iconName ->
|
||||
val iconFile = getIconStream("branding/$size/$iconName.png")
|
||||
?: return PatchResultError("The icon $iconName can not be found.")
|
||||
// change the app icon
|
||||
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi")
|
||||
.map { "mipmap-$it" }
|
||||
.map(::createGroup)
|
||||
.let(::copyResources)
|
||||
|
||||
Files.write(
|
||||
resDirectory.resolve("mipmap-$iconDirectory").resolve("$iconName.png").toPath(),
|
||||
iconFile.readBytes()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Name branding
|
||||
// change the name of the app
|
||||
val manifest = context["AndroidManifest.xml"]
|
||||
manifest.writeText(
|
||||
manifest.readText()
|
||||
@@ -64,15 +71,6 @@ class CustomBrandingPatch : ResourcePatch {
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private fun getIconStream(iconPath: String): InputStream? {
|
||||
if (appIconPath == null) {
|
||||
return this.javaClass.classLoader.getResourceAsStream(iconPath)
|
||||
}
|
||||
val file = File(appIconPath!!).resolve(iconPath)
|
||||
if (!file.exists()) return null
|
||||
return FileInputStream(file)
|
||||
}
|
||||
|
||||
companion object : OptionsContainer() {
|
||||
private var appName: String? by option(
|
||||
PatchOption.StringOption(
|
||||
@@ -84,12 +82,12 @@ class CustomBrandingPatch : ResourcePatch {
|
||||
)
|
||||
)
|
||||
|
||||
private var appIconPath: String? by option(
|
||||
private var iconPath: String? by option(
|
||||
PatchOption.StringOption(
|
||||
key = "appIconPath",
|
||||
key = "iconPath",
|
||||
default = null,
|
||||
title = "Application Icon Path",
|
||||
description = "A path to the icon of the application."
|
||||
title = "App Icon Path",
|
||||
description = "A path containing mipmap resource folders with icons."
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 276 B |
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src/main/resources/branding/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/main/resources/branding/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 191 B |
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/main/resources/branding/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/main/resources/branding/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 343 B |
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/main/resources/branding/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
src/main/resources/branding/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 483 B |
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/main/resources/branding/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
src/main/resources/branding/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 163 B |
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src/main/resources/branding/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
src/main/resources/branding/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 11 KiB |