2222from typing import Callable , Optional
2323
2424import flet
25- from flet import (AlertDialog , AppBar , Banner , Checkbox , Column , Container ,
26- Divider , ElevatedButton , FilePicker , FilePickerResultEvent ,
27- FilledButton , Icon , Image , Page , ProgressBar , ProgressRing ,
28- Row , Text , TextButton , TextField , UserControl , FloatingActionButton ,
29- VerticalDivider , colors , icons )
25+ from flet import (
26+ AlertDialog ,
27+ AppBar ,
28+ Banner ,
29+ Checkbox ,
30+ Column ,
31+ Container ,
32+ Divider ,
33+ ElevatedButton ,
34+ FilePicker ,
35+ FilePickerResultEvent ,
36+ FilledButton ,
37+ Icon ,
38+ Image ,
39+ Page ,
40+ ProgressBar ,
41+ ProgressRing ,
42+ Row ,
43+ Text ,
44+ TextButton ,
45+ TextField ,
46+ UserControl ,
47+ FloatingActionButton ,
48+ VerticalDivider ,
49+ colors ,
50+ icons ,
51+ )
3052from installer_config import InstallerConfig , Step , _load_config
3153from loguru import logger
3254from tool_utils import call_tool_with_command , search_device
3355from utils import AppState , get_download_link , image_recovery_works_with_device
3456from widgets import call_button , confirm_button , get_title , link_button
3557
3658# Toggle to True for development purposes
37- DEVELOPMENT = True
59+ DEVELOPMENT = False
3860DEVELOPMENT_CONFIG = "yuga" # "a3y17lte" # "sargo"
3961
4062
4163PLATFORM = sys .platform
4264# Define asset paths
43- CONFIG_PATH = Path (__file__ ).parent .joinpath (Path (os .sep .join (["assets" , "configs" ]))).resolve ()
44- IMAGE_PATH = Path (__file__ ).parent .joinpath (Path (os .sep .join (["assets" , "imgs" ]))).resolve ()
65+ CONFIG_PATH = (
66+ Path (__file__ ).parent .joinpath (Path (os .sep .join (["assets" , "configs" ]))).resolve ()
67+ )
68+ IMAGE_PATH = (
69+ Path (__file__ ).parent .joinpath (Path (os .sep .join (["assets" , "imgs" ]))).resolve ()
70+ )
4571BIN_PATH = Path (__file__ ).parent .joinpath (Path ("bin" )).resolve ()
4672
4773
@@ -117,7 +143,9 @@ def check_bootloader_unlocked(e):
117143 self .state .num_total_steps = len (self .state .steps )
118144
119145 self .bootloader_checkbox = Checkbox (
120- label = "Bootloader is already unlocked." , on_change = check_bootloader_unlocked , disabled = True
146+ label = "Bootloader is already unlocked." ,
147+ on_change = check_bootloader_unlocked ,
148+ disabled = True ,
121149 )
122150
123151 # build up the main view
@@ -325,7 +353,9 @@ def build(self):
325353 ),
326354 self .selected_recovery ,
327355 Divider (),
328- Text ("If you selected both files and they work for your device you can continue." ),
356+ Text (
357+ "If you selected both files and they work for your device you can continue."
358+ ),
329359 self .info_field ,
330360 Row ([self .confirm_button ]),
331361 ]
@@ -335,12 +365,20 @@ def build(self):
335365 def enable_button_if_ready (self , e ):
336366 """Enable the confirm button if both files have been selected."""
337367
338- if (".zip" in self .selected_image .value ) and (".img" in self .selected_recovery .value ):
368+ if (".zip" in self .selected_image .value ) and (
369+ ".img" in self .selected_recovery .value
370+ ):
339371 if not image_recovery_works_with_device (
340- device_code = self .state .config .metadata .get ("devicecode" ), image_path = self .state .image_path
341- ):
372+ device_code = self .state .config .metadata .get ("devicecode" ),
373+ image_path = self .state .image_path ,
374+ recovery_path = self .state .recovery_path ,
375+ ):
342376 # if image and recovery work for device allow to move on, otherwise display message
343- self .info_field .controls .append (Text ("Image and recovery don't work with the device. Please select different ones." ))
377+ self .info_field .controls .append (
378+ Text (
379+ "Image and recovery don't work with the device. Please select different ones."
380+ )
381+ )
344382 self .right_view .update ()
345383 return
346384 self .info_field .controls = []
@@ -612,15 +650,17 @@ def main(page: Page):
612650 logger .info (f"Running OpenAndroidInstaller on { PLATFORM } " )
613651 # Configure the application base page
614652 page .title = "OpenAndroidInstaller"
615- page .window_height = 780
653+ page .window_height = 780
616654 page .window_width = int (1.77 * page .window_height )
617655 page .window_top = 100
618656 page .window_left = 120
619657 page .scroll = "adaptive"
620658 page .horizontal_alignment = "center"
621659
622660 # header
623- image_path = Path (__file__ ).parent .joinpath (Path (os .sep .join (["assets" , "logo-192x192.png" ])))
661+ image_path = Path (__file__ ).parent .joinpath (
662+ Path (os .sep .join (["assets" , "logo-192x192.png" ]))
663+ )
624664 page .appbar = AppBar (
625665 leading = Image (src = image_path , height = 40 , width = 40 , border_radius = 40 ),
626666 leading_width = 56 ,
0 commit comments