This commit is contained in:
inotia00
2023-01-10 04:30:54 +09:00
parent 1b83a30a56
commit 7db88c2dc8
77 changed files with 807 additions and 663 deletions

View File

@ -38,6 +38,7 @@ class GeneralAdsPatch : ResourcePatch {
"promotion_",
"compact_premium_",
"compact_promoted_",
"simple_text_section",
)
private val replacements = arrayOf(
@ -46,6 +47,13 @@ class GeneralAdsPatch : ResourcePatch {
"marginTop"
)
private val additionalReplacements = arrayOf(
"Bottom",
"End",
"Start",
"Top"
)
override fun execute(context: ResourceContext): PatchResult {
context.forEach {
@ -53,11 +61,11 @@ class GeneralAdsPatch : ResourcePatch {
// for each file in the "layouts" directory replace all necessary attributes content
context.xmlEditor[it.absolutePath].use { editor ->
editor.file.doRecursively { node ->
editor.file.doRecursively {
replacements.forEach replacement@{ replacement ->
if (node !is Element) return@replacement
if (it !is Element) return@replacement
node.getAttributeNode("android:layout_$replacement")?.let { attribute ->
it.getAttributeNode("android:layout_$replacement")?.let { attribute ->
attribute.textContent = "0.0dip"
}
}
@ -65,6 +73,18 @@ class GeneralAdsPatch : ResourcePatch {
}
}
context.xmlEditor["res/layout/simple_text_section.xml"].use { editor ->
editor.file.doRecursively {
additionalReplacements.forEach replacement@{ replacement ->
if (it !is Element) return@replacement
it.getAttributeNode("android:padding_$replacement")?.let { attribute ->
attribute.textContent = "0.0dip"
}
}
}
}
/*
add settings
*/