1616from loguru import logger
1717from time import sleep
1818from typing import Callable
19- from pathlib import Path
2019from functools import partial
2120
2221from flet import (
3433 ProgressBar ,
3534)
3635
37- from views import BaseView
38- from installer_config import Step
39- from app_state import AppState
40- from tooling import (
36+ from openandroidinstaller . views import BaseView
37+ from openandroidinstaller . installer_config import Step
38+ from openandroidinstaller . app_state import AppState
39+ from openandroidinstaller . tooling import (
4140 adb_reboot ,
4241 adb_reboot_bootloader ,
4342 adb_reboot_download ,
5049 fastboot_unlock_with_code ,
5150 heimdall_flash_recovery ,
5251)
53- from widgets import call_button , confirm_button , get_title , link_button
52+ from openandroidinstaller .widgets import (
53+ call_button ,
54+ confirm_button ,
55+ get_title ,
56+ link_button ,
57+ )
5458
5559
5660class StepView (BaseView ):
@@ -110,16 +114,18 @@ def check_advanced_switch(e):
110114 self .call_button = call_button (
111115 self .call_to_phone , command = self .step .command
112116 )
113- self .right_view .controls .extend ([
114- Row ([self .error_text ]),
115- Column (
116- [
117- self .advanced_switch ,
118- Row ([self .call_button , self .confirm_button ]),
119- ]
120- ),
121- Row ([self .terminal_box ])
122- ])
117+ self .right_view .controls .extend (
118+ [
119+ Row ([self .error_text ]),
120+ Column (
121+ [
122+ self .advanced_switch ,
123+ Row ([self .call_button , self .confirm_button ]),
124+ ]
125+ ),
126+ Row ([self .terminal_box ]),
127+ ]
128+ )
123129 elif self .step .type == "call_button_with_input" :
124130 self .confirm_button .disabled = True
125131 self .call_button = call_button (
@@ -135,7 +141,7 @@ def check_advanced_switch(e):
135141 Row ([self .call_button , self .confirm_button ]),
136142 ]
137143 ),
138- Row ([self .terminal_box ])
144+ Row ([self .terminal_box ]),
139145 ]
140146 )
141147 elif self .step .type == "link_button_with_confirm" :
@@ -189,13 +195,23 @@ def call_to_phone(self, e, command: str):
189195 "adb_reboot_bootloader" : adb_reboot_bootloader ,
190196 "adb_reboot_download" : adb_reboot_download ,
191197 "adb_sideload" : partial (adb_sideload , target = self .state .image_path ),
192- "adb_twrp_wipe_and_install" : partial (adb_twrp_wipe_and_install , target = self .state .image_path , config_path = self .state .config_path ),
198+ "adb_twrp_wipe_and_install" : partial (
199+ adb_twrp_wipe_and_install ,
200+ target = self .state .image_path ,
201+ config_path = self .state .config_path ,
202+ ),
193203 "fastboot_unlock" : fastboot_unlock ,
194- "fastboot_unlock_with_code" : partial (fastboot_unlock_with_code , unlock_code = self .inputtext .value ),
204+ "fastboot_unlock_with_code" : partial (
205+ fastboot_unlock_with_code , unlock_code = self .inputtext .value
206+ ),
195207 "fastboot_oem_unlock" : fastboot_oem_unlock ,
196- "fastboot_flash_recovery" : partial (fastboot_flash_recovery , recovery = self .state .recovery_path ),
208+ "fastboot_flash_recovery" : partial (
209+ fastboot_flash_recovery , recovery = self .state .recovery_path
210+ ),
197211 "fastboot_reboot" : fastboot_reboot ,
198- "heimdall_flash_recovery" : partial (heimdall_flash_recovery , recovery = self .state .recovery_path ),
212+ "heimdall_flash_recovery" : partial (
213+ heimdall_flash_recovery , recovery = self .state .recovery_path
214+ ),
199215 }
200216
201217 # run the right command
@@ -229,12 +245,11 @@ def call_to_phone(self, e, command: str):
229245
230246
231247class TerminalBox (UserControl ):
232-
233248 def __init__ (self , expand : bool = True ):
234249 super ().__init__ (expand = expand )
235250
236251 def build (self ):
237- self .box = Container (
252+ self ._box = Container (
238253 content = Column (scroll = "auto" , expand = True ),
239254 margin = 10 ,
240255 padding = 10 ,
@@ -243,28 +258,30 @@ def build(self):
243258 height = 300 ,
244259 border_radius = 2 ,
245260 expand = True ,
246- visible = False
261+ visible = False ,
247262 )
248- return self .box
263+ return self ._box
249264
250265 def write_line (self , line : str ):
251266 """
252267 Write the line to the window box and update.
253-
268+
254269 Ignores empty lines.
255270 """
256271 if (type (line ) == str ) and line .strip ():
257- self .box .content .controls .append (
258- Text (f">{ line .strip ()} " , selectable = True )
259- )
260- self .box .update ()
261-
272+ self ._box .content .controls .append (Text (f">{ line .strip ()} " , selectable = True ))
273+ self .update ()
274+
262275 def toggle_visibility (self ):
263276 """Toogle the visibility of the terminal box."""
264- self .box .visible = not self .box .visible
265- self .box . update ()
277+ self ._box .visible = not self ._box .visible
278+ self .update ()
266279
267280 def clear (self ):
268281 """Clear terminal output."""
269- self .box .content .controls = []
270- self .box .update ()
282+ self ._box .content .controls = []
283+ self .update ()
284+
285+ def update (self ):
286+ """Update the view."""
287+ self ._box .update ()
0 commit comments