mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-06 03:03:50 +05:00
feat: add disable beta banner patch
This commit is contained in:
parent
4ec18d7dd4
commit
8498cace94
4 changed files with 84 additions and 19 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ decompiled
|
||||||
dist
|
dist
|
||||||
__pycache__
|
__pycache__
|
||||||
keystore.jks
|
keystore.jks
|
||||||
|
help
|
15
main.py
15
main.py
|
@ -7,7 +7,14 @@ from config import log, console
|
||||||
from time import time
|
from time import time
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
parser = argparse.ArgumentParser(prog='anixart patcher')
|
||||||
|
parser.add_argument("--no-decompile", action='store_true')
|
||||||
|
parser.add_argument("--no-compile", action='store_true')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
check_and_download_all_tools()
|
check_and_download_all_tools()
|
||||||
check_java_version()
|
check_java_version()
|
||||||
|
|
||||||
|
@ -15,10 +22,14 @@ if __name__ == "__main__":
|
||||||
if not apks:
|
if not apks:
|
||||||
log.fatal(f"apks folder is empty")
|
log.fatal(f"apks folder is empty")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
apk = select_apk(apks)
|
apk = select_apk(apks)
|
||||||
|
if not apk:
|
||||||
|
log.info('cancelled')
|
||||||
|
exit(0)
|
||||||
|
|
||||||
start_time = time()
|
start_time = time()
|
||||||
|
|
||||||
|
if not args.no_decompile:
|
||||||
decompile_apk(apk)
|
decompile_apk(apk)
|
||||||
|
|
||||||
patches = get_patches()
|
patches = get_patches()
|
||||||
|
@ -35,8 +46,10 @@ if __name__ == "__main__":
|
||||||
console.print(f"{status['name']}: ✘", style="bold red")
|
console.print(f"{status['name']}: ✘", style="bold red")
|
||||||
statuses_err.append(status["name"])
|
statuses_err.append(status["name"])
|
||||||
|
|
||||||
|
if not args.no_compile:
|
||||||
compile_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
compile_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
||||||
sign_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
sign_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
||||||
|
|
||||||
end_time = time()
|
end_time = time()
|
||||||
|
|
||||||
log.info("Finished")
|
log.info("Finished")
|
||||||
|
|
45
patches/disable_beta_banner.py
Normal file
45
patches/disable_beta_banner.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
"""Remove beta banner"""
|
||||||
|
|
||||||
|
priority = 0
|
||||||
|
import os
|
||||||
|
from tqdm import tqdm
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
from typing import TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
class PatchConfig_DisableBetaBanner(TypedDict):
|
||||||
|
src: str
|
||||||
|
|
||||||
|
|
||||||
|
def apply(config: PatchConfig_DisableBetaBanner) -> bool:
|
||||||
|
xml_ns = {
|
||||||
|
"android": "http://schemas.android.com/apk/res/android",
|
||||||
|
"app": "http://schemas.android.com/apk/res-auto",
|
||||||
|
}
|
||||||
|
attributes = [
|
||||||
|
"paddingTop",
|
||||||
|
"paddingBottom",
|
||||||
|
"paddingStart",
|
||||||
|
"paddingEnd",
|
||||||
|
"layout_width",
|
||||||
|
"layout_height",
|
||||||
|
"layout_marginTop",
|
||||||
|
"layout_marginBottom",
|
||||||
|
"layout_marginStart",
|
||||||
|
"layout_marginEnd"
|
||||||
|
]
|
||||||
|
|
||||||
|
beta_banner_xml = f"{config['src']}/res/layout/item_beta.xml"
|
||||||
|
if os.path.exists(beta_banner_xml):
|
||||||
|
parser = etree.XMLParser(remove_blank_text=True)
|
||||||
|
tree = etree.parse(beta_banner_xml, parser)
|
||||||
|
root = tree.getroot()
|
||||||
|
|
||||||
|
for attr in attributes:
|
||||||
|
tqdm.write(f"set {attr} = 0.0dip")
|
||||||
|
root.set(f"{{{xml_ns['android']}}}{attr}", "0.0dip")
|
||||||
|
|
||||||
|
tree.write(beta_banner_xml, pretty_print=True, xml_declaration=True, encoding="utf-8")
|
||||||
|
|
||||||
|
return True
|
|
@ -70,8 +70,13 @@ def apply_patches(patches: list[str]) -> list[PatchStatus]:
|
||||||
modules.append(Patch(name, module))
|
modules.append(Patch(name, module))
|
||||||
modules.sort(key=lambda x: x.package.priority, reverse=True)
|
modules.sort(key=lambda x: x.package.priority, reverse=True)
|
||||||
|
|
||||||
for patch in tqdm(modules, colour="green", desc="patching apk"):
|
with tqdm(
|
||||||
tqdm.write(f"patch apply: {patch.name}")
|
total=len(modules),
|
||||||
|
unit="patch",
|
||||||
|
unit_divisor=1,
|
||||||
|
) as bar:
|
||||||
|
for patch in modules:
|
||||||
|
bar.set_description(f"{patch.name}")
|
||||||
conf = {}
|
conf = {}
|
||||||
if os.path.exists(f"{config['folders']['patches']}/{patch.name}.config.json"):
|
if os.path.exists(f"{config['folders']['patches']}/{patch.name}.config.json"):
|
||||||
with open(
|
with open(
|
||||||
|
@ -83,5 +88,6 @@ def apply_patches(patches: list[str]) -> list[PatchStatus]:
|
||||||
conf["src"] = config["folders"]["decompiled"]
|
conf["src"] = config["folders"]["decompiled"]
|
||||||
status = patch.apply(conf)
|
status = patch.apply(conf)
|
||||||
statuses.append({"name": patch.name, "status": status})
|
statuses.append({"name": patch.name, "status": status})
|
||||||
|
bar.update()
|
||||||
|
|
||||||
return statuses
|
return statuses
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue