Skip to content

Commit

Permalink
update(Bring back twitter): Create strings file if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
crimera committed Apr 30, 2024
1 parent de5b170 commit 9f51a5c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app.revanced.util.copyResources
import org.w3c.dom.Element
import crimera.patches.twitter.misc.bringbacktwitter.strings.StringsMap
import java.io.File
import java.io.FileWriter

@Patch(
name = "Bring back twitter",
Expand Down Expand Up @@ -102,8 +103,12 @@ object BringBackTwitterResourcePatch : ResourcePatch() {
for ((key, value) in langs) {
val stringsFile = context["res/$key/strings.xml"]
if(!stringsFile.isFile){
println("$key/strings.xml not found")
continue
// println("$key/strings.xml not found")

context["res/$key"].mkdirs()
FileWriter(stringsFile).use {
it.write("<?xml version=\"1.0\" encoding=\"utf-8\"?><resources></resources>")
}
}
updateStringsFile(stringsFile, value, context)
}
Expand All @@ -127,7 +132,12 @@ object BringBackTwitterResourcePatch : ResourcePatch() {

// log which keys were not found or failed
if (!keyReplaced) {
println("Key not found: $key")
val colorElement = document.createElement("string")

colorElement.setAttribute("name", key)
colorElement.textContent = value

document.getElementsByTagName("resources").item(0).appendChild(colorElement)
}
}
}
Expand Down

0 comments on commit 9f51a5c

Please sign in to comment.