1616from loguru import logger
1717from time import sleep
1818from typing import Callable
19+ from pathlib import Path
1920
2021from flet import (
2122 Column ,
3334
3435from views import BaseView
3536from app_state import AppState
36- from tooling import adb_twrp_install_addons
37+ from tooling import adb_twrp_install_addon , adb_twrp_finish_install_addons
3738from widgets import (
3839 confirm_button ,
3940 get_title ,
@@ -55,6 +56,8 @@ def build(self):
5556 """Create the content of the view."""
5657 # error text
5758 self .error_text = Text ("" , color = colors .RED )
59+ # text field to inform about the currently installing addon
60+ self .addon_info_text = Text ("" )
5861
5962 # switch to enable advanced output - here it means show terminal input/output in tool
6063 def check_advanced_switch (e ):
@@ -112,8 +115,9 @@ def check_advanced_switch(e):
112115 # build the view
113116 self .right_view .controls .extend (
114117 [
115- Row ([self .error_text ]),
118+ Row ([self .addon_info_text ]),
116119 Row ([self .progress_indicator ]),
120+ Row ([self .error_text ]),
117121 Column (
118122 [
119123 self .advanced_switch ,
@@ -150,24 +154,38 @@ def run_install_addons(self, e):
150154 # disable the call button while the command is running
151155 self .install_button .disabled = True
152156 self .error_text .value = ""
153- # reset the progress indicators
154- self .progress_indicator .clear ()
157+ self .addon_info_text .value = ""
155158 # reset terminal output
156159 if self .state .advanced :
157160 self .terminal_box .clear ()
158161 self .right_view .update ()
159162
160163 # run the install script
161- for line in adb_twrp_install_addons (
162- addons = self .state .addon_paths ,
164+ for addon_num , addon_path in enumerate (self .state .addon_paths ):
165+ # reset the progress indicators
166+ self .progress_indicator .clear ()
167+ # inform about the currently installed addon
168+ self .addon_info_text .value = f"{ addon_num + 1 } /{ len (self .state .addon_paths )} : Installing { Path (addon_path ).name } ..."
169+ self .right_view .update ()
170+
171+ # install one addon at the time
172+ for line in adb_twrp_install_addon (
173+ addon_path = addon_path ,
174+ bin_path = self .state .bin_path ,
175+ is_ab = self .state .config .is_ab ,
176+ ):
177+ # write the line to advanced output terminal
178+ self .terminal_box .write_line (line )
179+ # in case the install command is run, we want to update the progress bar
180+ self .progress_indicator .display_progress_bar (line )
181+ self .progress_indicator .update ()
182+
183+ # reboot after installing the addons; here we might switch partitions on ab-partitioned devices
184+ for line in adb_twrp_finish_install_addons (
163185 bin_path = self .state .bin_path ,
164186 is_ab = self .state .config .is_ab ,
165187 ):
166- # write the line to advanced output terminal
167188 self .terminal_box .write_line (line )
168- # in case the install command is run, we want to update the progress bar
169- self .progress_indicator .display_progress_bar (line )
170- self .progress_indicator .update ()
171189 success = line # the last element of the iterable is a boolean encoding success/failure
172190
173191 # update the view accordingly
0 commit comments