forked from anixart-mod/patcher
Патч панели навигации и подписи версии в настройках
This commit is contained in:
@@ -9,6 +9,7 @@ from utils.public import (
|
||||
change_color,
|
||||
)
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
main_color = config["colors"]["primary"]
|
||||
splash_color = config["colors"]["secondary"]
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Replace navbar items"""
|
||||
priority = 0
|
||||
|
||||
from lxml import etree
|
||||
from tqdm import tqdm
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
file_path = "./decompiled/res/menu/bottom.xml"
|
||||
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
tree = etree.parse(file_path, parser)
|
||||
root = tree.getroot()
|
||||
|
||||
items = root.findall("item", namespaces=config['xml_ns'])
|
||||
|
||||
def get_id_suffix(item):
|
||||
full_id = item.get(f"{{{config['xml_ns']['android']}}}id")
|
||||
return full_id.split("tab_")[-1] if full_id else None
|
||||
|
||||
items_by_id = {get_id_suffix(item): item for item in items}
|
||||
existing_order = [get_id_suffix(item) for item in items]
|
||||
|
||||
ordered_items = []
|
||||
for key in config['items']:
|
||||
if key in items_by_id:
|
||||
ordered_items.append(items_by_id[key])
|
||||
|
||||
extra = [i for i in items if get_id_suffix(i) not in config['items']]
|
||||
if extra:
|
||||
tqdm.write("⚠Найдены лишние элементы: " + str([get_id_suffix(i) for i in extra]))
|
||||
ordered_items.extend(extra)
|
||||
|
||||
for i in root.findall("item", namespaces=config['xml_ns']):
|
||||
root.remove(i)
|
||||
|
||||
for item in ordered_items:
|
||||
root.append(item)
|
||||
|
||||
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||
|
||||
return True
|
||||
@@ -38,4 +38,19 @@ def apply(config: dict) -> bool:
|
||||
|
||||
# Save back
|
||||
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||
|
||||
filepaths = [
|
||||
"./decompiled/smali_classes2/com/swiftsoft/anixartd/ui/activity/UpdateActivity.smali",
|
||||
"./decompiled/smali_classes2/com/swiftsoft/anixartd/ui/fragment/main/preference/MainPreferenceFragment.smali",
|
||||
]
|
||||
for filepath in filepaths:
|
||||
content = ""
|
||||
with open(filepath, "r", encoding="utf-8") as file:
|
||||
for line in file.readlines():
|
||||
if '"\u0412\u0435\u0440\u0441\u0438\u044f'.encode("unicode_escape").decode() in line:
|
||||
content += line[:line.rindex('"')] + config["version"] + line[line.rindex('"'):]
|
||||
else:
|
||||
content += line
|
||||
with open(filepath, "w", encoding="utf-8") as file:
|
||||
file.write(content)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user