Skip to content

Commit

Permalink
Allow to add a specific link to a twrp page for the download button t…
Browse files Browse the repository at this point in the history
…o config
  • Loading branch information
tsterbak committed Feb 9, 2023
1 parent dcfaaf4 commit 176ffa5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ If you want to use the tool for a non-supported smartphone, the fastest way is t

#### Content of a config file

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.

##### How to write Metadata
Every config file should have metadata with the following fields:
- `maintainer`: str; Maintainer and author of the config file.
- `devicename`: str; Name of the device.
- `devicecode`: str; The official device code.
- `twrp-link`: [OPTIONAL] str; name of the corresponding twrp page.

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.
- `android`: [OPTIONAL] int|str; Android version to install prior to installing a custom ROM.
- `firmware`: [OPTIONAL] str; specific firmware version to install before installing a custom ROM.

##### How to write steps:
Every step in the config file corresponds to one view in the application. These steps should contain the following fields:
- `type`: str; Corresponds to the type of view to generate. There are the following options:
- `text`: Just display the text given in content.
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/assets/configs/cheeseburger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ metadata:
maintainer: SirRGB
devicename: OnePlus 5
devicecode: cheeseburger
twrp-link: cheeseburger_dumpling
steps:
unlock_bootloader:
- type: call_button
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/assets/configs/dumpling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ metadata:
maintainer: SirRGB
devicename: OnePlus 5T
devicecode: dumpling
twrp-link: cheeseburger_dumpling
steps:
unlock_bootloader:
- type: call_button
Expand Down
2 changes: 2 additions & 0 deletions openandroidinstaller/installer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(
self.metadata = metadata
self.requirements = requirements
self.device_code = metadata.get("devicecode")
self.twrp_link = metadata.get("twrp-link")
inverted_mapping = dict(map(reversed, self.device_code_mapping.items()))
self.alternative_device_code = inverted_mapping.get(
self.device_code, self.device_code
Expand Down Expand Up @@ -175,6 +176,7 @@ def validate_config(config: str) -> bool:
"maintainer": str,
"devicename": str,
"devicecode": str,
schema.Optional("twrp-link"): str,
},
schema.Optional("requirements"): {
schema.Optional("android"): schema.Or(str, int),
Expand Down
3 changes: 2 additions & 1 deletion openandroidinstaller/views/select_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def build(self):
self.info_field = Row()
# if there is an available download, show the button to the page
if self.download_link:
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}"
self.right_view.controls.append(Divider())
self.right_view.controls.append(
Column(
Expand All @@ -166,7 +167,7 @@ def build(self):
"Download TWRP recovery",
icon=icons.DOWNLOAD_OUTLINED,
on_click=lambda _: webbrowser.open(
f"https://dl.twrp.me/{self.state.config.device_code}"
twrp_download_link
),
expand=True,
),
Expand Down

0 comments on commit 176ffa5

Please sign in to comment.