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

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
+1
View File
@@ -113,6 +113,7 @@ class Patch:
return True
except Exception as e:
print(f"Ошибка при применении патча {self.name}: {e}")
print(e.args)
return False
+1 -1
View File
@@ -3,5 +3,5 @@
import time
def apply(config: dict) -> bool:
time.sleep(1)
time.sleep(0.2)
return False
+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
+31 -3
View File
@@ -14,9 +14,37 @@
}
},
"cleanup": {
"keep_dirs": [
"META-INF",
"kotlin"
"keep_dirs": ["META-INF", "kotlin"]
},
"settings_urls": {
"Мы в социальных сетях": [
{
"title": "wowlikon",
"description": "Разработчик",
"url": "https://t.me/wowlikon",
"icon": "@drawable/ic_custom_telegram",
"icon_space_reserved": "false"
},
{
"title": "Мы в Telegram",
"description": "Подпишитесь на канал, чтобы быть в курсе последних новостей.",
"url": "https://t.me/wowlikon",
"icon": "@drawable/ic_custom_telegram",
"icon_space_reserved": "false"
}
],
"Прочее": [
{
"title": "Поддержать проект",
"description": "После пожертвования вы сможете выбрать в своём профиле любую роль, например «Кошка-девочка», которая будет видна всем пользователям мода.",
"url": "https://t.me/wowlikon",
"icon": "@drawable/ic_custom_crown",
"icon_space_reserved": "false"
}
]
},
"xml_ns": {
"android": "http://schemas.android.com/apk/res/android",
"app": "http://schemas.android.com/apk/res-auto"
}
}
+16 -6
View File
@@ -11,10 +11,9 @@ def apply(config: dict) -> bool:
)
# Mod assets
shutil.copy("./patches/resources/wowlikon.png", "./decompiled/assets/wowlikon.png")
shutil.copy(
"./patches/resources/ytsans_medium.ttf",
"./decompiled/res/font/ytsans_medium.ttf",
"./patches/resources/wowlikon.png",
"./decompiled/assets/wowlikon.png"
)
shutil.copy(
"./patches/resources/OpenSans-Regular.ttf",
@@ -29,9 +28,20 @@ def apply(config: dict) -> bool:
"./decompiled/res/drawable/ic_custom_telegram.xml",
)
shutil.copy(
"./patches/resources/torlook-fs8.torlook-fs8.png",
"./decompiled/res/drawable/torlook-fs8.png",
"./patches/resources/ytsans_medium.ttf",
"./decompiled/res/font/ytsans_medium.ttf",
)
os.remove("./decompiled/res/font/ytsans_medium.otf")
# IDK
shutil.move(
"./decompiled/res/raw/bundled_cert.crt",
"./decompiled/res/raw/bundled_cert.cer",
)
shutil.move(
"./decompiled/res/raw/sdkinternalca.crt",
"./decompiled/res/raw/sdkinternalca.cer",
)
os.remove("./decompiled/res/font/ytsans_medium.otf")
return False
return True
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

+41
View File
@@ -0,0 +1,41 @@
# Change application theme
from lxml import etree
# Generate PreferenceCategory
def make_category(ns, name, items):
cat = etree.Element("PreferenceCategory", nsmap=ns)
cat.set(f"{{{ns['android']}}}title", name)
cat.set(f"{{{ns['app']}}}iconSpaceReserved", "false")
for item in items:
pref = etree.SubElement(cat, "Preference", nsmap=ns)
pref.set(f"{{{ns['android']}}}title", item["title"])
pref.set(f"{{{ns['android']}}}summary", item["description"])
pref.set(f"{{{ns['app']}}}icon", item["icon"])
pref.set(f"{{{ns['app']}}}iconSpaceReserved", item["icon_space_reserved"])
intent = etree.SubElement(pref, "intent", nsmap=ns)
intent.set(f"{{{ns['android']}}}action", "android.intent.action.VIEW")
intent.set(f"{{{ns['android']}}}data", item["url"])
intent.set(f"{{{ns['app']}}}iconSpaceReserved", item["icon_space_reserved"])
return cat
def apply(config: dict) -> bool:
file_path = "./decompiled/res/xml/preference_main.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
root = tree.getroot()
# Insert new PreferenceCategory before the last element
last = root[-1] # last element
pos = root.index(last)
for section, items in config["settings_urls"].items():
root.insert(pos, make_category(config["xml_ns"], section, items))
pos += 1
# Save back
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
return True