From 1bd77ca3757cb3c0eb44bc4f5ba612adda9134c6 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Fri, 15 Aug 2025 19:25:21 -0500 Subject: [PATCH] wip --- debug_tools/debug_adb.py | 4 +- debug_tools/debug_main.py | 6 ++- debug_tools/debug_parsing.py | 4 +- debug_tools/test_large_transfer_progress.py | 4 +- debug_tools/test_minimal_progress.py | 4 +- debug_tools/test_modular_progress.py | 3 +- debug_tools/test_modular_successive.py | 4 +- debug_tools/test_normal_flow.py | 3 +- debug_tools/test_parsing.py | 24 +++++---- debug_tools/test_progress.py | 3 +- debug_tools/test_real_workflow.py | 3 +- debug_tools/test_successive_transfers.py | 8 ++- src/gui/main_window.py | 60 +++++++++++++++------ src/gui/windows_browser.py | 16 +----- 14 files changed, 92 insertions(+), 54 deletions(-) diff --git a/debug_tools/debug_adb.py b/debug_tools/debug_adb.py index 94dad2d..3280ad8 100644 --- a/debug_tools/debug_adb.py +++ b/debug_tools/debug_adb.py @@ -11,7 +11,7 @@ import os # Add the src directory to Python path for imports sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) -from adb_manager import ADB_BINARY_PATH +from src.adb_manager import ADB_BINARY_PATH def debug_large_transfer_output(): @@ -117,7 +117,7 @@ def main(): def debug_original_adb_detection(): """Original ADB debugging functionality.""" - from adb_manager import ADBManager + from src.adb_manager import ADBManager print("=== ADB Device Detection Debug ===\n") diff --git a/debug_tools/debug_main.py b/debug_tools/debug_main.py index a437b35..f56223a 100644 --- a/debug_tools/debug_main.py +++ b/debug_tools/debug_main.py @@ -4,10 +4,12 @@ Debug version of main window with console output """ import sys +import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) -from gui.main_window import AndroidFileHandlerGUI +from src.main_window import AndroidFileHandlerGUI class DebugAndroidFileHandlerGUI(AndroidFileHandlerGUI): diff --git a/debug_tools/debug_parsing.py b/debug_tools/debug_parsing.py index d3e8f93..0734ca5 100644 --- a/debug_tools/debug_parsing.py +++ b/debug_tools/debug_parsing.py @@ -5,8 +5,10 @@ Debug folder name parsing from ADB ls output import sys import subprocess +import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from adb_manager import ADB_BINARY_PATH diff --git a/debug_tools/test_large_transfer_progress.py b/debug_tools/test_large_transfer_progress.py index 94c524e..27319a7 100644 --- a/debug_tools/test_large_transfer_progress.py +++ b/debug_tools/test_large_transfer_progress.py @@ -6,8 +6,10 @@ Test improved progress calculation for large transfers import sys import time import threading +import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from gui.main_window import AndroidFileHandlerGUI diff --git a/debug_tools/test_minimal_progress.py b/debug_tools/test_minimal_progress.py index 1fd2d06..01f042b 100644 --- a/debug_tools/test_minimal_progress.py +++ b/debug_tools/test_minimal_progress.py @@ -6,8 +6,10 @@ Minimal test to verify progress updates work in modular GUI import sys import time import threading +import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from gui.main_window import AndroidFileHandlerGUI diff --git a/debug_tools/test_modular_progress.py b/debug_tools/test_modular_progress.py index 705d64a..e36afd1 100644 --- a/debug_tools/test_modular_progress.py +++ b/debug_tools/test_modular_progress.py @@ -6,7 +6,8 @@ Debug test for progress callback in modular GUI import sys import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from gui.main_window import AndroidFileHandlerGUI diff --git a/debug_tools/test_modular_successive.py b/debug_tools/test_modular_successive.py index 4809eff..f26d577 100644 --- a/debug_tools/test_modular_successive.py +++ b/debug_tools/test_modular_successive.py @@ -6,8 +6,10 @@ Test successive transfers with modular GUI import sys import time import threading +import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from gui.main_window import AndroidFileHandlerGUI diff --git a/debug_tools/test_normal_flow.py b/debug_tools/test_normal_flow.py index ac9dd32..f122987 100644 --- a/debug_tools/test_normal_flow.py +++ b/debug_tools/test_normal_flow.py @@ -8,7 +8,8 @@ import os import time import threading -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from gui.main_window import AndroidFileHandlerGUI diff --git a/debug_tools/test_parsing.py b/debug_tools/test_parsing.py index f5effb0..116205d 100644 --- a/debug_tools/test_parsing.py +++ b/debug_tools/test_parsing.py @@ -4,41 +4,45 @@ Test script to debug folder parsing """ import sys import os -sys.path.insert(0, 'src') + +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from adb_manager import ADBManager + def main(): adb = ADBManager() print("Testing folder parsing...") - - result = adb.run_adb_command(['shell', 'ls', '-la', '/sdcard/']) + + result = adb.run_adb_command(["shell", "ls", "-la", "/sdcard/"]) print(f"Return code: {result[2]}") - - lines = result[0].strip().split('\n') + + lines = result[0].strip().split("\n") print(f"Total lines: {len(lines)}") print("\nFirst 10 lines:") for i, line in enumerate(lines[:10]): print(f" {i}: {repr(line)}") - + print("\nParsing directories:") folders = [] for i, line in enumerate(lines): - if line.startswith('d'): + if line.startswith("d"): parts = line.split() print(f" Line {i}: {len(parts)} parts") if len(parts) >= 8: # Changed from 9 to 8 - folder_name = ' '.join(parts[7:]) # Changed from 8 to 7 + folder_name = " ".join(parts[7:]) # Changed from 8 to 7 print(f" Folder name: {repr(folder_name)}") - if folder_name not in ['.', '..']: + if folder_name not in [".", ".."]: folders.append(folder_name) print(f" ✅ Added: {repr(folder_name)}") else: print(f" ❌ Skipped: {repr(folder_name)}") - + print(f"\nFinal folders list ({len(folders)} items):") for folder in sorted(folders): print(f" - {repr(folder)}") + if __name__ == "__main__": main() diff --git a/debug_tools/test_progress.py b/debug_tools/test_progress.py index e2fe9e6..9eb6236 100644 --- a/debug_tools/test_progress.py +++ b/debug_tools/test_progress.py @@ -5,7 +5,8 @@ Test script to verify progress callback is working import sys import os -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from adb_manager import ADBManager import time diff --git a/debug_tools/test_real_workflow.py b/debug_tools/test_real_workflow.py index 81df5a6..1458ba1 100644 --- a/debug_tools/test_real_workflow.py +++ b/debug_tools/test_real_workflow.py @@ -8,7 +8,8 @@ import os import time import threading -sys.path.insert(0, "src") +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from gui.main_window import AndroidFileHandlerGUI diff --git a/debug_tools/test_successive_transfers.py b/debug_tools/test_successive_transfers.py index a60afcc..7d90f5c 100644 --- a/debug_tools/test_successive_transfers.py +++ b/debug_tools/test_successive_transfers.py @@ -6,7 +6,13 @@ import sys import os import time -sys.path.insert(0, "src") +import sys +import time +import threading +import os + +# Add the src directory to Python path for imports +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")) from adb_manager import ADBManager diff --git a/src/gui/main_window.py b/src/gui/main_window.py index ee2ac36..a56155d 100644 --- a/src/gui/main_window.py +++ b/src/gui/main_window.py @@ -26,9 +26,16 @@ except ImportError: is_adb_available, ) -from .progress_handler import ProgressHandler -from .windows_browser import WindowsAndroidBrowser -from .linux_browser import LinuxAndroidBrowser +try: + # Try relative imports first + from .progress_handler import ProgressHandler + from .windows_browser import WindowsAndroidBrowser + from .linux_browser import LinuxAndroidBrowser +except ImportError: + # Fall back to direct imports + from progress_handler import ProgressHandler + from windows_browser import WindowsAndroidBrowser + from linux_browser import LinuxAndroidBrowser class AndroidFileHandlerGUI(tk.Tk): @@ -253,17 +260,25 @@ class AndroidFileHandlerGUI(tk.Tk): self.check_device_connection() def show_enable_debugging_instructions(self): - """Show instructions for enabling USB debugging.""" + """Show instructions to connect device, enable file transfer, and to enable USB debugging.""" msg = ( + "Additionally, ensure your device is set to 'File Transfer' mode:\n" + "1. When you connect your device, swipe down to check the notification panel.\n" + "2. Look for a 'USB' notification that will tell you what mode the device is in (usually 'Charging over USB') and tap it.\n" + "3. Select 'File Transfer' or 'MTP' mode.\n\n" + "Please ensure your Android device is securely connected to the computer at both ends.\n\n" "To enable USB debugging:\n" - "1. Open Settings → About phone.\n" - "2. Tap 'Build number' seven times to unlock Developer Options.\n" - "3. Go back to Settings → Developer Options.\n" - "4. Enable 'USB debugging'.\n" - "5. Connect your phone via USB and accept the prompt to allow debugging.\n\n" - "After enabling, click 'Recheck for connected Android device' to try again." + "1. Connect your device to the computer via USB.\n" + "2. Open Settings → About phone.\n" + "3. Tap 'Build number' seven times to unlock Developer Options.\n" + "4. Go back to Settings → Developer Options.\n" + "5. Enable 'USB debugging'.\n" + "6. Connect your phone via USB and accept the prompt to allow debugging.\n\n" + "After enabling USB debugging, please click the 'Recheck for connected Android device' button to try again." + ) + result = messagebox.showinfo( + "Check device connection and enable USB Debugging", msg ) - result = messagebox.showinfo("Enable USB Debugging", msg) # After user clicks OK, ensure recheck button is enabled self.after(0, self._enable_recheck_after_dialog) @@ -280,8 +295,8 @@ class AndroidFileHandlerGUI(tk.Tk): def _show_debugging_reminder_ui(self): """Internal method to show debugging reminder on main thread.""" msg = ( - "Transfer completed.\n\n" - "For security, disable USB debugging when done:\n" + "Transfer completed!\n\n" + "For security, please disable USB debugging when done:\n" "Settings → Developer Options → disable 'USB debugging'." ) messagebox.showinfo("Disable USB Debugging", msg) @@ -290,10 +305,23 @@ class AndroidFileHandlerGUI(tk.Tk): """Start the file transfer operation.""" # Double-check device is still connected before starting transfer if not self.device_connected: - messagebox.showerror( - "No Device", - "No Android device is connected. Please connect your device and enable USB debugging.", + msg = ( + "Android device appears to have been disconnected and/or USB debugging is disabled.\n" + "Please ensure your Android device is securely connected to the computer at both ends.\n\n" + "Additionally, ensure your device is set to 'File Transfer' mode:\n" + "1. When you connect your device, swipe down to check the notification panel.\n" + "2. Look for a 'USB' notification that will tell you what mode the device is in (usually 'Charging over USB') and tap it.\n" + "3. Select 'File Transfer' or 'MTP' mode.\n\n" + "To enable USB debugging:\n" + "1. Connect your device to the computer via USB.\n" + "2. Open Settings → About phone.\n" + "3. Tap 'Build number' seven times to unlock Developer Options.\n" + "4. Go back to Settings → Developer Options.\n" + "5. Enable 'USB debugging'.\n" + "6. Connect your phone via USB and accept the prompt to allow debugging.\n\n" + "After enabling USB debugging, please click the 'Recheck for connected Android device' button to try again." ) + messagebox.showerror("No Android Device Detected", msg) self._switch_to_recheck_mode() return diff --git a/src/gui/windows_browser.py b/src/gui/windows_browser.py index f9289a6..8a9b0bf 100644 --- a/src/gui/windows_browser.py +++ b/src/gui/windows_browser.py @@ -5,7 +5,7 @@ Provides Android filesystem browsing capabilities for Windows using ADB. import threading import tkinter as tk -from tkinter import messagebox, ttk, simpledialog +from tkinter import messagebox, ttk class WindowsAndroidBrowser: @@ -404,23 +404,9 @@ class WindowsAndroidBrowser: else: messagebox.showwarning("No Selection", "Please select a valid folder.") - def enter_custom_path(): - """Allow user to enter a custom path.""" - browser_window.destroy() - custom_path = simpledialog.askstring( - "Custom Path", - "Enter custom Android folder path:", - initialvalue="/sdcard/", - ) - if custom_path: - self.remote_path_var.set(custom_path.strip()) - tk.Button( button_frame, text="Select This Folder", command=select_current_folder ).pack(side="left", padx=5) - tk.Button( - button_frame, text="Enter Custom Path", command=enter_custom_path - ).pack(side="left", padx=5) tk.Button(button_frame, text="Cancel", command=browser_window.destroy).pack( side="left", padx=5 )