Skip to content

Commit 13c85be

Browse files
committed
Improve the code of the notes generation a bit
1 parent 0bd2ccc commit 13c85be

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

openandroidinstaller/views/select_view.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,8 @@ def build(self):
179179
self.additional_image_selection = Column()
180180

181181
# Device specific notes
182-
notes = ""
183-
if "brand" in self.state.config.metadata and (
184-
self.state.config.metadata["brand"] == "xiaomi"
185-
or self.state.config.metadata["brand"] == "poco"
186-
):
187-
notes += "- If something goes wrong, you can reinstall MiUI here :\n<https://xiaomifirmwareupdater.com/miui/lavender/>\n\n"
188-
if (
189-
"untested" in self.state.config.metadata
190-
and self.state.config.metadata["untested"] == True
191-
):
192-
notes += "- **This device has never been tested with OpenAndroidInstaller.** The installation can go wrong. You may have to finish the installation process with command line. If you test, please report the result on GitHub.\n\n"
193-
if "notes" in self.state.config.metadata:
194-
for note in self.state.config.metadata["notes"]:
195-
notes += "- " + note + "\n\n"
196-
if notes != "":
182+
notes = self.get_notes()
183+
if notes:
197184
self.right_view.controls.extend(
198185
[
199186
Text(
@@ -202,9 +189,10 @@ def build(self):
202189
color=colors.RED,
203190
weight="bold",
204191
),
205-
Markdown(f"""{notes}"""),
192+
Markdown(notes),
206193
]
207194
)
195+
208196
# if there is an available download, show the button to the page
209197
if self.download_link:
210198
twrp_download_link = f"https://dl.twrp.me/{self.state.config.twrp_link if self.state.config.twrp_link else self.state.config.device_code}"
@@ -300,6 +288,27 @@ def build(self):
300288
)
301289
return self.view
302290

291+
def get_notes(self) -> str:
292+
"""Prepare and get notes for the specific device from config."""
293+
notes = []
294+
295+
brand = self.state.config.metadata.get("brand", "")
296+
if brand in ["xiaomi", "poco"]:
297+
notes.append(
298+
f"- If something goes wrong, you can reinstall MiUI here:\n<https://xiaomifirmwareupdater.com/miui/{self.state.config.device_code}/>\n"
299+
)
300+
301+
# this should be used as little as possible!
302+
if self.state.config.metadata.get("untested", False):
303+
notes.append(
304+
"- **This device has not been tested with OpenAndroidInstaller yet.** The installation can go wrong. You may have to finish the installation process with command line. If you test, please report the result on GitHub."
305+
)
306+
307+
notes.extend(
308+
f"- {note}" for note in self.state.config.metadata.get("notes", [])
309+
)
310+
return "\n\n".join(notes)
311+
303312
def toggle_additional_image_selection(self):
304313
"""Toggle the visibility of the additional image selection controls."""
305314
# attach the controls for uploading others partitions, like dtbo, vbmeta & super_empty

0 commit comments

Comments
 (0)