forked from anixart-mod/patcher
Добавление патча сжатия png, обновление документации
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# Change package icon of apk
|
||||
"""Change application icon"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import time
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# Change api server of apk
|
||||
"""Change api server"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import json
|
||||
import requests
|
||||
@@ -6,6 +8,8 @@ import requests
|
||||
def apply(config: dict) -> bool:
|
||||
response = requests.get(config['server'])
|
||||
if response.status_code == 200:
|
||||
print(json.loads(response.text))
|
||||
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
|
||||
|
||||
+5
-3
@@ -1,4 +1,6 @@
|
||||
# Remove unnecessary files
|
||||
"""Remove unnecessary files"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
import shutil
|
||||
@@ -9,9 +11,9 @@ def apply(config: dict) -> bool:
|
||||
|
||||
if os.path.isfile(item_path):
|
||||
os.remove(item_path)
|
||||
print(f'Удалён файл: {item_path}')
|
||||
tqdm.write(f'Удалён файл: {item_path}')
|
||||
elif os.path.isdir(item_path):
|
||||
if item not in config["cleanup"]["keep_dirs"]:
|
||||
shutil.rmtree(item_path)
|
||||
print(f'Удалена папка: {item_path}')
|
||||
tqdm.write(f'Удалена папка: {item_path}')
|
||||
return True
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Change application theme
|
||||
"""Change application theme"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
from lxml import etree
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
main_color = config["theme"]["colors"]["primary"]
|
||||
splash_color = config["theme"]["colors"]["secondary"]
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Compress PNGs"""
|
||||
priority = 1
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def compress_pngs(root_dir):
|
||||
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}")
|
||||
try:
|
||||
subprocess.run(
|
||||
["pngquant", "--force", "--ext", ".png", "--quality=65-90", filepath],
|
||||
check=True, capture_output=True
|
||||
)
|
||||
compressed_files.append(filepath)
|
||||
except subprocess.CalledProcessError as e:
|
||||
tqdm.write(f"Ошибка при сжатии {filepath}: {e}")
|
||||
return compressed_files
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
files = compress_pngs("./decompiled")
|
||||
return len(files) > 0 and any(files)
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"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": {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
# Change package icon of apk
|
||||
"""Insert new files"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import shutil
|
||||
import os
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
# Mod first launch window
|
||||
shutil.copytree(
|
||||
"./patches/resources/smali_classes4/", "./decompiled/smali_classes4/"
|
||||
"./patches/resources/smali_classes4/",
|
||||
"./decompiled/smali_classes4/"
|
||||
)
|
||||
|
||||
# Mod assets
|
||||
@@ -43,5 +45,4 @@ def apply(config: dict) -> bool:
|
||||
"./decompiled/res/raw/sdkinternalca.cer",
|
||||
)
|
||||
|
||||
os.remove("./decompiled/res/font/ytsans_medium.otf")
|
||||
return True
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Change package name of apk
|
||||
"""Change package name of apk"""
|
||||
priority = -1
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def rename_dir(src, dst):
|
||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||
os.rename(src, dst)
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
assert config["new_package_name"] is not None, "new_package_name is not configured"
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Change application theme
|
||||
"""Add new settings"""
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
from lxml import etree
|
||||
|
||||
|
||||
# Generate PreferenceCategory
|
||||
def make_category(ns, name, items):
|
||||
cat = etree.Element("PreferenceCategory", nsmap=ns)
|
||||
|
||||
Reference in New Issue
Block a user