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)
|
# [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
|
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.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.youtube.layout.branding.icon.annotations.CustomBrandingCompatibility
|
import app.revanced.patches.youtube.layout.branding.icon.annotations.CustomBrandingCompatibility
|
||||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
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.File
|
||||||
import java.io.FileInputStream
|
|
||||||
import java.io.InputStream
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@@ -22,36 +22,43 @@ import java.nio.file.Files
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class CustomBrandingPatch : ResourcePatch {
|
class CustomBrandingPatch : ResourcePatch {
|
||||||
override fun execute(context: ResourceContext): PatchResult {
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
val resDirectory = context["res"]
|
fun copyResources(resourceGroups: List<ResourceUtils.ResourceGroup>) {
|
||||||
if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.")
|
iconPath?.let { iconPathString ->
|
||||||
|
val iconPath = File(iconPathString)
|
||||||
|
val resourceDirectory = context["res"]
|
||||||
|
|
||||||
// Icon branding
|
resourceGroups.forEach { group ->
|
||||||
val iconNames = arrayOf(
|
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_background_color_108",
|
||||||
"adaptiveproduct_youtube_foreground_color_108",
|
"adaptiveproduct_youtube_foreground_color_108",
|
||||||
"ic_launcher",
|
"ic_launcher",
|
||||||
"ic_launcher_round"
|
"ic_launcher_round"
|
||||||
|
).map { "$it.png" }.toTypedArray()
|
||||||
|
|
||||||
|
fun createGroup(directory: String) = ResourceUtils.ResourceGroup(
|
||||||
|
directory, *iconResourceFileNames
|
||||||
)
|
)
|
||||||
|
|
||||||
mapOf(
|
// change the app icon
|
||||||
"xxxhdpi" to 192,
|
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi")
|
||||||
"xxhdpi" to 144,
|
.map { "mipmap-$it" }
|
||||||
"xhdpi" to 96,
|
.map(::createGroup)
|
||||||
"hdpi" to 72,
|
.let(::copyResources)
|
||||||
"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.")
|
|
||||||
|
|
||||||
Files.write(
|
// change the name of the app
|
||||||
resDirectory.resolve("mipmap-$iconDirectory").resolve("$iconName.png").toPath(),
|
|
||||||
iconFile.readBytes()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name branding
|
|
||||||
val manifest = context["AndroidManifest.xml"]
|
val manifest = context["AndroidManifest.xml"]
|
||||||
manifest.writeText(
|
manifest.writeText(
|
||||||
manifest.readText()
|
manifest.readText()
|
||||||
@@ -64,15 +71,6 @@ class CustomBrandingPatch : ResourcePatch {
|
|||||||
return PatchResultSuccess()
|
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() {
|
companion object : OptionsContainer() {
|
||||||
private var appName: String? by option(
|
private var appName: String? by option(
|
||||||
PatchOption.StringOption(
|
PatchOption.StringOption(
|
||||||
@@ -84,12 +82,12 @@ class CustomBrandingPatch : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
private var appIconPath: String? by option(
|
private var iconPath: String? by option(
|
||||||
PatchOption.StringOption(
|
PatchOption.StringOption(
|
||||||
key = "appIconPath",
|
key = "iconPath",
|
||||||
default = null,
|
default = null,
|
||||||
title = "Application Icon Path",
|
title = "App Icon Path",
|
||||||
description = "A path to the icon of the application."
|
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 |