Исправление патчей, реализация базвого функционала для сборки apk
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Change api server"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import json
|
||||
import requests
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
response = requests.get(config['server'])
|
||||
assert response.status_code == 200, f"Failed to fetch data {response.status_code} {response.text}"
|
||||
for item in json.loads(response.text)['modifications']:
|
||||
tqdm.write(f"Изменение {item['file']}")
|
||||
filepath = './decompiled/smali_classes2/com/swiftsoft/anixartd/network/api/'+item['file']
|
||||
with open(filepath, 'r') as f:
|
||||
content = f.read()
|
||||
with open(filepath, 'w') as f:
|
||||
if content.count(item['src']) == 0:
|
||||
tqdm.write(f"⚠ Не найдено {item['src']}")
|
||||
f.write(content.replace(item['src'], item['dst']))
|
||||
return True
|
||||
+4
-2
@@ -12,9 +12,11 @@ def apply(config: dict) -> bool:
|
||||
|
||||
if os.path.isfile(item_path):
|
||||
os.remove(item_path)
|
||||
tqdm.write(f'Удалён файл: {item_path}')
|
||||
if config.get("verbose", False):
|
||||
tqdm.write(f'Удалён файл: {item_path}')
|
||||
elif os.path.isdir(item_path):
|
||||
if item not in config["cleanup"]["keep_dirs"]:
|
||||
shutil.rmtree(item_path)
|
||||
tqdm.write(f'Удалена папка: {item_path}')
|
||||
if config.get("verbose", False):
|
||||
tqdm.write(f'Удалена папка: {item_path}')
|
||||
return True
|
||||
|
||||
+56
-1
@@ -3,10 +3,17 @@ priority = 0
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from utils.public import (
|
||||
insert_after_public,
|
||||
insert_after_color,
|
||||
insert_after_id,
|
||||
change_color,
|
||||
)
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
main_color = config["theme"]["colors"]["primary"]
|
||||
splash_color = config["theme"]["colors"]["secondary"]
|
||||
gradient_angle = config["theme"]["gradient"]["angle"]
|
||||
gradient_from = config["theme"]["gradient"]["from"]
|
||||
gradient_to = config["theme"]["gradient"]["to"]
|
||||
|
||||
@@ -31,6 +38,7 @@ def apply(config: dict) -> bool:
|
||||
root = tree.getroot()
|
||||
|
||||
# Change attributes with namespace
|
||||
root.set(f"{{{config['xml_ns']['android']}}}angle", gradient_angle)
|
||||
root.set(f"{{{config['xml_ns']['android']}}}startColor", gradient_from)
|
||||
root.set(f"{{{config['xml_ns']['android']}}}endColor", gradient_to)
|
||||
|
||||
@@ -45,7 +53,7 @@ def apply(config: dict) -> bool:
|
||||
root = tree.getroot()
|
||||
|
||||
# Finding "path"
|
||||
for el in root.findall("path", namespaces=config['xml_ns']):
|
||||
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)
|
||||
@@ -53,4 +61,51 @@ def apply(config: dict) -> bool:
|
||||
# Save back
|
||||
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||
|
||||
for filename in ["$ic_launcher_foreground__0", "$ic_banner_foreground__0"]:
|
||||
file_path = f"./decompiled/res/drawable-v24/{filename}.xml"
|
||||
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
tree = etree.parse(file_path, parser)
|
||||
root = tree.getroot()
|
||||
|
||||
# Change attributes with namespace
|
||||
root.set(f"{{{config['xml_ns']['android']}}}angle", gradient_angle)
|
||||
items = root.findall("item", namespaces=config['xml_ns'])
|
||||
assert len(items) == 2
|
||||
items[0].set(f"{{{config['xml_ns']['android']}}}color", gradient_from)
|
||||
items[1].set(f"{{{config['xml_ns']['android']}}}color", gradient_to)
|
||||
|
||||
# Save back
|
||||
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||
|
||||
insert_after_public("carmine", "custom_color")
|
||||
insert_after_public("carmine_alpha_10", "custom_color_alpha_10")
|
||||
insert_after_color("carmine", "custom_color", main_color[0]+'ff'+main_color[1:])
|
||||
insert_after_color("carmine_alpha_10", "custom_color_alpha_10", main_color[0]+'1a'+main_color[1:])
|
||||
|
||||
change_color("accent_alpha_10", main_color[0]+'1a'+main_color[1:])
|
||||
change_color("accent_alpha_20", main_color[0]+'33'+main_color[1:])
|
||||
change_color("accent_alpha_50", main_color[0]+'80'+main_color[1:])
|
||||
change_color("accent_alpha_70", main_color[0]+'b3'+main_color[1:])
|
||||
change_color("colorAccent", main_color[0]+'ff'+main_color[1:])
|
||||
change_color("link_color", main_color[0]+'ff'+main_color[1:])
|
||||
change_color("link_color_alpha_70", main_color[0]+'b3'+main_color[1:])
|
||||
change_color("refresh_progress", main_color[0]+'ff'+main_color[1:])
|
||||
|
||||
change_color("ic_launcher_background", "#ff000000")
|
||||
change_color("bottom_nav_indicator_active", "#ffffffff")
|
||||
change_color("bottom_nav_indicator_icon_checked", main_color[0]+'ff'+main_color[1:])
|
||||
change_color("bottom_nav_indicator_label_checked", main_color[0]+'ff'+main_color[1:])
|
||||
|
||||
insert_after_public("warning_error_counter_background", "ic_custom_telegram")
|
||||
insert_after_public("warning_error_counter_background", "ic_custom_crown")
|
||||
|
||||
try:
|
||||
last = "speed75"
|
||||
for speed in config.get("speeds", []):
|
||||
insert_after_public(last, f"speed{int(float(speed)*10)}")
|
||||
insert_after_id(last, f"speed{int(float(speed)*10)}")
|
||||
last = f"speed{int(float(speed)*10)}"
|
||||
except Exception as e:
|
||||
print(f"Error occurred while processing speeds: {e}")
|
||||
return True
|
||||
|
||||
@@ -6,15 +6,15 @@ import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def compress_pngs(root_dir):
|
||||
def compress_pngs(root_dir: str, verbose: bool = False):
|
||||
compressed_files = []
|
||||
for dirpath, _, filenames in os.walk(root_dir):
|
||||
for filename in filenames:
|
||||
if filename.lower().endswith(".png"):
|
||||
filepath = os.path.join(dirpath, filename)
|
||||
tqdm.write(f"Сжимаю: {filepath}")
|
||||
if verbose: tqdm.write(f"Сжимаю: {filepath}")
|
||||
try:
|
||||
subprocess.run(
|
||||
assert subprocess.run(
|
||||
[
|
||||
"pngquant",
|
||||
"--force",
|
||||
@@ -23,9 +23,8 @@ def compress_pngs(root_dir):
|
||||
"--quality=65-90",
|
||||
filepath,
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
).returncode in [0, 99]
|
||||
compressed_files.append(filepath)
|
||||
except subprocess.CalledProcessError as e:
|
||||
tqdm.write(f"Ошибка при сжатии {filepath}: {e}")
|
||||
@@ -33,5 +32,5 @@ def compress_pngs(root_dir):
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
files = compress_pngs("./decompiled")
|
||||
files = compress_pngs("./decompiled", config.get("verbose", False))
|
||||
return len(files) > 0 and any(files)
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
{
|
||||
"tools": {
|
||||
"apktool_jar_url": "https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.12.0.jar",
|
||||
"apktool_wrapper_url": "https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool"
|
||||
},
|
||||
"new_package_name": "com.wowlikon.anixart",
|
||||
"server": "https://anixarty.wowlikon.tech/modding",
|
||||
"theme": {
|
||||
"colors": {
|
||||
"primary": "#ccff00",
|
||||
"secondary": "#ffffd700",
|
||||
"background": "#FFFFFF",
|
||||
"text": "#000000"
|
||||
},
|
||||
"gradient": {
|
||||
"from": "#ffff6060",
|
||||
"to": "#ffccff00"
|
||||
}
|
||||
},
|
||||
"cleanup": {
|
||||
"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"
|
||||
},
|
||||
"speeds": [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 9.0]
|
||||
}
|
||||
@@ -5,8 +5,6 @@ from tqdm import tqdm
|
||||
import os
|
||||
from lxml import etree
|
||||
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
def apply(config) -> bool:
|
||||
attributes = [
|
||||
|
||||
@@ -49,6 +49,7 @@ def apply(config: dict) -> bool:
|
||||
config["new_package_name"].replace(".", "/"),
|
||||
),
|
||||
)
|
||||
os.rmdir("./decompiled/smali_classes2/com/swiftsoft")
|
||||
if os.path.exists("./decompiled/smali_classes4/com/swiftsoft"):
|
||||
rename_dir(
|
||||
"./decompiled/smali_classes4/com/swiftsoft",
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
"""Change api server"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import json
|
||||
import requests
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
response = requests.get(config['server'])
|
||||
if response.status_code == 200:
|
||||
for item in json.loads(response.text)["modding"]:
|
||||
tqdm.write(item)
|
||||
return True
|
||||
tqdm.write(f"Failed to fetch data {response.status_code} {response.text}")
|
||||
return False
|
||||
Reference in New Issue
Block a user