refactor: improve ExampleResourcePatch

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
oSumAtrIX 2022-05-23 20:58:03 +02:00
parent 5dc6aa9bfd
commit 5535eb4f01
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 12 additions and 16 deletions

View file

@ -1,4 +1,4 @@
package app.revanced.patcher
package app.revanced.patcher.usage
import org.junit.jupiter.api.Test

View file

@ -18,21 +18,17 @@ import org.w3c.dom.Element
@Version("0.0.1")
class ExampleResourcePatch : ResourcePatch() {
override fun execute(data: ResourceData): PatchResult {
val editor = data.getXmlEditor("AndroidManifest.xml")
// regular DomFileEditor
val element = editor
.file
.getElementsByTagName("application")
.item(0) as Element
element
.setAttribute(
"exampleAttribute",
"exampleValue"
)
// close the editor to write changes
editor.close()
data.getXmlEditor("AndroidManifest.xml").use { domFileEditor ->
val element = domFileEditor // regular DomFileEditor
.file
.getElementsByTagName("application")
.item(0) as Element
element
.setAttribute(
"exampleAttribute",
"exampleValue"
)
}
// iterate through all available resources
data.forEach {