forked from anixart-mod/patcher
исправления ошибок, добавление патча настроек
This commit is contained in:
@@ -113,6 +113,7 @@ class Patch:
|
|||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Ошибка при применении патча {self.name}: {e}")
|
print(f"Ошибка при применении патча {self.name}: {e}")
|
||||||
|
print(e.args)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
def apply(config: dict) -> bool:
|
def apply(config: dict) -> bool:
|
||||||
time.sleep(1)
|
time.sleep(0.2)
|
||||||
return False
|
return False
|
||||||
|
|||||||
+19
-21
@@ -1,6 +1,6 @@
|
|||||||
# Change application theme
|
# Change application theme
|
||||||
|
|
||||||
import re
|
from lxml import etree
|
||||||
|
|
||||||
|
|
||||||
def apply(config: dict) -> bool:
|
def apply(config: dict) -> bool:
|
||||||
@@ -24,34 +24,32 @@ def apply(config: dict) -> bool:
|
|||||||
for drawable_type in drawable_types:
|
for drawable_type in drawable_types:
|
||||||
# Application logo gradient colors
|
# Application logo gradient colors
|
||||||
file_path = f"./decompiled/res/drawable{drawable_type}/$logo__0.xml"
|
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):
|
# Change attributes with namespace
|
||||||
return (
|
root.set(f"{{{config['xml_ns']['android']}}}startColor", gradient_from)
|
||||||
f'android:startColor="{gradient_from}" android:endColor="{gradient_to}"'
|
root.set(f"{{{config['xml_ns']['android']}}}endColor", gradient_to)
|
||||||
)
|
|
||||||
|
|
||||||
new_content = re.sub(pattern, replace_colors, content).replace("\n ", "")
|
# Save back
|
||||||
|
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||||
with open(file_path, "w", encoding="utf-8") as file:
|
|
||||||
file.write(new_content)
|
|
||||||
|
|
||||||
# Application logo anim color
|
# Application logo anim color
|
||||||
file_path = f"./decompiled/res/drawable{drawable_type}/$logo_splash_anim__0.xml"
|
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):
|
# Finding "path"
|
||||||
return f'android:name="path" android:fillColor="{splash_color}"'
|
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)
|
# Save back
|
||||||
|
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||||
with open(file_path, "w", encoding="utf-8") as file:
|
|
||||||
file.write(new_content)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
+31
-3
@@ -14,9 +14,37 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cleanup": {
|
"cleanup": {
|
||||||
"keep_dirs": [
|
"keep_dirs": ["META-INF", "kotlin"]
|
||||||
"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
@@ -11,10 +11,9 @@ def apply(config: dict) -> bool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Mod assets
|
# Mod assets
|
||||||
shutil.copy("./patches/resources/wowlikon.png", "./decompiled/assets/wowlikon.png")
|
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
"./patches/resources/ytsans_medium.ttf",
|
"./patches/resources/wowlikon.png",
|
||||||
"./decompiled/res/font/ytsans_medium.ttf",
|
"./decompiled/assets/wowlikon.png"
|
||||||
)
|
)
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
"./patches/resources/OpenSans-Regular.ttf",
|
"./patches/resources/OpenSans-Regular.ttf",
|
||||||
@@ -29,9 +28,20 @@ def apply(config: dict) -> bool:
|
|||||||
"./decompiled/res/drawable/ic_custom_telegram.xml",
|
"./decompiled/res/drawable/ic_custom_telegram.xml",
|
||||||
)
|
)
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
"./patches/resources/torlook-fs8.torlook-fs8.png",
|
"./patches/resources/ytsans_medium.ttf",
|
||||||
"./decompiled/res/drawable/torlook-fs8.png",
|
"./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")
|
os.remove("./decompiled/res/font/ytsans_medium.otf")
|
||||||
return False
|
return True
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
@@ -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
|
||||||
Reference in New Issue
Block a user