From b7dc557bfa08e1a2e8583bacf364c1489635706b Mon Sep 17 00:00:00 2001 From: obrusvit Date: Thu, 8 Aug 2024 19:16:08 +0200 Subject: [PATCH] feat(core): slight change of passphrase copy Usage of different copy in mercury (especially titles and subtitles) requires moving the layout code deeper into the model specifics. [no changelog] --- core/src/apps/management/apply_settings.py | 46 ++++++------------- .../src/trezor/ui/layouts/mercury/__init__.py | 42 +++++++++++++++++ core/src/trezor/ui/layouts/tr/__init__.py | 40 +++++++++++++++- core/src/trezor/ui/layouts/tt/__init__.py | 40 +++++++++++++++- core/translations/signatures.json | 4 +- 5 files changed, 135 insertions(+), 37 deletions(-) diff --git a/core/src/apps/management/apply_settings.py b/core/src/apps/management/apply_settings.py index 1f06cd1e18..2c98479604 100644 --- a/core/src/apps/management/apply_settings.py +++ b/core/src/apps/management/apply_settings.py @@ -147,33 +147,24 @@ async def _require_confirm_change_label(label: str) -> None: async def _require_confirm_change_passphrase(use: bool) -> None: - description = TR.passphrase__turn_on if use else TR.passphrase__turn_off - verb = TR.buttons__turn_on if use else TR.buttons__turn_off - await confirm_action( - "set_passphrase", - TR.passphrase__title_settings, - description=description, - verb=verb, - br_code=BRT_PROTECT_CALL, - prompt_screen=True, - ) + from trezor.ui.layouts import confirm_change_passphrase + + await confirm_change_passphrase(use) + + +async def _require_confirm_hide_passphrase_from_host(enable: bool) -> None: + from trezor.ui.layouts import confirm_hide_passphrase_from_host + + if enable: + await confirm_hide_passphrase_from_host() async def _require_confirm_change_passphrase_source( passphrase_always_on_device: bool, ) -> None: - description = ( - TR.passphrase__always_on_device - if passphrase_always_on_device - else TR.passphrase__revoke_on_device - ) - await confirm_action( - "set_passphrase_source", - TR.passphrase__title_source, - description=description, - br_code=BRT_PROTECT_CALL, - prompt_screen=True, - ) + from trezor.ui.layouts import confirm_change_passphrase_source + + await confirm_change_passphrase_source(passphrase_always_on_device) async def _require_confirm_change_display_rotation(rotation: int) -> None: @@ -263,17 +254,6 @@ async def _require_confirm_experimental_features(enable: bool) -> None: ) -async def _require_confirm_hide_passphrase_from_host(enable: bool) -> None: - if enable: - await confirm_action( - "set_hide_passphrase_from_host", - TR.passphrase__title_hide, - description=TR.passphrase__hide, - br_code=BRT_PROTECT_CALL, - prompt_screen=True, - ) - - if utils.USE_HAPTIC: async def _require_confirm_haptic_feedback(enable: bool) -> None: diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index b224329187..5b83080d7f 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -446,6 +446,48 @@ def confirm_homescreen( ) +def confirm_change_passphrase(use: bool) -> Awaitable[None]: + description = TR.passphrase__turn_on if use else TR.passphrase__turn_off + + return confirm_action( + "set_passphrase", + TR.passphrase__title_passphrase, + subtitle=TR.words__settings, + description=description, + br_code=ButtonRequestType.ProtectCall, + prompt_screen=True, + ) + + +def confirm_hide_passphrase_from_host() -> Awaitable[None]: + return confirm_action( + "set_hide_passphrase_from_host", + TR.passphrase__title_passphrase, + subtitle=TR.words__settings, + description=TR.passphrase__hide, + br_code=ButtonRequestType.ProtectCall, + prompt_screen=True, + ) + + +def confirm_change_passphrase_source( + passphrase_always_on_device: bool, +) -> Awaitable[None]: + description = ( + TR.passphrase__always_on_device + if passphrase_always_on_device + else TR.passphrase__revoke_on_device + ) + return confirm_action( + "set_passphrase_source", + TR.passphrase__title_passphrase, + subtitle=TR.words__settings, + description=description, + br_code=ButtonRequestType.ProtectCall, + prompt_screen=True, + ) + + async def show_address( address: str, *, diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 446322fbf4..54b32b464b 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -394,7 +394,7 @@ def confirm_action( reverse: bool = False, exc: ExceptionType = ActionCancelled, br_code: ButtonRequestType = BR_CODE_OTHER, - prompt_screen: bool = False, + prompt_screen: bool = False, # unused on TR prompt_title: str | None = None, ) -> Awaitable[None]: verb = verb or TR.buttons__confirm # def_arg @@ -536,6 +536,44 @@ def confirm_homescreen(image: bytes) -> Awaitable[None]: ) +def confirm_change_passphrase(use: bool) -> Awaitable[None]: + description = TR.passphrase__turn_on if use else TR.passphrase__turn_off + verb = TR.buttons__turn_on if use else TR.buttons__turn_off + + return confirm_action( + "set_passphrase", + TR.passphrase__title_settings, + description=description, + verb=verb, + br_code=ButtonRequestType.ProtectCall, + ) + + +def confirm_hide_passphrase_from_host() -> Awaitable[None]: + return confirm_action( + "set_hide_passphrase_from_host", + TR.passphrase__title_hide, + description=TR.passphrase__hide, + br_code=ButtonRequestType.ProtectCall, + ) + + +def confirm_change_passphrase_source( + passphrase_always_on_device: bool, +) -> Awaitable[None]: + description = ( + TR.passphrase__always_on_device + if passphrase_always_on_device + else TR.passphrase__revoke_on_device + ) + return confirm_action( + "set_passphrase_source", + TR.passphrase__title_source, + description=description, + br_code=ButtonRequestType.ProtectCall, + ) + + async def show_address( address: str, *, diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index f7ef29c1e9..f7253b6d7c 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -303,7 +303,7 @@ def confirm_action( reverse: bool = False, exc: ExceptionType = ActionCancelled, br_code: ButtonRequestType = BR_CODE_OTHER, - prompt_screen: bool = False, + prompt_screen: bool = False, # unused on TT prompt_title: str | None = None, ) -> Awaitable[None]: if description is not None and description_param is not None: @@ -469,6 +469,44 @@ def confirm_homescreen(image: bytes) -> Awaitable[None]: ) +def confirm_change_passphrase(use: bool) -> Awaitable[None]: + description = TR.passphrase__turn_on if use else TR.passphrase__turn_off + verb = TR.buttons__turn_on if use else TR.buttons__turn_off + + return confirm_action( + "set_passphrase", + TR.passphrase__title_settings, + description=description, + verb=verb, + br_code=ButtonRequestType.ProtectCall, + ) + + +def confirm_hide_passphrase_from_host() -> Awaitable[None]: + return confirm_action( + "set_hide_passphrase_from_host", + TR.passphrase__title_hide, + description=TR.passphrase__hide, + br_code=ButtonRequestType.ProtectCall, + ) + + +def confirm_change_passphrase_source( + passphrase_always_on_device: bool, +) -> Awaitable[None]: + description = ( + TR.passphrase__always_on_device + if passphrase_always_on_device + else TR.passphrase__revoke_on_device + ) + return confirm_action( + "set_passphrase_source", + TR.passphrase__title_source, + description=description, + br_code=ButtonRequestType.ProtectCall, + ) + + async def show_address( address: str, *, diff --git a/core/translations/signatures.json b/core/translations/signatures.json index 4bfa570137..faf8f88322 100644 --- a/core/translations/signatures.json +++ b/core/translations/signatures.json @@ -1,8 +1,8 @@ { "current": { "merkle_root": "14c1d561c00b83c685a89d37be68d94dae0fb8b88835d346c877e6246fe022e3", - "datetime": "2024-08-07T21:19:23.594799", - "commit": "0a6b0baa2790360902f9a451f595325f9c8c1fb0" + "datetime": "2024-08-09T07:44:08.162423", + "commit": "89a3ce360514eff165fe0fcb0c2a218b88d85e07" }, "history": [ {