Skip to content

Commit 176ffa5

Browse files
committed
Allow to add a specific link to a twrp page for the download button to config
1 parent dcfaaf4 commit 176ffa5

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ If you want to use the tool for a non-supported smartphone, the fastest way is t
179179

180180
#### Content of a config file
181181

182+
A config file consists of two parts. The first part are some metadata about the device and the second parts are the steps to unlock the bootloader, flash a recovery and install the ROMs.
183+
184+
##### How to write Metadata
185+
Every config file should have metadata with the following fields:
186+
- `maintainer`: str; Maintainer and author of the config file.
187+
- `devicename`: str; Name of the device.
188+
- `devicecode`: str; The official device code.
189+
- `twrp-link`: [OPTIONAL] str; name of the corresponding twrp page.
190+
191+
In addition to these metadata, every config can have optional requirements. If these are set, the user is asked to check if they are meet.
192+
- `android`: [OPTIONAL] int|str; Android version to install prior to installing a custom ROM.
193+
- `firmware`: [OPTIONAL] str; specific firmware version to install before installing a custom ROM.
194+
195+
##### How to write steps:
182196
Every step in the config file corresponds to one view in the application. These steps should contain the following fields:
183197
- `type`: str; Corresponds to the type of view to generate. There are the following options:
184198
- `text`: Just display the text given in content.

openandroidinstaller/assets/configs/cheeseburger.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ metadata:
22
maintainer: SirRGB
33
devicename: OnePlus 5
44
devicecode: cheeseburger
5+
twrp-link: cheeseburger_dumpling
56
steps:
67
unlock_bootloader:
78
- type: call_button

openandroidinstaller/assets/configs/dumpling.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ metadata:
22
maintainer: SirRGB
33
devicename: OnePlus 5T
44
devicecode: dumpling
5+
twrp-link: cheeseburger_dumpling
56
steps:
67
unlock_bootloader:
78
- type: call_button

openandroidinstaller/installer_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(
8181
self.metadata = metadata
8282
self.requirements = requirements
8383
self.device_code = metadata.get("devicecode")
84+
self.twrp_link = metadata.get("twrp-link")
8485
inverted_mapping = dict(map(reversed, self.device_code_mapping.items()))
8586
self.alternative_device_code = inverted_mapping.get(
8687
self.device_code, self.device_code
@@ -175,6 +176,7 @@ def validate_config(config: str) -> bool:
175176
"maintainer": str,
176177
"devicename": str,
177178
"devicecode": str,
179+
schema.Optional("twrp-link"): str,
178180
},
179181
schema.Optional("requirements"): {
180182
schema.Optional("android"): schema.Or(str, int),

openandroidinstaller/views/select_view.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def build(self):
145145
self.info_field = Row()
146146
# if there is an available download, show the button to the page
147147
if self.download_link:
148+
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}"
148149
self.right_view.controls.append(Divider())
149150
self.right_view.controls.append(
150151
Column(
@@ -166,7 +167,7 @@ def build(self):
166167
"Download TWRP recovery",
167168
icon=icons.DOWNLOAD_OUTLINED,
168169
on_click=lambda _: webbrowser.open(
169-
f"https://dl.twrp.me/{self.state.config.device_code}"
170+
twrp_download_link
170171
),
171172
expand=True,
172173
),

0 commit comments

Comments
 (0)