Skip to content

Commit 74af4c8

Browse files
authored
Upload v7.0-stable source files
1 parent 7991cf8 commit 74af4c8

11 files changed

+3829
-6
lines changed

Config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[ProgConfig]
2-
version = 7.0.0
2+
version = 7.0.1
33
rammappath = $DEFAULT
44
adwclrpath = $DEFAULT
55
winxpepath = $NONE
Binary file not shown.
Binary file not shown.
Binary file not shown.

android_cleaner/adb_processor.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,34 @@ def connectViaWiFiDebugging(ip_addr_and_port: str, auth_code=None):
182182

183183
return out
184184

185+
def getConnectedDevicesNamesWithSNs(userDevList: list=None):
186+
"""
187+
Returns a list with list representing each connected debugging mode device's Name and SN
188+
189+
Syntax for each device tuple is: (devNameSN,devType)
190+
191+
Output is usually like this: [(dev1NameSN,dev1Type),(dev2NameSN,dev2Type),(dev3NameSN,dev3Type),...]
192+
"""
193+
# userDevList is an optional devices list passed by the user in rare circumstances.
194+
if userDevList is not None:
195+
devList = userDevList
196+
else:
197+
devList: list = listADBDevices()
198+
devsWithSNs: list = []
199+
for dev in devList:
200+
devInLst: list = dev.split("\t")
201+
devInLst: tuple = tuple(devInLst)
202+
devsWithSNs.append(devInLst)
203+
return devsWithSNs
204+
185205
if __name__ == '__main__':
206+
# for testing
186207
# killADBDaemon()
187208
# requestADBConnection()
188-
209+
# requestADBConnection()
210+
# connectViaWiFiDebugging(ip_addr_and_port='192.168.1.7:36765')
211+
# print(listADBDevices())
212+
# print(getConnectedDevicesNamesWithSNs())
189213
# print(f"{listADBDevices()}, len:{len(listADBDevices())}")
190214
# print(needToShowInstructionsWindow())
191215
# print(cleanCachesViaADB())

android_cleaner/connection_window.py

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import time
1212
import threading
1313
from subprocess import getoutput
14+
from . import adb_processor
1415
# initializing a variable containing the path where program executable is stored.
1516
application_path = ''
1617

@@ -337,8 +338,107 @@ def closeWindowAndReturnData(self):
337338
return (self.ipaddr_and_port, self.authcode)
338339

339340

341+
chosen_dev = ''
342+
343+
class ChooseADeviceWindow(Toplevel):
344+
global getTextJustification, killADBDaemon, requestADBConnection, ipaddr_and_port, authcode, chosen_dev
345+
def __init__(self):
346+
global chosen_dev
347+
super().__init__()
348+
self.wm_attributes("-topmost", True)
349+
# trying to apply some styling as well.
350+
try:
351+
set_default_color_theme(f"{application_path}\\..\\style.json")
352+
except Exception as style_json_file_loader_tryone_error:
353+
print(f"[ERROR]: couldn't read from file 'style.json' in the current directory due to the error:\n{style_json_file_loader_tryone_error}")
354+
self.destroy()
355+
return # error 299 is for error loading style.json file from current and previous directories.
356+
def getCurrentAppearanceMode():
357+
"""
358+
Gets the current appearance mode to apply to the background of the widgets.
359+
360+
Returns a tuple containing the values of text color and background color for widgets.
361+
362+
Order goes like that:
363+
364+
```py
365+
(background_color, text_color)
366+
```
367+
"""
368+
global GetConfig
369+
try:
370+
if str(GetConfig["ProgConfig"]['appearancemode']) == "1": # 1 is for light mode
371+
return (None, 'black')
372+
elif str(GetConfig["ProgConfig"]['appearancemode']) == "2": # 2 is for dark mode
373+
return ('#333', "white")
374+
else:
375+
return (None, "black")
376+
except Exception as exception_reading_appearance_mode:
377+
messagebox.showerror("An ERROR has occured", f"{exception_reading_appearance_mode}")
378+
return False
379+
return False
380+
381+
382+
def closeWindowAndReturnChoice():
383+
"""
384+
Closes this window and saves the chosen value into the variable `chosen_dev`
385+
"""
386+
global chosen_dev
387+
if str(self.devchoosercombobox.get()) == getCurrentLanguage().chooser_choose_a_device: # all devices are chosen
388+
return None
389+
else:
390+
_choice = self.devchoosercombobox.get()
391+
_choice = _choice.split("\t")
392+
chosen_dev = _choice[0]
393+
print(chosen_dev)
394+
try:
395+
self.destroy()
396+
except:
397+
print("[INFO] window might have been already destroyed")
398+
return
399+
400+
401+
self.title(f"{getCurrentLanguage().choose_a_device_window_title}")
402+
self.appwidth = 605
403+
self.appheight = 257
404+
self.spawn_x = (int(self.winfo_screenwidth()) / 2) - (self.appwidth / 2)
405+
self.spawn_y = (int(self.winfo_screenheight()) / 2) - (self.appheight / 2)
406+
self.geometry(f'{self.appwidth}x{self.appheight}+{int(self.spawn_x)}+{int(self.spawn_y)}') # spawns in the middle of the screen.
407+
self.resizable(False, False)
408+
self.wm_resizable(False, False)
409+
self.configure(bg=getCurrentAppearanceMode()[0])
410+
try:
411+
self.iconbitmap(f"{application_path}\\debug.ico")
412+
except Exception as errorLoadingIconBitmap:
413+
print(f"An exception has occured while attempting to load iconbitmap for the 'Connect Phone to PC Window'\nError details are:\n\n{errorLoadingIconBitmap}")
414+
messagebox.showerror("Error", f"An exception has occured while attempting to load iconbitmap for 'connectphonetopc' window\nError details are:\n\n{errorLoadingIconBitmap}")
415+
pass
416+
417+
418+
419+
self.lbl0 = Label(self, text=getCurrentLanguage().choose_a_usb_debugging_device, font=("Arial Bold", 17), bg=getCurrentAppearanceMode()[0], fg=getCurrentAppearanceMode()[1], justify=getTextJustification())
420+
self.lbl0.pack(expand=False)
421+
self.lbl1 = Label(self, text=getCurrentLanguage().choose_a_device_info, font=("Arial", 12), bg=getCurrentAppearanceMode()[0], fg=getCurrentAppearanceMode()[1], justify=getTextJustification(), wraplength=599)
422+
self.lbl1.pack(expand=False)
423+
self.devchooser_combobox_values = [getCurrentLanguage().chooser_choose_a_device]
424+
_deviceslst:list = adb_processor.listADBDevices()
425+
for _dev in _deviceslst:
426+
self.devchooser_combobox_values.append(_dev)
427+
self.devchoosercombobox = CTkComboBox(self, width=450, values=self.devchooser_combobox_values)
428+
self.devchoosercombobox.pack(expand=False, pady=0, padx=0, ipadx=0, ipady=0, after=self.lbl1)
429+
self.continue_btn = CTkButton(self, text=getCurrentLanguage().continue_connection_window_btn, command=closeWindowAndReturnChoice)
430+
self.continue_btn.pack(expand=False, pady=15, ipadx=170, ipady=5)
431+
432+
433+
def __str__(self):
434+
return chosen_dev
435+
436+
437+
438+
340439

341440
if __name__ == '__main__':
342-
# ConnectPhoneToPCViaWiFiWindow().mainloop()
441+
# ChooseADeviceWindow().mainloop()
442+
# print(chosen_dev)
343443
# raise SystemExit(0)
344444
pass

android_cleaner/debug.ico

37.2 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)