From c282c3a82ffe7d6922f3e9e6f98604e508173912 Mon Sep 17 00:00:00 2001 From: bennett-sh <110846042+bennett-sh@users.noreply.github.com> Date: Wed, 28 Sep 2022 13:14:39 +0200 Subject: [PATCH] feat: `monochrome-icon` patch (#643) --- .../MonochromeIconCompatibility.kt | 9 ++++ .../monochrome/patch/MonochromeIconPatch.kt | 53 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/annotations/MonochromeIconCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/annotations/MonochromeIconCompatibility.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/annotations/MonochromeIconCompatibility.kt new file mode 100644 index 000000000..646ad2b0b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/annotations/MonochromeIconCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.twitter.misc.monochrome.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.twitter.android")]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class MonochromeIconCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt new file mode 100644 index 000000000..ec65952e2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt @@ -0,0 +1,53 @@ +package app.revanced.patches.twitter.misc.monochrome.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.impl.DomFileEditor +import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patches.twitter.misc.monochrome.annotations.MonochromeIconCompatibility +import java.nio.file.Files + +@Patch +@Name("monochrome-icon") +@Description("Adds a monochrome icon.") +@MonochromeIconCompatibility +@Version("0.0.1") +class MonochromeIconPatch : ResourcePatch() { + override fun execute(data: ResourceData): PatchResult { + val resDirectory = data["res"] + if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") + + val mipmapV33Directory = resDirectory.resolve("mipmap-anydpi-v33") + if (!mipmapV33Directory.isDirectory) Files.createDirectories(mipmapV33Directory.toPath()) + + Files.writeString( + mipmapV33Directory.resolve("ic_launcher_twitter.xml").toPath(), + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "" + ) + + Files.writeString( + mipmapV33Directory.resolve("ic_launcher_twitter_round.xml").toPath(), + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "" + ) + + return PatchResultSuccess() + } +} \ No newline at end of file