diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index 22a7c40682..6e371ffc73 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -361,6 +361,7 @@ static void _librust_qstrs(void) { MP_QSTR_language__title; MP_QSTR_lines; MP_QSTR_load_from_flash; + MP_QSTR_lockable; MP_QSTR_lockscreen__tap_to_connect; MP_QSTR_lockscreen__tap_to_unlock; MP_QSTR_lockscreen__title_locked; diff --git a/core/embed/rust/src/ui/api/firmware_micropython.rs b/core/embed/rust/src/ui/api/firmware_micropython.rs index 90c1ebf54f..97ddf23404 100644 --- a/core/embed/rust/src/ui/api/firmware_micropython.rs +++ b/core/embed/rust/src/ui/api/firmware_micropython.rs @@ -825,10 +825,10 @@ extern "C" fn new_show_homescreen(n_args: usize, args: *const Obj, kwargs: *mut let notification: Option> = kwargs.get(Qstr::MP_QSTR_notification)?.try_into_option()?; let notification_level: u8 = kwargs.get_or(Qstr::MP_QSTR_notification_level, 0)?; - let hold: bool = kwargs.get(Qstr::MP_QSTR_hold)?.try_into()?; + let lockable: bool = kwargs.get(Qstr::MP_QSTR_lockable)?.try_into()?; let skip_first_paint: bool = kwargs.get(Qstr::MP_QSTR_skip_first_paint)?.try_into()?; - let layout = ModelUI::show_homescreen(label, hold, notification, notification_level)?; + let layout = ModelUI::show_homescreen(label, notification, notification_level, lockable)?; let layout_obj = LayoutObj::new_root(layout)?; if skip_first_paint { layout_obj.skip_first_paint(); @@ -1662,9 +1662,9 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// def show_homescreen( /// *, /// label: str | None, - /// hold: bool, /// notification: str | None, /// notification_level: int = 0, + /// lockable: bool, /// skip_first_paint: bool, /// ) -> LayoutObj[UiResult]: /// """Idle homescreen.""" diff --git a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs index 2d5abefc0b..c63eb2fa42 100644 --- a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs @@ -869,12 +869,12 @@ impl FirmwareUI for UIBolt { fn show_homescreen( label: TString<'static>, - hold: bool, notification: Option>, notification_level: u8, + lockable: bool, ) -> Result { let notification = notification.map(|w| (w, notification_level)); - let layout = RootComponent::new(Homescreen::new(label, notification, hold)); + let layout = RootComponent::new(Homescreen::new(label, notification, lockable)); Ok(layout) } diff --git a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs index a68283ad87..738436e259 100644 --- a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs @@ -1059,12 +1059,12 @@ impl FirmwareUI for UICaesar { fn show_homescreen( label: TString<'static>, - hold: bool, notification: Option>, notification_level: u8, + lockable: bool, ) -> Result { let notification = notification.map(|w| (w, notification_level)); - let loader_description = hold.then_some("Locking the device...".into()); + let loader_description = lockable.then_some("Locking the device...".into()); let layout = RootComponent::new(Homescreen::new(label, notification, loader_description)); Ok(layout) } diff --git a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs index a1e6c1f646..e73a4e9bfe 100644 --- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs @@ -889,12 +889,12 @@ impl FirmwareUI for UIDelizia { fn show_homescreen( label: TString<'static>, - hold: bool, notification: Option>, notification_level: u8, + lockable: bool, ) -> Result { let notification = notification.map(|w| (w, notification_level)); - let layout = RootComponent::new(Homescreen::new(label, notification, hold)?); + let layout = RootComponent::new(Homescreen::new(label, notification, lockable)?); Ok(layout) } diff --git a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs index 180f1b4c7d..6ce4d77088 100644 --- a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs @@ -1016,9 +1016,9 @@ impl FirmwareUI for UIEckhart { fn show_homescreen( label: TString<'static>, - hold: bool, notification: Option>, notification_level: u8, + lockable: bool, ) -> Result { let locked = false; let bootscreen = false; @@ -1026,7 +1026,7 @@ impl FirmwareUI for UIEckhart { let notification = notification.map(|w| (w, notification_level)); let layout = RootComponent::new(Homescreen::new( label, - hold, + lockable, locked, bootscreen, coinjoin_authorized, diff --git a/core/embed/rust/src/ui/ui_firmware.rs b/core/embed/rust/src/ui/ui_firmware.rs index fc10b183e4..29c2b98d56 100644 --- a/core/embed/rust/src/ui/ui_firmware.rs +++ b/core/embed/rust/src/ui/ui_firmware.rs @@ -308,9 +308,9 @@ pub trait FirmwareUI { fn show_homescreen( label: TString<'static>, - hold: bool, notification: Option>, notification_level: u8, + lockable: bool, ) -> Result; fn show_device_menu( diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index 4dfb21b581..7e2406ad94 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -541,9 +541,9 @@ def show_group_share_success( def show_homescreen( *, label: str | None, - hold: bool, notification: str | None, notification_level: int = 0, + lockable: bool, skip_first_paint: bool, ) -> LayoutObj[UiResult]: """Idle homescreen.""" diff --git a/core/src/apps/homescreen/__init__.py b/core/src/apps/homescreen/__init__.py index 06c814a17d..a20341fdf6 100644 --- a/core/src/apps/homescreen/__init__.py +++ b/core/src/apps/homescreen/__init__.py @@ -31,27 +31,31 @@ async def homescreen() -> None: # TODO: add notification that translations are out of date notification = None - notification_is_error = False + notification_level = 1 # 0 = strong warning, 1 = warning, 2 = info, 3 = success if is_set_any_session(MessageType.AuthorizeCoinJoin): notification = TR.homescreen__title_coinjoin_authorized + notification_level = 3 elif storage.device.is_initialized() and storage.device.no_backup(): notification = TR.homescreen__title_seedless - notification_is_error = True + notification_level = 0 elif storage.device.is_initialized() and storage.device.unfinished_backup(): notification = TR.homescreen__title_backup_failed - notification_is_error = True + notification_level = 0 elif storage.device.is_initialized() and storage.device.needs_backup(): notification = TR.homescreen__title_backup_needed + notification_level = 1 elif storage.device.is_initialized() and not config.has_pin(): notification = TR.homescreen__title_pin_not_set + notification_level = 1 elif storage.device.get_experimental_features(): notification = TR.homescreen__title_experimental_mode + notification_level = 2 obj = Homescreen( label=label, notification=notification, - notification_is_error=notification_is_error, - hold_to_lock=config.has_pin(), + notification_level=notification_level, + lockable=config.has_pin(), ) try: res = await obj.get_result() diff --git a/core/src/trezor/ui/layouts/homescreen.py b/core/src/trezor/ui/layouts/homescreen.py index ebad72eba0..33ae56c885 100644 --- a/core/src/trezor/ui/layouts/homescreen.py +++ b/core/src/trezor/ui/layouts/homescreen.py @@ -67,28 +67,16 @@ class Homescreen(HomescreenBase): self, label: str | None, notification: str | None, - notification_is_error: bool, - hold_to_lock: bool, + notification_level: int, + lockable: bool, ) -> None: - level = 1 - if notification is not None: - notification = notification.rstrip( - "!" - ) # TODO handle TS5 that doesn't have it - if notification == TR.homescreen__title_coinjoin_authorized: - level = 3 - elif notification == TR.homescreen__title_experimental_mode: - level = 2 - elif notification_is_error: - level = 0 - super().__init__( layout=_retry_with_gc( trezorui_api.show_homescreen, label=label, notification=notification, - notification_level=level, - hold=hold_to_lock, + notification_level=notification_level, + lockable=lockable, skip_first_paint=self._should_resume(), ) )