@@ -322,9 +322,13 @@ def download_completed(destination_path):
322
322
download_thread .start ()
323
323
324
324
def on_refresh_google_images (self , event ):
325
+ print ("Refreshing Google Images Menu ..." )
326
+ self .parent ._on_spin ('start' )
325
327
self .parent .config .google_images_last_checked = False
326
328
# Refresh the Google Images menu
327
329
self .parent .update_google_images_menu ()
330
+ print ("Completed refreshing Google Images Menu." )
331
+ self .parent ._on_spin ('stop' )
328
332
329
333
# ============================================================================
330
334
# Class GoogleImagesMenu
@@ -410,9 +414,9 @@ def __init__(self, parent):
410
414
phone_menu_item .SetBitmap (phone_icon )
411
415
watches_menu_item = self .AppendSubMenu (self .watches_menu , "Watches" )
412
416
watches_menu_item .SetBitmap (watch_icon )
413
- # self.AppendSeparator()
414
- # refresh_images_menu_item = self.Append(wx.ID_ANY, "Refresh images list")
415
- # self.Bind(wx.EVT_MENU, self.on_refresh_google_images, refresh_images_menu_item)
417
+ self .AppendSeparator ()
418
+ refresh_images_menu_item = self .Append (wx .ID_ANY , "Refresh images list" )
419
+ self .Bind (wx .EVT_MENU , self .on_refresh_google_images , refresh_images_menu_item )
416
420
417
421
if download_available :
418
422
self .parent .toast ("Updates are available" , f"There are updates available for your device.\n Check Google Images menu." )
@@ -751,7 +755,7 @@ def initialize(self):
751
755
752
756
# select configured device
753
757
debug ("select configured device" )
754
- self ._select_configured_device ()
758
+ self ._select_configured_device (is_init = True )
755
759
self ._refresh_ui ()
756
760
except Exception as e :
757
761
print (f"\n ❌ { datetime .now ():%Y-%m-%d %H:%M:%S} ERROR: Encountered an error while checking for connected devices during initialization." )
@@ -2392,7 +2396,7 @@ def _update_custom_flash_options(self):
2392
2396
# -----------------------------------------------
2393
2397
# _select_configured_device
2394
2398
# -----------------------------------------------
2395
- def _select_configured_device (self ):
2399
+ def _select_configured_device (self , is_init = False ):
2396
2400
try :
2397
2401
if self .config .device :
2398
2402
count = 0
@@ -2402,7 +2406,7 @@ def _select_configured_device(self):
2402
2406
set_phone_id (device .id )
2403
2407
puml (f":Select Device;\n " , True )
2404
2408
self ._print_device_details (device )
2405
- self .update_google_images_menu ()
2409
+ self .update_google_images_menu (update_icons_only = not is_init )
2406
2410
count += 1
2407
2411
elif self .device_choice .StringSelection :
2408
2412
device = self .device_choice .StringSelection
@@ -2416,7 +2420,7 @@ def _select_configured_device(self):
2416
2420
set_phone_id (device .id )
2417
2421
puml (f":Select Device;\n " , True )
2418
2422
self ._print_device_details (device )
2419
- self .update_google_images_menu ()
2423
+ self .update_google_images_menu (update_icons_only = not is_init )
2420
2424
else :
2421
2425
set_phone_id (None )
2422
2426
self .device_label .Label = "ADB Connected Devices"
@@ -2439,19 +2443,23 @@ def refresh_device(self, look_for_device=None):
2439
2443
print ("Updating connected devices ..." )
2440
2444
if look_for_device :
2441
2445
selected_device_id = look_for_device
2446
+ debug (f"Looking for requested device: { look_for_device } " )
2442
2447
else :
2443
2448
selected_device = self .device_choice .StringSelection
2449
+ debug (f"Checking a previous device choice: [{ selected_device } ]" )
2444
2450
selected_device_id = None
2445
2451
if selected_device :
2446
2452
# selected_device_id = selected_device.split()[2]
2447
2453
selected_device_id = self .config .device
2454
+ debug (f"Looking for previously selected device: { selected_device_id } " )
2448
2455
self .device_choice .Clear ()
2449
2456
phones = get_phones ()
2450
2457
for device in phones :
2451
2458
if device :
2452
2459
device_details = device .get_device_details ()
2453
2460
self .device_choice .Append (device_details )
2454
2461
if selected_device_id and device .id == selected_device_id :
2462
+ debug (f"Found device: { selected_device_id } , selecting it ..." )
2455
2463
self .device_choice .SetStringSelection (device_details ) # Select the matching device ID
2456
2464
self ._select_configured_device ()
2457
2465
self ._reflect_slots ()
@@ -2778,8 +2786,9 @@ def _on_select_device(self, event):
2778
2786
wx .YieldIfNeeded ()
2779
2787
if device .id == d_id :
2780
2788
set_phone_id (device .id )
2789
+ self .config .device = device .id
2781
2790
self ._print_device_details (device )
2782
- self .update_google_images_menu ()
2791
+ self .update_google_images_menu (update_icons_only = True )
2783
2792
self ._reflect_slots ()
2784
2793
self .update_widget_states ()
2785
2794
except Exception as e :
@@ -2829,6 +2838,9 @@ def _on_scan(self, event):
2829
2838
# -----------------------------------------------
2830
2839
def _on_select_platform_tools (self , event ):
2831
2840
try :
2841
+ print ("\n ==============================================================================" )
2842
+ print (f" { datetime .now ():%Y-%m-%d %H:%M:%S} User initiated select platform tools" )
2843
+ print ("==============================================================================" )
2832
2844
self ._on_spin ('start' )
2833
2845
self .config .platform_tools_path = event .GetPath ().replace ("'" , "" )
2834
2846
check_platform_tools (self )
@@ -2847,6 +2859,9 @@ def _on_select_platform_tools(self, event):
2847
2859
# -----------------------------------------------
2848
2860
def update_firmware_selection (self , path ):
2849
2861
try :
2862
+ print ("\n ==============================================================================" )
2863
+ print (f" { datetime .now ():%Y-%m-%d %H:%M:%S} User initiated update firmware selection" )
2864
+ print ("==============================================================================" )
2850
2865
if not os .path .exists (path ):
2851
2866
print (f"\n ❌ { datetime .now ():%Y-%m-%d %H:%M:%S} ERROR: file { path } does not exist" )
2852
2867
return - 1
@@ -4863,14 +4878,37 @@ def _add_mode_radio_button(sizer, index, flash_mode, label, tooltip):
4863
4878
# -----------------------------------------------
4864
4879
# update_google_images_menu
4865
4880
# -----------------------------------------------
4866
- def update_google_images_menu (self ):
4867
- self .google_images_menu .reset_menu_id ()
4868
- menu_index = self .menuBar .FindMenu ("Google Images" )
4869
- self .menuBar .Remove (menu_index )
4870
- self .google_images_menu = GoogleImagesMenu (self )
4871
- self .menuBar .Insert (menu_index , self .google_images_menu , "Google Images" )
4872
- self .Refresh ()
4873
- self .Update ()
4881
+ def update_google_images_menu (self , update_icons_only = False ):
4882
+ try :
4883
+ if update_icons_only :
4884
+ device = get_phone ()
4885
+ device_icon = images .star_green_24 .GetBitmap ()
4886
+ empty_bitmap = wx .NullBitmap
4887
+
4888
+ if device :
4889
+ current_device = device .hardware
4890
+ else :
4891
+ current_device = "UNKNOWN_DEVICE"
4892
+
4893
+ for menu in [self .google_images_menu .phones_menu , self .google_images_menu .watches_menu ]:
4894
+ for item in menu .GetMenuItems ():
4895
+ # Clear the icon
4896
+ item .SetBitmap (empty_bitmap )
4897
+
4898
+ # If the item's label matches the current device, set the icon
4899
+ if current_device in item .GetItemLabelText ():
4900
+ item .SetBitmap (device_icon )
4901
+ else :
4902
+ self .google_images_menu .reset_menu_id ()
4903
+ menu_index = self .menuBar .FindMenu ("Google Images" )
4904
+ self .menuBar .Remove (menu_index )
4905
+ self .google_images_menu = GoogleImagesMenu (self )
4906
+ self .menuBar .Insert (menu_index , self .google_images_menu , "Google Images" )
4907
+ self .Refresh ()
4908
+ self .Update ()
4909
+ except Exception as e :
4910
+ print (f"\n ❌ { datetime .now ():%Y-%m-%d %H:%M:%S} ERROR: Encountered an error while updating Google Images Menu" )
4911
+ traceback .print_exc ()
4874
4912
4875
4913
4876
4914
# ============================================================================
0 commit comments