refactor: cleanup CustomBrandingPatch
This commit is contained in:
parent
d3f86689a6
commit
6d5761bbad
|
@ -10,7 +10,6 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.impl.ResourcePatch
|
import app.revanced.patcher.patch.impl.ResourcePatch
|
||||||
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 java.io.ByteArrayOutputStream
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
@ -42,20 +41,13 @@ class CustomBrandingPatch : ResourcePatch() {
|
||||||
"hdpi" to 72,
|
"hdpi" to 72,
|
||||||
"mdpi" to 48
|
"mdpi" to 48
|
||||||
).forEach { (iconDirectory, size) ->
|
).forEach { (iconDirectory, size) ->
|
||||||
iconNames.forEach iconLoop@{ iconName ->
|
iconNames.forEach { iconName ->
|
||||||
val iconFile = getIconStream("branding/$size/$iconName.png")
|
val iconFile = getIconStream("branding/$size/$iconName.png")
|
||||||
?: return PatchResultError("The icon $iconName can not be found.")
|
?: return PatchResultError("The icon $iconName can not be found.")
|
||||||
|
|
||||||
val outputStream = ByteArrayOutputStream()
|
|
||||||
iconFile.use { input ->
|
|
||||||
outputStream.use { output ->
|
|
||||||
input.copyTo(output)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Files.write(
|
Files.write(
|
||||||
resDirectory.resolve("mipmap-$iconDirectory").resolve("$iconName.png").toPath(),
|
resDirectory.resolve("mipmap-$iconDirectory").resolve("$iconName.png").toPath(),
|
||||||
outputStream.toByteArray()
|
iconFile.readBytes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue