From 62be5c351fb79d87ca6b51be03f8cbfbc652b25d Mon Sep 17 00:00:00 2001
From: rudu <40572253+anon1892@users.noreply.github.com>
Date: Tue, 1 Aug 2023 13:27:27 +0200
Subject: [PATCH 1/3] Added device specific notes
---
README.md | 1 +
openandroidinstaller/installer_config.py | 1 +
openandroidinstaller/views/select_view.py | 14 ++++++++++++++
3 files changed, 16 insertions(+)
diff --git a/README.md b/README.md
index a49b1a4a..bea6ab57 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,7 @@ Every config file should have `metadata` with the following fields:
- `device_code`: str; The official device code.
- `supported_device_codes`: List[str]; A list of supported device codes for the config. The config will be loaded based on this field.
- `twrp-link`: [OPTIONAL] str; name of the corresponding twrp page.
+- `notes`: [OPTIONAL] str; specific phone information, showed before choosing ROM / recovery
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.
diff --git a/openandroidinstaller/installer_config.py b/openandroidinstaller/installer_config.py
index 2a857d83..cf41617a 100644
--- a/openandroidinstaller/installer_config.py
+++ b/openandroidinstaller/installer_config.py
@@ -166,6 +166,7 @@ def validate_config(config: str) -> bool:
"device_code": str,
"supported_device_codes": [str],
schema.Optional("twrp-link"): str,
+ schema.Optional("notes"): str,
},
schema.Optional("requirements"): {
schema.Optional("android"): schema.Or(str, int),
diff --git a/openandroidinstaller/views/select_view.py b/openandroidinstaller/views/select_view.py
index 442fa98b..a83ae0fe 100644
--- a/openandroidinstaller/views/select_view.py
+++ b/openandroidinstaller/views/select_view.py
@@ -144,6 +144,20 @@ def build(self):
# text row to show infos during the process
self.info_field = Row()
+
+ # Device specific notes
+ if "notes" in self.state.config.metadata:
+ self.right_view.controls.extend(
+ [
+ Text(
+ "Important notes for your device",
+ style="titleSmall",
+ color=colors.RED,
+ weight="bold",
+ ),
+ Markdown(f"""{self.state.config.metadata['notes']}"""),
+ ]
+ )
# 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}"
From 812bb51d9909c33f0b6e72ae7f0aedbb71e01f98 Mon Sep 17 00:00:00 2001
From: rudu <40572253+anon1892@users.noreply.github.com>
Date: Wed, 2 Aug 2023 13:58:18 +0200
Subject: [PATCH 2/3] Update `notes`, add `brand` and `untested` metadata.
---
README.md | 4 +++-
openandroidinstaller/views/select_view.py | 9 ++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index bea6ab57..e20c44e9 100644
--- a/README.md
+++ b/README.md
@@ -210,12 +210,14 @@ A config file consists of two parts. The first part are some metadata about the
##### How to write Metadata
Every config file should have `metadata` with the following fields:
- `maintainer`: str; Maintainer and author of the config file.
+- `brand`: [OPTIONAL] str; Name of the brand. Can be used to make brand specific actions.
- `device_name`: str; Name of the device.
- `is_ab_device`: bool; A boolean to determine if the device is a/b-partitioned or not.
- `device_code`: str; The official device code.
- `supported_device_codes`: List[str]; A list of supported device codes for the config. The config will be loaded based on this field.
- `twrp-link`: [OPTIONAL] str; name of the corresponding twrp page.
-- `notes`: [OPTIONAL] str; specific phone information, showed before choosing ROM / recovery
+- `notes`: [OPTIONAL] List[str]; specific phone information, showed before choosing ROM / recovery
+- `untested`: [OPTIONAL] bool; If `true`, a warning message is showed during installation process.
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.
diff --git a/openandroidinstaller/views/select_view.py b/openandroidinstaller/views/select_view.py
index a83ae0fe..19b24700 100644
--- a/openandroidinstaller/views/select_view.py
+++ b/openandroidinstaller/views/select_view.py
@@ -147,6 +147,13 @@ def build(self):
# Device specific notes
if "notes" in self.state.config.metadata:
+ notes = ""
+ if "brand" in self.state.config.metadata and (self.state.config.metadata['brand'] == "xiaomi" or self.state.config.metadata['brand'] == "poco"):
+ notes += "- If something goes wrong, you can reinstall MiUI here :\n\n\n"
+ if "untested" in self.state.config.metadata and self.state.config.metadata['untested'] == True:
+ 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"
+ for note in self.state.config.metadata['notes']:
+ notes += "- " + note + "\n\n"
self.right_view.controls.extend(
[
Text(
@@ -155,7 +162,7 @@ def build(self):
color=colors.RED,
weight="bold",
),
- Markdown(f"""{self.state.config.metadata['notes']}"""),
+ Markdown(f"""{notes}"""),
]
)
# if there is an available download, show the button to the page
From 616c7e6f73fe752e7d9851679663f165b729b023 Mon Sep 17 00:00:00 2001
From: rudu <40572253+anon1892@users.noreply.github.com>
Date: Wed, 2 Aug 2023 19:54:55 +0200
Subject: [PATCH 3/3] Fix
---
openandroidinstaller/views/select_view.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/openandroidinstaller/views/select_view.py b/openandroidinstaller/views/select_view.py
index 19b24700..0c45502f 100644
--- a/openandroidinstaller/views/select_view.py
+++ b/openandroidinstaller/views/select_view.py
@@ -146,14 +146,16 @@ def build(self):
self.info_field = Row()
# Device specific notes
+ notes = ""
+ if "brand" in self.state.config.metadata and (
+ self.state.config.metadata['brand'] == "xiaomi" or self.state.config.metadata['brand'] == "poco"):
+ notes += "- If something goes wrong, you can reinstall MiUI here :\n\n\n"
+ if "untested" in self.state.config.metadata and self.state.config.metadata['untested'] == True:
+ 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"
if "notes" in self.state.config.metadata:
- notes = ""
- if "brand" in self.state.config.metadata and (self.state.config.metadata['brand'] == "xiaomi" or self.state.config.metadata['brand'] == "poco"):
- notes += "- If something goes wrong, you can reinstall MiUI here :\n\n\n"
- if "untested" in self.state.config.metadata and self.state.config.metadata['untested'] == True:
- 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"
for note in self.state.config.metadata['notes']:
notes += "- " + note + "\n\n"
+ if notes != "":
self.right_view.controls.extend(
[
Text(