Skip to content

Commit 78f9d8f

Browse files
committed
First end2end run with desktopapp for samsung galaxy a3
1 parent 41424d1 commit 78f9d8f

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

openandroidinstaller/openandroidinstaller.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import chunk
12
from time import sleep
23
import flet
34
from flet import (AppBar, ElevatedButton, Page, Text, View, Row, ProgressRing, Column, FilePicker, FilePickerResultEvent, icons)
@@ -18,8 +19,6 @@ def main(page: Page):
1819

1920
def confirm(e):
2021
view_num = int(page.views[-1].route) + 1
21-
#if view_num > 6:
22-
# view_num = 6
2322
page.views.clear()
2423
page.views.append(views[view_num])
2524
page.update()
@@ -37,14 +36,27 @@ def search_devices(e):
3736
output = check_output(["adb", "shell", "dumpsys", "bluetooth_manager", "|", "grep", "\'name:\'", "|", "cut", "-c9-"], stderr=STDOUT).decode()
3837
page.views[-1].controls.append(Text(f"Detected: {output}"))
3938
page.views[-1].controls.append(ElevatedButton("Confirm and continue", on_click=confirm))
39+
views.extend([
40+
get_new_view(title="Unlock the bootloader", content=[confirm_button("Turn on developer options and OEM Unlock on your phone.")], index=2),
41+
get_new_view(title="Boot into recovery", content=[confirm_button("Turn on your device and wait until its fully booted.")], index=3),
42+
get_new_view(title="Boot into recovery", content=[call_button("Reboot into bootloader", command="adb reboot download")], index=4),
43+
get_new_view(title="Boot into recovery", content=[call_button("Flash custom recovery", command="heimdall flash --no-reboot --RECOVERY recovery")], index=5),
44+
get_new_view(title="Boot into recovery", content=[confirm_button("Unplug the USB cable from your device. Manually reboot into recovery. Press the Volume Down + Power buttons for 8~10 seconds until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, hold Volume Up + Home + Power.")], index=6),
45+
get_new_view(title="Flash LineageOS", content=[confirm_button("Now tap 'Wipe'. Then tap 'Format Data' and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage.")], index=7),
46+
get_new_view(title="Flash LineageOS", content=[confirm_button("Return to the previous menu and tap 'Advanced Wipe', then select the 'Cache' and 'System' partitions and then 'Swipe to Wipe'.")], index=8),
47+
get_new_view(title="Flash LineageOS", content=[confirm_button("On the device, go back and select “Advanced”, “ADB Sideload”, then swipe to begin sideload. Then confirm here")], index=9),
48+
get_new_view(title="Flash LineageOS", content=[call_button("Flash lineageOS image. Don't remove the USB-Cable!", command="adb sideload image")], index=10),
49+
get_new_view(title="Boot into recovery", content=[call_button("Reboot into OS", command="adb reboot")], index=11),
50+
get_new_view(title="Successfully finished flashing", content=[Text("Have fun with LineageOS!")], index=12),
51+
])
4052
except:
4153
output = "No device detected!"
4254
page.views[-1].controls.append(Text(f"{output}"))
4355
page.update()
4456

4557
def call_to_phone(e, command: str):
4658
command = command.replace("recovery", recovery_path)
47-
#command = command.replace("image", pick_image_dialog.result.path)
59+
command = command.replace("image", image_path)
4860
page.views[-1].controls.append(ProgressRing())
4961
page.update()
5062
res = call(f'{command}', shell=True)
@@ -85,11 +97,15 @@ def pick_recovery_result(e: FilePickerResultEvent):
8597
# Generate the Views for the different steps
8698

8799
def confirm_button(text: str, confirm_text: str = "Confirm and continue") -> Row:
88-
return Row([
89-
Text(f"{text}"),
90-
ElevatedButton(f"{confirm_text}", on_click=confirm)
91-
])
92-
100+
words = text.split(" ")
101+
chunk_size = 10
102+
if len(words) > chunk_size:
103+
n_chunks = len(words) // chunk_size
104+
text_field = [Text(f"{' '.join(words[i*chunk_size:(i+1)*chunk_size])}") for i in range(n_chunks)]
105+
return Column(text_field + [ElevatedButton(f"{confirm_text}", on_click=confirm)])
106+
else:
107+
text_field = Text(f"{text}")
108+
return Row([text_field, ElevatedButton(f"{confirm_text}", on_click=confirm)])
93109

94110
def call_button(text: str, command: str, confirm_text: str = "Confirm and run") -> Row:
95111
return Row([
@@ -129,11 +145,6 @@ def get_new_view(title: str, index: int, content: List = []) -> View:
129145
]
130146

131147
), confirm_button("Done?")], index=1),
132-
get_new_view(title="Unlock the bootloader", content=[confirm_button("Turn on developer options and OEM Unlock on your phone.")], index=2),
133-
get_new_view(title="Boot into recovery", content=[confirm_button("Turn on your device and wait until its fully booted.")], index=3),
134-
get_new_view(title="Boot into recovery", content=[call_button("Reboot into bootloader", command="adb reboot download")], index=4),
135-
get_new_view(title="Boot into recovery", content=[call_button("Flash custom recovery", command="heimdall flash --no-reboot --RECOVERY recovery")], index=5),
136-
get_new_view(title="Continue somehow", content=[confirm_button("Turn on your device and wait until its fully booted.")], index=6),
137148
]
138149

139150
page.views.append(views[0])

0 commit comments

Comments
 (0)