Skip to content

Commit 243d910

Browse files
committed
Update config for google pixel 3a; improve rendering of views; add some dirty testing mode for now; fix the progressbar
1 parent caa02b6 commit 243d910

File tree

4 files changed

+129
-61
lines changed

4 files changed

+129
-61
lines changed
Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,62 @@
11
steps:
22
- title: "Unlock the bootloader"
33
type: confirm_button
4-
content: "Turn on your device and wait until its fully booted."
4+
content: "As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone who to start and run an operating system (like Android). Your device should be turned on."
55
- title: "Unlock the bootloader"
66
type: call_button
7-
content: "Press 'Confirm' to reboot into the bootloader."
7+
content: "Press 'Confirm and run' to reboot into the bootloader."
88
command: "adb reboot bootloader"
99
- title: "Unlock the bootloader"
1010
type: confirm_button
11-
content: "Select 'Restart bootloader' on your smartphone screen by pressing the volume button and the confirm by pushing the power button. Then press 'Confirm' here."
11+
content: "Select 'Restart bootloader' on your smartphone screen by pressing the volume button and the confirm by pushing the power button. Then press 'Confirm and continue' here."
1212
- title: "Unlock the bootloader"
1313
type: call_button
14-
content: "Unlock the bootloader now:"
14+
content: "In this step you actually unlock the bootloader. Just press 'Confirm and run' here. Once it's done, press continue here."
1515
command: "fastboot flashing unlock"
1616
allow_skip: True
1717
- title: "Unlock the bootloader"
1818
type: confirm_button
1919
content: "At this point the device may display on-screen prompts which will require interaction to continue the process of unlocking the bootloader. Please take whatever actions the device asks you to to proceed."
2020
- title: "Unlock the bootloader"
2121
type: call_button
22-
content: "Reboot the phone"
22+
content: "To finish the unlocking, the phone needs to reboot. Just press 'Confirm and run' here to reboot. Then continue."
2323
command: "fastboot reboot"
2424
- title: "Unlock the bootloader"
2525
type: confirm_button
2626
content: "The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue."
27-
- title: "Flash custom recovery"
27+
- title: "Flash a custom recovery"
28+
type: confirm_button
29+
content: "Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating, adapting and repairing of the operating system."
30+
- title: "Flash a custom recovery"
2831
type: call_button
29-
content: "Once the device is fully booted, reboot into bootloader"
32+
content: "Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue."
3033
command: "adb reboot bootloader"
31-
- title: "Flash custom recovery"
34+
- title: "Flash a custom recovery"
3235
type: confirm_button
33-
content: "Select 'Restart bootloader' on your smartphone screen. Then confirm"
34-
- title: "Flash custom recovery"
36+
content: "Select 'Restart bootloader' on your smartphone screen. Then confirm to continue."
37+
- title: "Flash a custom recovery"
3538
type: call_button
36-
content: "Flash custom recovery (temporarily)"
39+
content: "Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue."
3740
command: "fastboot flash boot <recovery>"
41+
- title: "Flash LineageOS"
42+
type: confirm_button
43+
content: "In this step, you finally flash LineageOS. Confirm to continue."
3844
- title: "Flash LineageOS"
3945
type: confirm_button
40-
content: "Select 'Recovery Mode' on your smartphone screen. Then confirm"
46+
content: "Select 'Recovery Mode' on your smartphone screen and press the Start-Button to confirm. Then confirm here."
4147
- title: "Flash LineageOS"
4248
type: confirm_button
43-
content: "Now tap Factory Reset, then Format data / factory reset and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage, as well as format your cache partition (if you have one)."
49+
content: "Now tap Factory Reset, then Format data / Factory reset on your phone screen and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage, as well as format your cache partition (if you have one)."
4450
- title: "Flash LineageOS"
4551
type: confirm_button
46-
content: "Return to the main menu."
52+
content: "Return to the main menu on the phone."
4753
- title: "Flash LineageOS"
4854
type: confirm_button
49-
content: "On the device, select “Apply Update”, then “Apply from ADB” to begin sideload. Then confirm here"
55+
content: "On the device, select “Apply Update”, then “Apply from ADB” to begin sideload. Then confirm here."
5056
- title: "Flash LineageOS"
5157
type: call_button
52-
content: "Flash lineageOS image. Don't remove the USB-Cable!"
58+
content: "Now it's time to flash the LineageOS image. Don't remove the USB-Cable and press 'Confirm and run' to start! Confirm after it's done."
5359
command: "adb sideload <image>"
5460
- title: "Flash LineageOS"
5561
type: confirm_button
56-
content: "Flashing finished. Now press 'back' (arrow) and then 'Reboot system now' to finish the installation."
57-
- title: "Successfully finished flashing"
58-
type: text
59-
content: "Have fun with LineageOS!"
62+
content: "Flashing finished. Now press 'back' (arrow) and then 'Reboot system now' on the phone screen to finish the installation."

openandroidinstaller/assets/configs/Samsung Galaxy A3 2017.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ steps:
2121
content: "Return to the previous menu and tap 'Advanced Wipe', then select the 'Cache' and 'System' partitions and then 'Swipe to Wipe'."
2222
- title: "Flash LineageOS"
2323
type: confirm_button
24-
content: "Now connect the phone to the computer again with the USB-cable. On the device, go back and select “Advanced”, “ADB Sideload”, then swipe to begin sideload. Then confirm here"
24+
content: "Now connect the phone to the computer again with the USB-cable. On the device, go back and select “Advanced”, “ADB Sideload”, then swipe to begin sideload. Then confirm here."
2525
- title: "Flash LineageOS"
2626
type: call_button
2727
content: "Flash lineageOS image. Don't remove the USB-Cable!"

openandroidinstaller/openandroidinstaller.py

Lines changed: 86 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,47 @@
11
"""Main app code for openAndroidInstaller."""
22

3-
43
from ctypes import alignment
54
import webbrowser
6-
from functools import partial
75
from os import path
86
from subprocess import STDOUT, CalledProcessError, call, check_output
97
from time import sleep
10-
from turtle import width
11-
from typing import Callable, List
8+
from typing import Callable
129

1310
import flet
14-
from flet import (AppBar, Banner, Checkbox, Column, Container, Divider,
15-
ElevatedButton, FilePicker, FilePickerResultEvent, Icon,
16-
Image, Page, ProgressBar, ProgressRing, Row, Text,
17-
TextButton, TextField, UserControl, VerticalDivider, colors, FilledButton,
18-
AlertDialog,
19-
icons)
11+
from flet import (
12+
AppBar,
13+
Banner,
14+
Checkbox,
15+
Column,
16+
Container,
17+
Divider,
18+
ElevatedButton,
19+
FilePicker,
20+
FilePickerResultEvent,
21+
Icon,
22+
Image,
23+
Page,
24+
ProgressBar,
25+
ProgressRing,
26+
Row,
27+
Text,
28+
TextButton,
29+
TextField,
30+
UserControl,
31+
VerticalDivider,
32+
colors,
33+
FilledButton,
34+
AlertDialog,
35+
icons,
36+
)
2037
from installer_config import InstallerConfig, Step
2138
from widgets import call_button, confirm_button, get_title
2239

40+
# Toggle to True for development purposes
41+
DEVELOPMENT = False
42+
DEVELOPMENT_CONFIG = "Pixel 3a"
43+
44+
2345
CONFIG_PATH = path.abspath(path.join(path.dirname(__file__), "assets/configs/"))
2446
IMAGE_PATH = path.abspath(path.join(path.dirname(__file__), "assets/imgs/"))
2547

@@ -29,7 +51,10 @@ def __init__(self, image: str = "placeholder.png"):
2951
super().__init__()
3052
self.right_view = Column(expand=True)
3153
self.left_view = Column(
32-
width=480, controls=[Image(src=IMAGE_PATH + "/" + image)], expand=True, horizontal_alignment="center",
54+
width=480,
55+
controls=[Image(src=IMAGE_PATH + "/" + image)],
56+
expand=True,
57+
horizontal_alignment="center",
3358
)
3459
# main view row
3560
self.view = Row(
@@ -63,7 +88,9 @@ def build(self):
6388
self.dlg_help_developer_options = AlertDialog(
6489
modal=True,
6590
title=Text("How to enable developer options and OEM unlocking"),
66-
content=Text("To do this, tap seven times on the build number in the System-Menu in Settings. Then in developer options, toggle OEM unlocking and USB-Debugging."),
91+
content=Text(
92+
"To do this, tap seven times on the build number in the System-Menu in Settings. Then in developer options, toggle OEM unlocking and USB-Debugging."
93+
),
6794
actions=[
6895
TextButton("Close", on_click=self.close_developer_options_dlg),
6996
],
@@ -77,13 +104,22 @@ def build(self):
77104
),
78105
Divider(),
79106
Text(
80-
"Before you continue, make sure your devices is on the latest system update."
107+
"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 on the phone, since this procedure will erase all data from the phone. Note, that vendor specific back-ups might not work on LineageOS!"
81108
),
82109
Divider(),
83110
Text(
84111
"Enable USB debugging and OEM unlocking on your device by enabling developer options."
85112
),
86-
Row([FilledButton("How do I enable developer mode?", on_click=self.open_developer_options_dlg, expand=True, tooltip="Get help to enable developer options and OEM unlocking.")]),
113+
Row(
114+
[
115+
FilledButton(
116+
"How do I enable developer mode?",
117+
on_click=self.open_developer_options_dlg,
118+
expand=True,
119+
tooltip="Get help to enable developer options and OEM unlocking.",
120+
)
121+
]
122+
),
87123
Divider(),
88124
Text(
89125
"Now connect your device to this computer via USB, then press 'Search device'."
@@ -102,7 +138,7 @@ def build(self):
102138
on_click=self.search_devices,
103139
icon=icons.PHONE_ANDROID,
104140
expand=True,
105-
tooltip="Search for a connected device."
141+
tooltip="Search for a connected device.",
106142
),
107143
self.continue_button,
108144
],
@@ -114,11 +150,10 @@ def build(self):
114150

115151
def open_developer_options_dlg(self, e):
116152
"""Open the dialog for help to developer mode."""
117-
self.page.dialog = self.dlg_help_developer_options
153+
self.page.dialog = self.dlg_help_developer_options
118154
self.dlg_help_developer_options.open = True
119155
self.page.update()
120156

121-
122157
def close_developer_options_dlg(self, e):
123158
"""Close the dialog for help to developer mode."""
124159
self.dlg_help_developer_options.open = False
@@ -154,7 +189,16 @@ def search_devices(self, e):
154189
# select a new path and load again
155190
pass
156191
except CalledProcessError:
157-
self.device_name.value = "No device detected! Connect to USB and try again."
192+
if DEVELOPMENT:
193+
path = f"{CONFIG_PATH}/{DEVELOPMENT_CONFIG}.yaml"
194+
load_config_success = self.load_config(path)
195+
if load_config_success:
196+
self.config_found_box.value = True
197+
self.continue_button.disabled = False
198+
else:
199+
self.device_name.value = (
200+
"No device detected! Connect to USB and try again."
201+
)
158202
self.view.update()
159203

160204

@@ -235,14 +279,27 @@ def enable_button_if_ready(self, e):
235279
else:
236280
self.confirm_button.disabled = True
237281

282+
238283
class SuccessView(BaseView):
239-
def __init__(self, page: Page):
284+
def __init__(self, progressbar: ProgressBar):
240285
super().__init__(image="success.png")
286+
self.progressbar = progressbar
241287

242-
def build(self, ):
288+
def build(
289+
self,
290+
):
243291
self.right_view.controls = [
244292
get_title("Installation completed successfully!"),
245-
Row([ElevatedButton("Finish and close", expand=True, on_click=lambda _: self.page.window_close())])
293+
self.progressbar,
294+
Row(
295+
[
296+
ElevatedButton(
297+
"Finish and close",
298+
expand=True,
299+
on_click=lambda _: self.page.window_close(),
300+
)
301+
]
302+
),
246303
]
247304
return self.view
248305

@@ -276,9 +333,7 @@ def __init__(self, page: Page):
276333

277334
# create default starter views
278335
welcome = WelcomeView(
279-
on_confirm=self.confirm,
280-
load_config=self.load_config,
281-
page=self.page
336+
on_confirm=self.confirm, load_config=self.load_config, page=self.page
282337
)
283338
select_files = SelectFilesView(
284339
on_confirm=self.confirm,
@@ -291,9 +346,9 @@ def __init__(self, page: Page):
291346
# ordered to allow for pop
292347
self.default_views = [select_files, welcome]
293348
# create the final success view
294-
self.final_view = SuccessView(page)
349+
self.final_view = SuccessView(progressbar=self.progress_bar)
295350
# keep track of the number of steps
296-
self.num_steps = len(self.default_views)
351+
self.num_steps = 2
297352

298353
def build(self):
299354
self.view.controls.append(self.default_views.pop())
@@ -305,9 +360,7 @@ def confirm(self, e):
305360
self.view.controls = []
306361
# if a config is loaded, display a progress bar
307362
if self.config:
308-
self.progress_bar.value = (self.num_steps - 1) / (
309-
len(self.config.steps) + 2
310-
) # don't show on the first step
363+
self.progress_bar.value = (self.num_steps - 1) / (self.num_total_steps + 2) # don't show on the first step
311364
self.num_steps += 1 # increase the step counter
312365
# if there are default views left, display them first
313366
if self.default_views:
@@ -332,6 +385,7 @@ def load_config(self, path: str):
332385
"""Function to load a config file from path."""
333386
try:
334387
self.config = InstallerConfig.from_file(path)
388+
self.num_total_steps = len(self.config.steps)
335389
return True
336390
except FileNotFoundError:
337391
return False
@@ -398,7 +452,7 @@ def build(self):
398452
raise Exception(f"Unknown step type: {self.step.type}")
399453

400454
# if skipping is allowed add a button to the view
401-
if self.step.allow_skip:
455+
if self.step.allow_skip or DEVELOPMENT:
402456
self.right_view.controls.append(
403457
confirm_button("Already done?", self.on_confirm, confirm_text="Skip")
404458
)
@@ -431,8 +485,8 @@ def call_to_phone(self, e, command: str):
431485
def main(page: Page):
432486
# Configure the application base page
433487
page.title = "OpenAndroidInstaller"
434-
page.window_width = 1080
435488
page.window_height = 720
489+
page.window_width = int(1.5 * page.window_height)
436490
page.window_top = 100
437491
page.window_left = 720
438492
page.scroll = "adaptive"
@@ -481,7 +535,7 @@ def close_banner(e):
481535
],
482536
)
483537
# TODO: disable the banner for now
484-
#page.banner.open = True
538+
# page.banner.open = True
485539

486540
page.update()
487541

openandroidinstaller/widgets.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from os import path
44
from typing import Callable
55

6-
from flet import (Column, Container, ElevatedButton, Image, Row, Text,
7-
alignment, icons)
6+
from flet import Column, Container, ElevatedButton, Image, Row, Text, alignment, icons
87

98

109
def get_title(title: str):
@@ -32,10 +31,15 @@ def confirm_button(
3231
return Column(
3332
[
3433
Text(f"{text}"),
35-
ElevatedButton(
36-
f"{confirm_text}",
37-
on_click=confirm_func,
38-
icon=icons.NEXT_PLAN_OUTLINED,
34+
Row(
35+
[
36+
ElevatedButton(
37+
f"{confirm_text}",
38+
on_click=confirm_func,
39+
icon=icons.NEXT_PLAN_OUTLINED,
40+
expand=True,
41+
)
42+
]
3943
),
4044
],
4145
horizontal_alignment="center",
@@ -48,8 +52,15 @@ def call_button(
4852
return Column(
4953
[
5054
Text(f"{text}"),
51-
ElevatedButton(
52-
f"{confirm_text}", on_click=partial(call_func, command=command)
55+
Row(
56+
[
57+
ElevatedButton(
58+
f"{confirm_text}",
59+
on_click=partial(call_func, command=command),
60+
expand=True,
61+
icon=icons.DIRECTIONS_RUN_OUTLINED,
62+
)
63+
]
5364
),
5465
],
5566
horizontal_alignment="center",

0 commit comments

Comments
 (0)