исправления ошибок, добавление патча настроек

This commit is contained in:
2025-08-28 11:56:34 +03:00
parent 0a3e4d780c
commit 99ef353500
7 changed files with 109 additions and 31 deletions
+19 -21
View File
@@ -1,6 +1,6 @@
# Change application theme
import re
from lxml import etree
def apply(config: dict) -> bool:
@@ -24,34 +24,32 @@ def apply(config: dict) -> bool:
for drawable_type in drawable_types:
# Application logo gradient colors
file_path = f"./decompiled/res/drawable{drawable_type}/$logo__0.xml"
with open(file_path, "r", encoding="utf-8") as file:
content = file.read()
pattern = r'android:startColor="(#[0-9a-fA-F]{8})"\s+android:endColor="(#[0-9a-fA-F]{8})"'
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
root = tree.getroot()
def replace_colors(match):
return (
f'android:startColor="{gradient_from}" android:endColor="{gradient_to}"'
)
# Change attributes with namespace
root.set(f"{{{config['xml_ns']['android']}}}startColor", gradient_from)
root.set(f"{{{config['xml_ns']['android']}}}endColor", gradient_to)
new_content = re.sub(pattern, replace_colors, content).replace("\n ", "")
with open(file_path, "w", encoding="utf-8") as file:
file.write(new_content)
# Save back
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
# Application logo anim color
file_path = f"./decompiled/res/drawable{drawable_type}/$logo_splash_anim__0.xml"
with open(file_path, "r", encoding="utf-8") as file:
content = file.read()
pattern = r'android:name="path" android:fillColor="(#[0-9a-fA-F]{8})"'
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
root = tree.getroot()
def replace_colors(match):
return f'android:name="path" android:fillColor="{splash_color}"'
# Finding "path"
for el in root.findall("path", namespaces=config['xml_ns']):
name = el.get(f"{{{config['xml_ns']['android']}}}name")
if name == "path":
el.set(f"{{{config['xml_ns']['android']}}}fillColor", splash_color)
new_content = re.sub(pattern, replace_colors, content).replace("\n ", " ", 1)
with open(file_path, "w", encoding="utf-8") as file:
file.write(new_content)
# Save back
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
return True