Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
fix(twitter): fix monochrome
Browse files Browse the repository at this point in the history
  • Loading branch information
IndusAryan committed Mar 22, 2024
1 parent c98af52 commit 4d6622a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
25 changes: 11 additions & 14 deletions src/main/kotlin/indus/org/patches/twitter/XMLUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class XMLUtils(context: ResourceContext) {
private val icLauncherTwitterXml26 = mipmapDirectory26.resolve("ic_launcher_twitter.xml")
private val icLauncherTwitterRoundXml26 = mipmapDirectory26.resolve("ic_launcher_twitter_round.xml")

private fun avatarFile() {
private fun createIconFiles() {
if (!avatarMarkerTwitterFile.isFile) Files.createFile(avatarMarkerTwitterFile.toPath())
if (!monochromeFile.isFile) Files.createFile(monochromeFile.toPath())
}

fun whiteIconBlackBG() {
Expand Down Expand Up @@ -54,7 +55,7 @@ class XMLUtils(context: ResourceContext) {
</vector>
""".trimIndent()

avatarFile()
createIconFiles()
addMonochromeIcon()
avatarMarkerTwitterFile.writeText(whiteBird)
}
Expand Down Expand Up @@ -90,7 +91,7 @@ class XMLUtils(context: ResourceContext) {
</vector>
""".trimIndent()

avatarFile()
createIconFiles()
addMonochromeIcon()
avatarMarkerTwitterFile.writeText(newAvatarMarkerTwitterContent)
}
Expand Down Expand Up @@ -126,7 +127,7 @@ class XMLUtils(context: ResourceContext) {
</vector>
""".trimIndent()

avatarFile()
createIconFiles()
addMonochromeIcon()
avatarMarkerTwitterFile.writeText(blackIcon)
}
Expand Down Expand Up @@ -163,10 +164,6 @@ class XMLUtils(context: ResourceContext) {
}

private fun addMonochromeIcon() {
if (!monochromeFile.isFile) {
Files.createFile(monochromeFile.toPath())
}

val adaptiveIcon = """
<?xml version='1.0' encoding='utf-8' ?>
<vector android:height="24.0dp"
Expand All @@ -185,12 +182,12 @@ class XMLUtils(context: ResourceContext) {
if (!Files.isRegularFile(xmlFile.toPath())) throw PatchException("$xmlFile not found.")

val content = xmlFile.readText()
val modifiedContent = content.replace(
"""android:drawable="@mipmap/ic_launcher_twitter_foreground"""",
"""android:drawable="@drawable/avatar_marker_twitter""""
).replace(
"""android:drawable="@mipmap/ic_launcher_twitter_foreground"""",
"""android:drawable="@drawable/ic_vector_twitter_circle_fill""""
val modifiedContent = content.replaceFirst(
"""<foreground\s+android:drawable="[^"]+"""",
"""<foreground android:drawable="@drawable/avatar_marker_twitter""""
).replaceFirst(
"""<monochrome\s+android:drawable="[^"]+"""",
"""<monochrome android:drawable="@drawable/ic_vector_twitter_circle_fill""""
)

xmlFile.writeText(modifiedContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import indus.org.patches.twitter.crimeraswak.misc.settings.fingerprints.Settings
name = "Remove \"Who to follow\" Banner",
dependencies = [SettingsPatch::class, TimelineEntryHookPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = true
use = false
)
object HideWTF :BytecodePatch(
setOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import indus.org.patches.twitter.hook.patch.BaseHookPatch

@Patch(
name = "Hide ads",
description = "DON'T USE WITH CRIMERA INTEGRATIONS (NOT NEEDED ANYWAYS).",
description = "DON'T USE WHEN PATCHING ALONG WITH CRIMERA PATCHES AND INTEGRATIONS (NOT NEEDED ANYWAYS THEN).",
dependencies = [JsonHookPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import indus.org.patches.twitter.hook.patch.BaseHookPatch

@Patch(
name = "Hide promoted users",
description = "DON'T USE WITH CRIMERA INTEGRATIONS (NOT NEEDED ANYWAYS).",
description = "DON'T USE WHEN PATCHING ALONG WITH CRIMERA PATCHES AND INTEGRATIONS (NOT NEEDED ANYWAYS THEN).",
dependencies = [JsonHookPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = false
Expand Down

0 comments on commit 4d6622a

Please sign in to comment.