import os import gradio as gr from pathlib import Path from patcher import PhantomPatcher # PHANTOM APK AUTOMATOR v1.0 — UI Digital # Estética Premium: Dark Mode + Cyber Gradient CUSTOM_CSS = """ body { background-color: #0d0d0d !important; color: #e0e0e0 !important; } .gradio-container { border: 2px solid #ff0000; border-radius: 15px; padding: 20px; box-shadow: 0 0 20px rgba(255,0,0,0.2); } #title { text-align: center; font-size: 2.5em; font-weight: bold; color: #ff0000; text-transform: uppercase; margin-bottom: 30px; } .gr-button { background: linear-gradient(90deg, #800000 0%, #ff0000 100%) !important; color: #fff !important; font-weight: bold !important; border: none !important; } .gr-button:hover { background: linear-gradient(90deg, #ff0000 0%, #800000 100%) !important; transform: scale(1.02); transition: 0.2s; } .gr-input, .gr-file { background-color: #1a1a1a !important; border: 1px solid #333 !important; border-radius: 8px !important; } """ def phantom_process(apk_file, regex_input, replace_input): """ Função principal de processamento chamada pela UI. """ if not apk_file: return "Nenhum arquivo enviado.", None # Preparar diretório de trabalho patcher = PhantomPatcher(work_dir="phantom_workspace") patcher.clean() try: # 1. Carregar RegEx # Simples split por linha ou pipe se necessário # Por enquanto, par único. No futuro pode ser lista. regex_pairs = [(regex_input, replace_input)] # 2. Processar Arquivo input_path = Path(apk_file.name) ready_apk = patcher.prepare_file(input_path) # 3. Decompilar decompiled_dir = patcher.decompile(ready_apk) # 4. Patch patcher.apply_patches(decompiled_dir, regex_pairs) # 5. Rebuild & Sign output_name = f"MOD_{ready_apk.name}" final_apk = patcher.rebuildand_sign(decompiled_dir, output_name) return f"Sucesso Industrial! APK Modificado: {output_name}", str(final_apk) except Exception as e: return f"FALHA CRÍTICA NA OPERAÇÃO: {str(e)}", None # Construção da UI PHANTOM with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="red", neutral_hue="slate")) as demo: gr.HTML("