Skip to content

Commit

Permalink
Update flet dependency to 0.24.1 and fix filepicker dialoge issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Feb 7, 2025
1 parent e7530ed commit f7214d5
Show file tree
Hide file tree
Showing 12 changed files with 2,916 additions and 1,873 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -14,13 +14,13 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.8.1
hooks:
# Run the linter.
- id: ruff
Expand All @@ -29,7 +29,7 @@ repos:
- id: ruff-format

- repo: https://github.com/python-poetry/poetry
rev: 1.6.1
rev: 1.8.4
hooks:
- id: poetry-check
#- id: poetry-lock
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Here are the official links for:
- [GrapheneOS](https://grapheneos.org)
- [LineageOS](https://wiki.lineageos.org/devices)
- [LineageOS for MicroG](https://download.lineage.microg.org)
- [PixelExperience](https://download.pixelexperience.org)
- Recovery:
- [TWRP recovery](https://twrp.me/Devices)
- Optional Add-ons:
Expand Down Expand Up @@ -275,7 +274,7 @@ Make sure to check if your issue or PR has already been fixed or implemented **b

## License

Original development by [Tobias Sterbak](https://tobiassterbak.com). Copyright (C) 2022-2024.
Original development by [Tobias Sterbak](https://tobiassterbak.com). Copyright (C) 2022-2025.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Expand Down
20 changes: 11 additions & 9 deletions openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ def configure(page: Page):
# Configure the application base page
page.title = "OpenAndroidInstaller"
page.theme_mode = "light"
page.window_height = 900
page.window_width = int(1.5 * page.window_height)
page.window_top = 100
page.window_left = 120
page.window.height = 900
page.window.width = int(1.5 * page.window.height)
page.window.top = 100
page.window.left = 120
page.scroll = "adaptive"
page.horizontal_alignment = "center"
page.window_min_width = 1000
page.window_min_height = 600
page.window.min_width = 1000
page.window.min_height = 600


def log_version_infos(bin_path):
Expand Down Expand Up @@ -272,10 +272,10 @@ def main(page: Page, test: bool = False, test_config: str = "sargo"):

# display a warnings banner
def close_banner(e):
page.banner.open = False
banner.open = False
page.update()

page.banner = Banner(
banner = Banner(
bgcolor=colors.AMBER_100,
leading=Icon(icons.WARNING_AMBER_ROUNDED, color=colors.AMBER, size=40),
content=Text(
Expand All @@ -285,7 +285,8 @@ def close_banner(e):
TextButton("I understand", on_click=close_banner),
],
)
page.banner.open = True
page.overlay.append(banner)
banner.open = True
page.update()

# create the State object
Expand All @@ -296,6 +297,7 @@ def close_banner(e):
test=test,
test_config=test_config,
)
state.page = page
# create application instance
app = MainView(state=state)

Expand Down
8 changes: 2 additions & 6 deletions openandroidinstaller/views/addon_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
colors,
icons,
)
from flet_core.buttons import CountinuosRectangleBorder
from flet_core.buttons import ContinuousRectangleBorder
from loguru import logger
from styles import Markdown, Text
from views import BaseView
Expand Down Expand Up @@ -78,7 +78,7 @@ def build(self):
TextButton("Close", on_click=self.close_close_explain_addons_dlg),
],
actions_alignment="end",
shape=CountinuosRectangleBorder(radius=0),
shape=ContinuousRectangleBorder(radius=0),
)

# initialize file pickers
Expand Down Expand Up @@ -170,10 +170,6 @@ def build(self):
self.right_view.controls.extend(
[
Text("Select addons:", style="titleSmall"),
# Markdown(
# f"""
# The image file should look something like `lineage-20.0-20240101-nightly-{self.state.config.metadata.get('devicecode')}-signed.zip`."""
# ),
Row(
[
FilledButton(
Expand Down
4 changes: 2 additions & 2 deletions openandroidinstaller/views/requirements_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
colors,
icons,
)
from flet_core.buttons import CountinuosRectangleBorder
from flet_core.buttons import ContinuousRectangleBorder
from loguru import logger
from styles import Markdown, Text
from views import BaseView
Expand Down Expand Up @@ -94,7 +94,7 @@ def init_visuals(
TextButton("Close", on_click=self.close_find_version_dlg),
],
actions_alignment="end",
shape=CountinuosRectangleBorder(radius=0),
shape=ContinuousRectangleBorder(radius=0),
)

def build(self):
Expand Down
24 changes: 13 additions & 11 deletions openandroidinstaller/views/select_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
colors,
icons,
)
from flet_core.buttons import CountinuosRectangleBorder
from flet_core.buttons import ContinuousRectangleBorder
from loguru import logger
from styles import Markdown, Text
from utils import (
Expand Down Expand Up @@ -90,7 +90,7 @@ def init_visuals(
TextButton("Close", on_click=self.close_close_explain_images_dlg),
],
actions_alignment="end",
shape=CountinuosRectangleBorder(radius=0),
shape=ContinuousRectangleBorder(radius=0),
)

# initialize file pickers
Expand Down Expand Up @@ -129,12 +129,7 @@ def init_visuals(
self.on_confirm, "Continue without additional images"
)
self.continue_eitherway_button.disabled = True
self.pick_recovery_dialog.on_result = self.enable_button_if_ready
self.pick_image_dialog.on_result = self.enable_button_if_ready
self.pick_dtbo_dialog.on_result = self.enable_button_if_ready
self.pick_vbmeta_dialog.on_result = self.enable_button_if_ready
self.pick_super_empty_dialog.on_result = self.enable_button_if_ready
self.pick_vendor_boot_dialog.on_result = self.enable_button_if_ready

# back button
self.back_button = ElevatedButton(
"Back",
Expand Down Expand Up @@ -245,7 +240,7 @@ def build(self):
Text("Select an OS image:", style="titleSmall"),
Markdown(
f"""
The image file should look something like `lineage-20.0-20240101-nightly-{self.state.config.device_code}-signed.zip`."""
The image file should look something like `lineage-22.1-20241101-nightly-{self.state.config.device_code}-signed.zip`."""
),
Row(
[
Expand All @@ -271,7 +266,7 @@ def build(self):
Text("Select a TWRP recovery image:", style="titleSmall"),
Markdown(
f"""
The recovery image should look something like `twrp-3.7.0_12-0-{self.state.config.device_code}.img`.
The recovery image should look something like `twrp-3.7.1_12-0-{self.state.config.device_code}.img`.
**Note:** This tool **only supports TWRP recoveries**.""",
extension_set="gitHubFlavored",
Expand Down Expand Up @@ -375,7 +370,7 @@ def toggle_additional_image_selection(self):
),
],
actions_alignment="end",
shape=CountinuosRectangleBorder(radius=0),
shape=ContinuousRectangleBorder(radius=0),
)

# create help/info button to show the help dialog for the image and recovery selection
Expand Down Expand Up @@ -520,6 +515,7 @@ def close_close_explain_additional_images_dlg(self, e):
self.page.update()

def pick_image_result(self, e: FilePickerResultEvent):
logger.info(f"Selected image: {e.files}")
path = ", ".join(map(lambda f: f.name, e.files)) if e.files else "Cancelled!"
# update the textfield with the name of the file
self.selected_image.value = (
Expand Down Expand Up @@ -555,6 +551,7 @@ def pick_image_result(self, e: FilePickerResultEvent):
self.additional_image_selection.controls = []
self.additional_image_selection.update()
# update
self.enable_button_if_ready(None)
self.selected_image.update()

def pick_recovery_result(self, e: FilePickerResultEvent):
Expand Down Expand Up @@ -583,6 +580,7 @@ def pick_recovery_result(self, e: FilePickerResultEvent):
self.selected_recovery.color = colors.RED
self.selected_recovery.value += f"\n> {self.recovery_compatibility.message}"
# update
self.enable_button_if_ready(None)
self.selected_recovery.update()

def pick_dtbo_result(self, e: FilePickerResultEvent):
Expand All @@ -600,6 +598,7 @@ def pick_dtbo_result(self, e: FilePickerResultEvent):
else:
logger.info("No image selected.")
# update
self.enable_button_if_ready(None)
self.selected_dtbo.update()

def pick_vbmeta_result(self, e: FilePickerResultEvent):
Expand All @@ -617,6 +616,7 @@ def pick_vbmeta_result(self, e: FilePickerResultEvent):
else:
logger.info("No image selected.")
# update
self.enable_button_if_ready(None)
self.selected_vbmeta.update()

def pick_super_empty_result(self, e: FilePickerResultEvent):
Expand All @@ -635,6 +635,7 @@ def pick_super_empty_result(self, e: FilePickerResultEvent):
else:
logger.info("No image selected.")
# update
self.enable_button_if_ready(None)
self.selected_super_empty.update()

def pick_vendor_boot_result(self, e: FilePickerResultEvent):
Expand All @@ -655,6 +656,7 @@ def pick_vendor_boot_result(self, e: FilePickerResultEvent):
else:
logger.info("No image selected.")
# update
self.enable_button_if_ready(None)
self.selected_vendor_boot.update()

def enable_button_if_ready(self, e):
Expand Down
4 changes: 2 additions & 2 deletions openandroidinstaller/views/start_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
colors,
icons,
)
from flet_core.buttons import CountinuosRectangleBorder
from flet_core.buttons import ContinuousRectangleBorder
from loguru import logger
from styles import Markdown, Text
from tooling import search_device, SearchResult
Expand Down Expand Up @@ -86,7 +86,7 @@ def init_visuals(
TextButton("Close", on_click=self.close_developer_options_dlg),
],
actions_alignment="end",
shape=CountinuosRectangleBorder(radius=0),
shape=ContinuousRectangleBorder(radius=0),
)

# toggleswitch to allow skipping unlocking the bootloader
Expand Down
Loading

0 comments on commit f7214d5

Please sign in to comment.