Skip to content

Commit c5b6656

Browse files
committed
Restructure welcome page
1 parent 6a3d0e0 commit c5b6656

3 files changed

Lines changed: 72 additions & 31 deletions

File tree

openandroidinstaller/openandroidinstaller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
logger.add("openandroidinstaller.log")
4646

4747
# Toggle to True for development purposes
48-
DEVELOPMENT = True
49-
DEVELOPMENT_CONFIG = "z3" # "a3y17lte" # "sargo"
48+
DEVELOPMENT = False
49+
DEVELOPMENT_CONFIG = "sargo" # "a3y17lte" # "sargo"
5050

5151

5252
PLATFORM = sys.platform
@@ -144,7 +144,7 @@ def main(page: Page):
144144
logger.info(100 * "-")
145145
# Configure the application base page
146146
page.title = "OpenAndroidInstaller"
147-
page.window_height = 780
147+
page.window_height = 820
148148
page.window_width = int(1.77 * page.window_height)
149149
page.window_top = 100
150150
page.window_left = 120

openandroidinstaller/tool_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) ->
159159
if (type(line) == bool) and not line:
160160
logger.error(f"Wiping {partition} failed.")
161161
# TODO: if this fails, a fix can be to just sideload something and then adb reboot
162-
for line in run_command("adb", ["sideload", str(config_path.parent.parent) + "/helper.txt"], bin_path):
162+
for line in run_command(
163+
"adb",
164+
["sideload", str(config_path.parent.parent) + "/helper.txt"],
165+
bin_path,
166+
):
163167
yield line
164168
sleep(1)
165169
if (type(line) == bool) and not line:

openandroidinstaller/views.py

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,8 @@ def build(self):
234234
disabled=True,
235235
expand=True,
236236
)
237-
self.device_name = Text("")
238-
self.config_found_box = Checkbox(
239-
label="Device config found:",
240-
value=False,
241-
disabled=True,
242-
label_position="left",
243-
)
237+
238+
# dialog box to help with developer options
244239
self.dlg_help_developer_options = AlertDialog(
245240
modal=True,
246241
title=Text("How to enable developer options and OEM unlocking"),
@@ -297,6 +292,12 @@ def check_advanced_box(e):
297292
disabled=False,
298293
)
299294

295+
# inform the user about the device detection
296+
self.device_name = Text("", weight="bold")
297+
self.device_detection_infobox = Row(
298+
[Text("Detected device:"), self.device_name]
299+
)
300+
300301
# build up the main view
301302
self.right_view.controls.extend(
302303
[
@@ -305,32 +306,48 @@ def check_advanced_box(e):
305306
"We will walk you through the installation process nice and easy."
306307
),
307308
Divider(),
308-
Text(
309-
"Before you continue, make sure your devices is on the latest system update. Also make sure you have a backup of all your important data, since this procedure will erase all data from the phone. Please store the backup not on the phone! Note, that vendor specific back-ups might not work on LineageOS!"
309+
Markdown(
310+
"""
311+
Before you continue, make sure
312+
- your devices is on the latest system update.
313+
- you have a backup of all your important data, since this procedure will **erase all data from the phone**.
314+
- to not store the backup not the phone!
315+
316+
Please note, that vendor specific back-ups will most likely not work on LineageOS!
317+
"""
310318
),
311319
Divider(),
312-
Text(
313-
"Enable USB debugging and OEM unlocking on your device by enabling developer options."
320+
Markdown(
321+
"""
322+
To get started you need to
323+
- **enable developer options** on your device
324+
- and then **enable USB debugging** and **OEM unlocking** in the developer options.
325+
"""
314326
),
315327
Row(
316328
[
317329
ElevatedButton(
318-
"How do I enable developer mode?",
330+
"How do I enable developer options?",
319331
on_click=self.open_developer_options_dlg,
320332
expand=True,
321333
tooltip="Get help to enable developer options and OEM unlocking.",
322334
)
323335
]
324336
),
325337
Divider(),
326-
Text(
327-
"Now connect your device to this computer via USB and allow USB debugging in the pop-up on your phone. Then press 'Search device'. When everything works correctly you should see your device name here."
338+
Markdown(
339+
"""
340+
Now
341+
- **connect your device to this computer via USB** and
342+
- **allow USB debugging in the pop-up on your phone**.
343+
- Then **press the button 'Search device'**.
344+
When everything works correctly you should see your device name here and you can continue.
345+
"""
328346
),
329347
Divider(),
330348
Column(
331349
[
332-
Row([Text("Detected device:"), self.device_name]),
333-
self.config_found_box,
350+
self.device_detection_infobox,
334351
Row([self.bootloader_checkbox, self.advanced_checkbox]),
335352
]
336353
),
@@ -382,32 +399,40 @@ def search_devices(self, e):
382399
if device_code:
383400
device_code = device_code_mapping.get(device_code, device_code)
384401
self.device_name.value = device_code
402+
self.device_name.color = colors.BLACK
385403
else:
386404
logger.info("No device detected! Connect to USB and try again.")
387405
self.device_name.value = (
388406
"No device detected! Connect to USB and try again."
389407
)
408+
self.device_name.color = colors.RED
390409

391410
# load the config, if a device is detected
392411
if device_code:
393412
self.device_name.value = device_code
394413
# load config from file
395414
self.state.load_config(device_code)
396-
device_name = self.state.config.metadata.get(
397-
"devicename", "No device name in config."
398-
)
415+
if self.state.config:
416+
device_name = self.state.config.metadata.get(
417+
"devicename", "No device name in config."
418+
)
419+
else:
420+
device_name = None
399421

400422
# display success in the application
401423
if device_name:
402-
self.config_found_box.value = True
403424
self.continue_button.disabled = False
404425
self.bootloader_checkbox.disabled = False
405426
# overwrite the text field with the real name from the config
406427
self.device_name.value = f"{device_name} (code: {device_code})"
428+
self.device_name.color = colors.GREEN
407429
else:
408430
# failed to load config
409431
logger.error(f"Failed to load config for {device_code}.")
410-
self.device_name.value = f"Failed to load config for {device_code}."
432+
self.device_name.value = (
433+
f"Failed to load config for device with code {device_code}."
434+
)
435+
self.device_name.color = colors.RED
411436
self.view.update()
412437

413438

@@ -705,15 +730,19 @@ def call_to_phone(self, e, command: str):
705730
if command in cmd_mapping.keys():
706731
for line in cmd_mapping.get(command)(bin_path=self.state.bin_path):
707732
if self.state.advanced and (type(line) == str) and line.strip():
708-
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
733+
self.terminal_box.content.controls.append(
734+
Text(f">{line.strip()}", selectable=True)
735+
)
709736
self.terminal_box.update()
710737
success = line
711738
elif command == "adb_sideload":
712739
for line in adb_sideload(
713740
bin_path=self.state.bin_path, target=self.state.image_path
714741
):
715742
if self.state.advanced and (type(line) == str) and line.strip():
716-
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
743+
self.terminal_box.content.controls.append(
744+
Text(f">{line.strip()}", selectable=True)
745+
)
717746
self.terminal_box.update()
718747
success = line
719748
elif command == "adb_twrp_wipe_and_install":
@@ -725,31 +754,39 @@ def call_to_phone(self, e, command: str):
725754
),
726755
):
727756
if self.state.advanced and (type(line) == str) and line.strip():
728-
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
757+
self.terminal_box.content.controls.append(
758+
Text(f">{line.strip()}", selectable=True)
759+
)
729760
self.terminal_box.update()
730761
success = line
731762
elif command == "fastboot_flash_recovery":
732763
for line in fastboot_flash_recovery(
733764
bin_path=self.state.bin_path, recovery=self.state.recovery_path
734765
):
735766
if self.state.advanced and (type(line) == str) and line.strip():
736-
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
767+
self.terminal_box.content.controls.append(
768+
Text(f">{line.strip()}", selectable=True)
769+
)
737770
self.terminal_box.update()
738771
success = line
739772
elif command == "fastboot_unlock_with_code":
740773
for line in fastboot_unlock_with_code(
741774
bin_path=self.state.bin_path, unlock_code=self.inputtext.value
742775
):
743776
if self.state.advanced and (type(line) == str) and line.strip():
744-
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
777+
self.terminal_box.content.controls.append(
778+
Text(f">{line.strip()}", selectable=True)
779+
)
745780
self.terminal_box.update()
746781
success = line
747782
elif command == "heimdall_flash_recovery":
748783
for line in heimdall_flash_recovery(
749784
bin_path=self.state.bin_path, recovery=self.state.recovery_path
750785
):
751786
if self.state.advanced and (type(line) == str) and line.strip():
752-
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
787+
self.terminal_box.content.controls.append(
788+
Text(f">{line.strip()}", selectable=True)
789+
)
753790
self.terminal_box.update()
754791
success = line
755792
else:

0 commit comments

Comments
 (0)