diff --git a/openandroidinstaller/views/start_view.py b/openandroidinstaller/views/start_view.py index ccac31f9..200ed817 100644 --- a/openandroidinstaller/views/start_view.py +++ b/openandroidinstaller/views/start_view.py @@ -101,14 +101,15 @@ def check_bootloader_unlocked(e): """Enable skipping unlocking the bootloader if selected.""" if self.bootloader_switch.value: logger.info("Skipping bootloader unlocking.") - self.state.steps = copy.deepcopy(self.state.config.boot_recovery) - self.state.num_total_steps = len(self.state.steps) + self.state.steps = [] else: logger.info("Enabled unlocking the bootloader again.") self.state.steps = copy.deepcopy( self.state.config.unlock_bootloader - ) + copy.deepcopy(self.state.config.boot_recovery) - self.state.num_total_steps = len(self.state.steps) + ) + # if the recovery is already flashed, skip flashing it again + if self.recovery_switch.value == False: + self.state.steps += copy.deepcopy(self.state.config.boot_recovery) self.bootloader_switch = Switch( label="Bootloader is already unlocked.", @@ -118,6 +119,32 @@ def check_bootloader_unlocked(e): active_color=colors.GREEN, ) + # toggleswitch to allow skipping flashing recovery + def check_recovery_already_flashed(e): + """Enable skipping flashing recovery if selected.""" + + # manage the bootloader unlocking switch + if self.bootloader_switch.value == False: + self.state.steps = copy.deepcopy( + self.state.config.unlock_bootloader + ) + else: + self.state.steps = [] + + if self.recovery_switch.value: + logger.info("Skipping flashing recovery.") + else: + logger.info("Enabled flashing recovery again.") + self.state.steps += copy.deepcopy(self.state.config.boot_recovery) + + self.recovery_switch = Switch( + label="Custom recovery is already flashed.", + on_change=check_recovery_already_flashed, + disabled=False, + inactive_thumb_color=colors.YELLOW, + active_color=colors.GREEN, + ) + # inform the user about the device detection self.device_name = Text("", weight="bold") self.device_detection_infobox = Row( @@ -179,11 +206,12 @@ def build(self): Divider(), Markdown( """ -If you **already unlocked the bootloader** of your device, please toggle the switch below, to skip the procedure. +If you **already unlocked the bootloader** of your device or already **flashed a custom recovery**, please toggle the respective switch below, to skip the procedure. If you don't know what this means, you most likely don't need to do anything and you can just continue. """ ), Row([self.bootloader_switch]), + Row([self.recovery_switch]), Divider(), self.device_infobox, Row(