mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-24 19:05:50 +01:00
fix(twitter patches.): use wider compatible Java API for writing to file (#678)
Allows running the patch on Android
This commit is contained in:
parent
fdff5efdbc
commit
4448de80a6
@ -10,6 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.annotations.Patch
|
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.twitter.misc.dynamiccolor.annotations.DynamicColorCompatibility
|
import app.revanced.patches.twitter.misc.dynamiccolor.annotations.DynamicColorCompatibility
|
||||||
|
import java.io.FileWriter
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@ -28,16 +29,19 @@ class DynamicColorPatch : ResourcePatch() {
|
|||||||
val valuesNightV31Directory = resDirectory.resolve("values-night-v31")
|
val valuesNightV31Directory = resDirectory.resolve("values-night-v31")
|
||||||
if (!valuesNightV31Directory.isDirectory) Files.createDirectories(valuesNightV31Directory.toPath())
|
if (!valuesNightV31Directory.isDirectory) Files.createDirectories(valuesNightV31Directory.toPath())
|
||||||
|
|
||||||
listOf(valuesV31Directory, valuesNightV31Directory).forEach {
|
listOf(valuesV31Directory, valuesNightV31Directory).forEach { it ->
|
||||||
val colorsXml = it.resolve("colors.xml")
|
val colorsXml = it.resolve("colors.xml")
|
||||||
|
|
||||||
if(!colorsXml.exists()) {
|
if(!colorsXml.exists()) {
|
||||||
Files.writeString(
|
FileWriter(
|
||||||
colorsXml.toPath(),
|
colorsXml,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
).use {
|
||||||
"<resources>\n" +
|
it.write(
|
||||||
"</resources>"
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||||
)
|
"<resources>\n" +
|
||||||
|
"</resources>".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package app.revanced.patches.twitter.misc.monochrome.patch
|
|||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.impl.DomFileEditor
|
|
||||||
import app.revanced.patcher.data.impl.ResourceData
|
import app.revanced.patcher.data.impl.ResourceData
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
@ -11,6 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.annotations.Patch
|
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.twitter.misc.monochrome.annotations.MonochromeIconCompatibility
|
import app.revanced.patches.twitter.misc.monochrome.annotations.MonochromeIconCompatibility
|
||||||
|
import java.io.FileWriter
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@ -26,27 +26,29 @@ class MonochromeIconPatch : ResourcePatch() {
|
|||||||
val mipmapV33Directory = resDirectory.resolve("mipmap-anydpi-v33")
|
val mipmapV33Directory = resDirectory.resolve("mipmap-anydpi-v33")
|
||||||
if (!mipmapV33Directory.isDirectory) Files.createDirectories(mipmapV33Directory.toPath())
|
if (!mipmapV33Directory.isDirectory) Files.createDirectories(mipmapV33Directory.toPath())
|
||||||
|
|
||||||
Files.writeString(
|
FileWriter(
|
||||||
mipmapV33Directory.resolve("ic_launcher_twitter.xml").toPath(),
|
mipmapV33Directory.resolve("ic_launcher_twitter.xml"),
|
||||||
|
).use {
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||||
"<adaptive-icon\n" +
|
"<adaptive-icon\n" +
|
||||||
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
|
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
|
||||||
" <background android:drawable=\"@color/ic_launcher_background\" />\n" +
|
" <background android:drawable=\"@color/ic_launcher_background\" />\n" +
|
||||||
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
||||||
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
||||||
"</adaptive-icon>"
|
"</adaptive-icon>"
|
||||||
)
|
}
|
||||||
|
|
||||||
Files.writeString(
|
FileWriter(
|
||||||
mipmapV33Directory.resolve("ic_launcher_twitter_round.xml").toPath(),
|
mipmapV33Directory.resolve("ic_launcher_twitter_round.xml"),
|
||||||
|
).use {
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||||
"<adaptive-icon\n" +
|
"<adaptive-icon\n" +
|
||||||
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
|
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
|
||||||
" <background android:drawable=\"@color/ic_launcher_background\" />\n" +
|
" <background android:drawable=\"@color/ic_launcher_background\" />\n" +
|
||||||
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
||||||
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
|
||||||
"</adaptive-icon>"
|
"</adaptive-icon>"
|
||||||
)
|
}
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user