build: Bump dependencies

This commit also migrates away from deprecated to new APIs
This commit is contained in:
oSumAtrIX
2024-02-21 04:07:32 +01:00
parent ff8b58b645
commit 376dda6e81
38 changed files with 464 additions and 456 deletions
@@ -11,12 +11,12 @@ import java.nio.file.Files
@Patch(
name = "Dynamic color",
description = "Replaces the default X (Formerly Twitter) Blue with the user's Material You palette.",
compatiblePackages = [CompatiblePackage("com.twitter.android")]
compatiblePackages = [CompatiblePackage("com.twitter.android")],
)
@Suppress("unused")
object DynamicColorPatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
val resDirectory = context["res"]
val resDirectory = context.get("res", false)
if (!resDirectory.isDirectory) throw PatchException("The res folder can not be found.")
val valuesV31Directory = resDirectory.resolve("values-v31")
@@ -28,16 +28,14 @@ object DynamicColorPatch : ResourcePatch() {
listOf(valuesV31Directory, valuesNightV31Directory).forEach { it ->
val colorsXml = it.resolve("colors.xml")
if(!colorsXml.exists()) {
if (!colorsXml.exists()) {
FileWriter(colorsXml).use {
it.write("<?xml version=\"1.0\" encoding=\"utf-8\"?><resources></resources>")
}
}
}
context.xmlEditor["res/values-v31/colors.xml"].use { editor ->
val document = editor.file
context.document["res/values-v31/colors.xml"].use { document ->
mapOf(
"ps__twitter_blue" to "@color/twitter_blue",
"ps__twitter_blue_pressed" to "@color/twitter_blue_fill_pressed",
@@ -46,7 +44,7 @@ object DynamicColorPatch : ResourcePatch() {
"twitter_blue_opacity_30" to "@android:color/system_accent1_100",
"twitter_blue_opacity_50" to "@android:color/system_accent1_200",
"twitter_blue_opacity_58" to "@android:color/system_accent1_300",
"deep_transparent_twitter_blue" to "@android:color/system_accent1_200"
"deep_transparent_twitter_blue" to "@android:color/system_accent1_200",
).forEach { (k, v) ->
val colorElement = document.createElement("color")
@@ -57,16 +55,14 @@ object DynamicColorPatch : ResourcePatch() {
}
}
context.xmlEditor["res/values-night-v31/colors.xml"].use { editor ->
val document = editor.file
context.document["res/values-night-v31/colors.xml"].use { document ->
mapOf(
"twitter_blue" to "@android:color/system_accent1_200",
"twitter_blue_fill_pressed" to "@android:color/system_accent1_300",
"twitter_blue_opacity_30" to "@android:color/system_accent1_50",
"twitter_blue_opacity_50" to "@android:color/system_accent1_100",
"twitter_blue_opacity_58" to "@android:color/system_accent1_200",
"deep_transparent_twitter_blue" to "@android:color/system_accent1_200"
"deep_transparent_twitter_blue" to "@android:color/system_accent1_200",
).forEach { (k, v) ->
val colorElement = document.createElement("color")
@@ -4,7 +4,7 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.twitter.misc.hook.json.JsonHookPatch
abstract class BaseHookPatch(private val hookClassDescriptor: String) : BytecodePatch() {
abstract class BaseHookPatch(private val hookClassDescriptor: String) : BytecodePatch(emptySet()) {
override fun execute(context: BytecodeContext) =
JsonHookPatch.hooks.addHook(JsonHookPatch.Hook(context, hookClassDescriptor))
}
}