generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
239cd34
commit c282c3a
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...n/app/revanced/patches/twitter/misc/monochrome/annotations/MonochromeIconCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
53 changes: 53 additions & 0 deletions
53
src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(), | ||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + | ||
"<adaptive-icon\n" + | ||
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + | ||
" <background android:drawable=\"@color/ic_launcher_background\" />\n" + | ||
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" + | ||
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" + | ||
"</adaptive-icon>" | ||
) | ||
|
||
Files.writeString( | ||
mipmapV33Directory.resolve("ic_launcher_twitter_round.xml").toPath(), | ||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + | ||
"<adaptive-icon\n" + | ||
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + | ||
" <background android:drawable=\"@color/ic_launcher_background\" />\n" + | ||
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" + | ||
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" + | ||
"</adaptive-icon>" | ||
) | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |