From 1e84f31eb04bb8c2c1a9daecdf58e465b6d38352 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 3 Sep 2025 18:40:48 +0500 Subject: [PATCH] chore: formatting files --- main.py | 2 +- patches/change_color_theme.py | 4 ++-- patches/change_navigation_bar.py | 11 ++++++++--- patches/disable_ad.py | 2 +- patches/force_static_request_urls.py | 29 +--------------------------- 5 files changed, 13 insertions(+), 35 deletions(-) diff --git a/main.py b/main.py index 75e0efd..cb3a102 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ def patch(): if __name__ == "__main__": check_and_download_all_tools() check_java_version() - + if args.init: init_patch() exit(0) diff --git a/patches/change_color_theme.py b/patches/change_color_theme.py index 889e035..0d33adf 100644 --- a/patches/change_color_theme.py +++ b/patches/change_color_theme.py @@ -28,14 +28,14 @@ class PatchConfig_ChangeColorTheme(TypedDict): def apply(patch_config: PatchConfig_ChangeColorTheme) -> bool: - + console.print("select color theme to apply (press [bold]enter[/bold] to confirm)") theme = select(patch_config["themes"], cursor="->", cursor_style="cyan") if not theme: console.print(f"theme: default") return False console.print(f"theme: {theme}") - + theme_attr = patch_config[theme]["attributes"] theme_text = patch_config[theme]["text"] theme_files = patch_config[theme]["files"] diff --git a/patches/change_navigation_bar.py b/patches/change_navigation_bar.py index 0202cc0..aab6b21 100644 --- a/patches/change_navigation_bar.py +++ b/patches/change_navigation_bar.py @@ -30,7 +30,7 @@ def modify_menu(menu: list[str], path: str) -> None: log.warning(f"menu item `{item}` is not allowed, removing from list") menu.remove(item) - root = etree.Element("menu", nsmap={"android": config['xml_ns']['android']}) + root = etree.Element("menu", nsmap={"android": config["xml_ns"]["android"]}) for item in menu: element = etree.SubElement(root, "item") element.set(f"{{{config['xml_ns']['android']}}}icon", f"@drawable/nav_{item}") @@ -47,6 +47,11 @@ def modify_menu(menu: list[str], path: str) -> None: def apply(patch_conf: PatchConfig_ChangeNavigationBar) -> bool: - modify_menu(patch_conf["portrait"], f"{config['folders']['decompiled']}/res/menu/bottom.xml") - modify_menu(patch_conf["landscape"], f"{config['folders']['decompiled']}/res/menu/navigation_rail_menu.xml") + modify_menu( + patch_conf["portrait"], f"{config['folders']['decompiled']}/res/menu/bottom.xml" + ) + modify_menu( + patch_conf["landscape"], + f"{config['folders']['decompiled']}/res/menu/navigation_rail_menu.xml", + ) return True diff --git a/patches/disable_ad.py b/patches/disable_ad.py index 6bac24e..4600769 100644 --- a/patches/disable_ad.py +++ b/patches/disable_ad.py @@ -20,7 +20,7 @@ replace = """ .locals 0 const/4 p0, 0x1 - return p0 + return p0 """ diff --git a/patches/force_static_request_urls.py b/patches/force_static_request_urls.py index 59f8a52..cc0529e 100644 --- a/patches/force_static_request_urls.py +++ b/patches/force_static_request_urls.py @@ -15,9 +15,6 @@ from scripts.smali_parser import ( get_smali_lines, save_smali_lines, find_and_replace_smali_line, - find_smali_method_start, - find_smali_method_end, - replace_smali_method_body, ) @@ -39,14 +36,6 @@ class PatchConfig_ForceStaticRequestUrls(TypedDict): constants: PatchConfig_ForceStaticRequestUrlsConst -replace_should_use_mirror_urls = """ .locals 0 - - const/4 p0, 0x0 - - return p0 -""" - - def apply(patch_config: PatchConfig_ForceStaticRequestUrls) -> bool: for value in patch_config["values"]: if os.path.exists(f"{config['folders']['decompiled']}/{value['file_path']}"): @@ -71,21 +60,6 @@ def apply(patch_config: PatchConfig_ForceStaticRequestUrls) -> bool: save_smali_lines(path, lines) log.debug(f"[FORCE_STATIC_REQUEST_URLS] file {path} has been modified") - # IDK If it is actually needed, will leave it for now, but seems like it should not be needed, since patch is working - # path = f"{config['folders']['decompiled']}/smali_classes2/com/swiftsoft/anixartd/Prefs.smali" - # if os.path.exists(path): - # lines = get_smali_lines(path) - # new_content = [] - # for index, line in enumerate(lines): - # if line.find("SHOULD_USE_MIRROR_URLS") >= 0: - # method_start = find_smali_method_start(lines, index) - # method_end = find_smali_method_end(lines, index) - # new_content = replace_smali_method_body( - # lines, method_start, method_end, replace_should_use_mirror_urls - # ) - # save_smali_lines(path, new_content) - # log.debug(f"[FORCE_STATIC_REQUEST_URLS] file {path} has been modified") - path = f"{config['folders']['decompiled']}/smali_classes2/com/swiftsoft/anixartd/DaggerApp_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.smali" pathInterceptor = f"{config['folders']['decompiled']}/smali_classes2/com/swiftsoft/anixartd/dagger/module/ApiModule$provideRetrofit$lambda$2$$inlined$-addInterceptor$1.smali" if os.path.exists(path) and os.path.exists(pathInterceptor): @@ -93,10 +67,9 @@ def apply(patch_config: PatchConfig_ForceStaticRequestUrls) -> bool: new_content = [] for index, line in enumerate(lines): if line.find("addInterceptor") >= 0: - continue + continue new_content.append(line) save_smali_lines(path, new_content) log.debug(f"[FORCE_STATIC_REQUEST_URLS] file {path} has been modified") - return True