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

Commit

Permalink
feat(twitter): good morning!
Browse files Browse the repository at this point in the history
  • Loading branch information
IndusAryan committed Feb 4, 2024
1 parent 03bf8b6 commit 469e6f0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
31 changes: 12 additions & 19 deletions src/main/kotlin/indus/org/patches/twitter/SplashScreenHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,20 @@ class SplashScreenHelper {

fun changeSplashScreen(context: ResourceContext) {

context.xmlEditor["res/values/styles.xml"].use { editor ->
val document = editor.file
val styles = document.getElementsByTagName("style")
for (i in 0 until styles.length) {
val styleNode = styles.item(i)
if (styleNode.attributes.getNamedItem("name")?.nodeValue == "Theme.LaunchScreen") {
val newSplashVector = """
<?xml version='1.0' encoding='utf-8' ?>
<vector android:height="192.0dp"
android:width="192.0dp"
android:viewportWidth="288.0"
android:viewportHeight="288.0" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffffff"
android:pathData="M205.66,112.13c-4.254,1.885 -8.823,3.158 -13.627,3.734 4.9,-2.934 8.66,-7.59 10.432,-13.132 -4.584,2.72 -9.663,4.696 -15.067,5.756 -4.33,-4.605 -10.493,-7.488 -17.32,-7.488 -13.1,0 -23.726,10.626 -23.726,23.737 0,1.854 0.214,3.657 0.61,5.4 -19.727,-0.994 -37.204,-10.443 -48.91,-24.797 -2.036,3.515 -3.208,7.59 -3.208,11.93 0,8.23 4.192,15.5 10.554,19.754 -3.892,-0.127 -7.55,-1.192 -10.748,-2.97v0.306c0,11.497 8.175,21.088 19.035,23.268 -1.997,0.54 -4.09,0.825 -6.25,0.825 -1.528,0 -3.02,-0.143 -4.467,-0.418 3.02,9.423 11.782,16.29 22.168,16.473 -8.125,6.367 -18.358,10.162 -29.472,10.162 -1.915,0 -3.805,-0.112 -5.664,-0.33 10.503,6.738 22.973,10.66 36.37,10.66 43.652,0 67.517,-36.155 67.517,-67.513 0,-1.02 -0.025,-2.048 -0.07,-3.066 4.634,-3.35 8.658,-7.522 11.832,-12.275l0.01,-0.015z" />
</vector>
""".trimIndent()

val styleItems = setOf(
"windowSplashScreenAnimatedIcon" to "@drawable/ic_vector_twitter_white",
)

styleItems.forEach { (k, v) ->
val styleElement = document.createElement("item")
styleElement.setAttribute("name", k)
styleElement.textContent = v
styleNode.appendChild(styleElement)
}
val splashFile = context["res/drawable/splash_screen_icon.xml"]
splashFile.writeText(newSplashVector)

break
}
}
}
}
}
11 changes: 4 additions & 7 deletions src/main/kotlin/indus/org/patches/twitter/XMLUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object XMLUtils {
"""

private val ogBirdVectorWhite = """
<?xml version='1.0' encoding='utf-8' ?>
<?xml version='1.0' encoding='utf-8' ?>
<vector android:height="24.0dp"
android:width="24.0dp"
android:viewportWidth="24.0"
Expand All @@ -76,7 +76,7 @@ object XMLUtils {
""".trimIndent()

private val ogBirdVector = """
<?xml version='1.0' encoding='utf-8' ?>
<?xml version='1.0' encoding='utf-8' ?>
<vector android:height="24.0dp"
android:width="24.0dp"
android:viewportWidth="24.0"
Expand All @@ -87,13 +87,10 @@ object XMLUtils {
""".trimIndent()

fun updateXVector(context: ResourceContext) {
val newBirdVectorWhite = ogBirdVectorWhite
val newBirdVector = ogBirdVector

val vectorFile = context["res/drawable/ic_vector_twitter_white.xml"]
vectorFile.writeText(newBirdVectorWhite)
vectorFile.writeText(ogBirdVectorWhite)

val vectorFileDark = context["res/drawable/ic_vector_twitter.xml"]
vectorFileDark.writeText(newBirdVector)
vectorFileDark.writeText(ogBirdVector)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import java.nio.file.Files
object BlackBirdIcon : ResourcePatch() {

private val newAvatarMarkerTwitterContent = XMLUtils.newAvatarMarkerTwitterContent.trimIndent()
private val blackbird = XMLUtils.blackBirdIco.trimIndent()
//private val blackbird = XMLUtils.blackBirdIco.trimIndent()

override fun execute(context: ResourceContext) {

updateAvatarMarkerTwitterXml(context)
updateLauncherXmlFiles(context)
XMLUtils.updateXVector(context)
//SplashScreenHelper().changeSplashScreen(context)
//XMLUtils.updateXVector(context)
SplashScreenHelper().changeSplashScreen(context)
}

private fun updateAvatarMarkerTwitterXml(context: ResourceContext) {
val avatarMarkerTwitterFile = context["res/drawable/avatar_marker_twitter.xml"]
if (!avatarMarkerTwitterFile.isFile) Files.createFile(avatarMarkerTwitterFile.toPath())

avatarMarkerTwitterFile.writeText(blackbird)
//avatarMarkerTwitterFile.writeText(blackbird)
}

private fun updateLauncherXmlFiles(context: ResourceContext) {
Expand Down

0 comments on commit 469e6f0

Please sign in to comment.