From 3d7720e6609f75ff2e163eaf3795d14178bda081 Mon Sep 17 00:00:00 2001 From: Lukas Bielesch Date: Mon, 2 Dec 2024 14:56:54 +0100 Subject: [PATCH] chore(core): adapt wipe pin flow --- core/.changelog.d/4027.changed | 1 + core/embed/rust/librust_qstr.h | 2 + .../generated/translated_string.rs | 20 ++--- .../rust/src/ui/api/firmware_micropython.rs | 31 ++++++- .../model_mercury/flow/confirm_set_new_pin.rs | 35 ++++---- .../flow/confirm_set_new_wipe_code.rs | 89 +++++++++++++++++++ .../rust/src/ui/model_mercury/flow/mod.rs | 2 + .../rust/src/ui/model_mercury/ui_firmware.rs | 16 +++- .../embed/rust/src/ui/model_tr/ui_firmware.rs | 11 +++ .../embed/rust/src/ui/model_tt/ui_firmware.rs | 11 +++ core/embed/rust/src/ui/ui_firmware.rs | 7 ++ core/mocks/generated/trezorui_api.pyi | 11 +++ core/mocks/trezortranslate_keys.pyi | 10 +-- core/src/apps/bitcoin/sign_tx/layout.py | 10 +-- core/src/apps/cardano/layout.py | 2 +- core/src/apps/management/change_pin.py | 16 +++- core/src/apps/management/change_wipe_code.py | 17 +++- .../src/trezor/ui/layouts/mercury/__init__.py | 64 ++++++++----- core/src/trezor/ui/layouts/tr/__init__.py | 2 + core/src/trezor/ui/layouts/tt/__init__.py | 2 + core/translations/en.json | 10 +-- core/translations/signatures.json | 4 +- 22 files changed, 292 insertions(+), 81 deletions(-) create mode 100644 core/.changelog.d/4027.changed create mode 100644 core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_wipe_code.rs diff --git a/core/.changelog.d/4027.changed b/core/.changelog.d/4027.changed new file mode 100644 index 0000000000..f0ee37fb16 --- /dev/null +++ b/core/.changelog.d/4027.changed @@ -0,0 +1 @@ +[T3T1] Improve wipe code flow. diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index 3197b9ff12..f284254741 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -172,6 +172,7 @@ static void _librust_qstrs(void) { MP_QSTR_can_go_back; MP_QSTR_cancel; MP_QSTR_cancel_text; + MP_QSTR_cancel_title; MP_QSTR_case_sensitive; MP_QSTR_check_homescreen_format; MP_QSTR_chunkify; @@ -243,6 +244,7 @@ static void _librust_qstrs(void) { MP_QSTR_firmware_update__title_fingerprint; MP_QSTR_flow_confirm_output; MP_QSTR_flow_confirm_set_new_pin; + MP_QSTR_flow_confirm_set_new_wipe_code; MP_QSTR_flow_get_address; MP_QSTR_get_language; MP_QSTR_get_transition_out; diff --git a/core/embed/rust/src/translations/generated/translated_string.rs b/core/embed/rust/src/translations/generated/translated_string.rs index e8da45f6eb..811b6d633c 100644 --- a/core/embed/rust/src/translations/generated/translated_string.rs +++ b/core/embed/rust/src/translations/generated/translated_string.rs @@ -741,7 +741,7 @@ pub enum TranslatedString { pin__enter = 453, // "Enter PIN" pin__enter_new = 454, // "Enter new PIN" pin__entered_not_valid = 455, // "The PIN you have entered is not valid." - pin__info = 456, // "PIN will be required to access this device." + pin__info = 456, // "The PIN will be required to access this device." pin__invalid_pin = 457, // "Invalid PIN" pin__last_attempt = 458, // "Last attempt" pin__mismatch = 459, // "Entered PINs do not match!" @@ -751,7 +751,7 @@ pub enum TranslatedString { pin__reenter_to_confirm = 463, // "Please re-enter PIN to confirm." pin__should_be_long = 464, // "PIN should be 4-50 digits long." pin__title_check_pin = 465, // "Check PIN" - pin__title_settings = 466, // "PIN settings" + pin__title_settings = 466, // "PIN" pin__title_wrong_pin = 467, // "Wrong PIN" pin__tries_left = 468, // "tries left" pin__turn_off = 469, // "Are you sure you want to turn off PIN protection?" @@ -1161,8 +1161,8 @@ pub enum TranslatedString { wipe_code__change = 774, // "Change wipe code?" wipe_code__changed = 775, // "Wipe code changed." wipe_code__diff_from_pin = 776, // "The wipe code must be different from your PIN." - wipe_code__disabled = 777, // "Wipe code disabled." - wipe_code__enabled = 778, // "Wipe code enabled." + wipe_code__disabled = 777, // "Wipe code protection turned off." + wipe_code__enabled = 778, // "Wipe code protection turned on." wipe_code__enter_new = 779, // "Enter new wipe code" wipe_code__info = 780, // "Wipe code can be used to erase all data from this device." wipe_code__invalid = 781, // "Invalid wipe code" @@ -1171,7 +1171,7 @@ pub enum TranslatedString { wipe_code__reenter_to_confirm = 784, // "Please re-enter wipe code to confirm." wipe_code__title_check = 785, // "Check wipe code" wipe_code__title_invalid = 786, // "Invalid wipe code" - wipe_code__title_settings = 787, // "Wipe code settings" + wipe_code__title_settings = 787, // "Wipe code" wipe_code__turn_off = 788, // "Turn off wipe code protection?" wipe_code__turn_on = 789, // "Turn on wipe code protection?" wipe_code__wipe_code_mismatch = 790, // "Wipe code mismatch" @@ -2117,7 +2117,7 @@ impl TranslatedString { Self::pin__enter => "Enter PIN", Self::pin__enter_new => "Enter new PIN", Self::pin__entered_not_valid => "The PIN you have entered is not valid.", - Self::pin__info => "PIN will be required to access this device.", + Self::pin__info => "The PIN will be required to access this device.", Self::pin__invalid_pin => "Invalid PIN", Self::pin__last_attempt => "Last attempt", Self::pin__mismatch => "Entered PINs do not match!", @@ -2127,7 +2127,7 @@ impl TranslatedString { Self::pin__reenter_to_confirm => "Please re-enter PIN to confirm.", Self::pin__should_be_long => "PIN should be 4-50 digits long.", Self::pin__title_check_pin => "Check PIN", - Self::pin__title_settings => "PIN settings", + Self::pin__title_settings => "PIN", Self::pin__title_wrong_pin => "Wrong PIN", Self::pin__tries_left => "tries left", Self::pin__turn_off => "Are you sure you want to turn off PIN protection?", @@ -2537,8 +2537,8 @@ impl TranslatedString { Self::wipe_code__change => "Change wipe code?", Self::wipe_code__changed => "Wipe code changed.", Self::wipe_code__diff_from_pin => "The wipe code must be different from your PIN.", - Self::wipe_code__disabled => "Wipe code disabled.", - Self::wipe_code__enabled => "Wipe code enabled.", + Self::wipe_code__disabled => "Wipe code protection turned off.", + Self::wipe_code__enabled => "Wipe code protection turned on.", Self::wipe_code__enter_new => "Enter new wipe code", Self::wipe_code__info => "Wipe code can be used to erase all data from this device.", Self::wipe_code__invalid => "Invalid wipe code", @@ -2547,7 +2547,7 @@ impl TranslatedString { Self::wipe_code__reenter_to_confirm => "Please re-enter wipe code to confirm.", Self::wipe_code__title_check => "Check wipe code", Self::wipe_code__title_invalid => "Invalid wipe code", - Self::wipe_code__title_settings => "Wipe code settings", + Self::wipe_code__title_settings => "Wipe code", Self::wipe_code__turn_off => "Turn off wipe code protection?", Self::wipe_code__turn_on => "Turn on wipe code protection?", Self::wipe_code__wipe_code_mismatch => "Wipe code mismatch", diff --git a/core/embed/rust/src/ui/api/firmware_micropython.rs b/core/embed/rust/src/ui/api/firmware_micropython.rs index e47b9145ef..6059da6864 100644 --- a/core/embed/rust/src/ui/api/firmware_micropython.rs +++ b/core/embed/rust/src/ui/api/firmware_micropython.rs @@ -532,8 +532,25 @@ extern "C" fn new_flow_confirm_set_new_pin( let block = move |_args: &[Obj], kwargs: &Map| { let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; + let cancel_title: TString = kwargs.get(Qstr::MP_QSTR_cancel_title)?.try_into()?; - let layout = ModelUI::flow_confirm_set_new_pin(title, description)?; + let layout = ModelUI::flow_confirm_set_new_pin(title, description, cancel_title)?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } +} + +extern "C" fn new_flow_confirm_set_new_wipe_code( + n_args: usize, + args: *const Obj, + kwargs: *mut Map, +) -> Obj { + let block = move |_args: &[Obj], kwargs: &Map| { + let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; + let cancel_title: TString = kwargs.get(Qstr::MP_QSTR_cancel_title)?.try_into()?; + + let layout = ModelUI::flow_confirm_set_new_wipe_code(title, description, cancel_title)?; Ok(LayoutObj::new_root(layout)?.into()) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } @@ -1378,16 +1395,24 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// """Confirm the recipient, (optionally) confirm the amount and (optionally) confirm the summary and present a Hold to Sign page.""" Qstr::MP_QSTR_flow_confirm_output => obj_fn_kw!(0, new_flow_confirm_output).as_obj(), - // TODO: supply more arguments for Wipe code setting (mercury) - /// /// def flow_confirm_set_new_pin( /// *, /// title: str, /// description: str, + /// cancel_title: str, /// ) -> LayoutObj[UiResult]: /// """Confirm new PIN setup with an option to cancel action.""" Qstr::MP_QSTR_flow_confirm_set_new_pin => obj_fn_kw!(0, new_flow_confirm_set_new_pin).as_obj(), + /// def flow_confirm_set_new_wipe_code( + /// *, + /// title: str, + /// description: str, + /// cancel_title: str, + /// ) -> LayoutObj[UiResult]: + /// """Confirm new wipe code setup with an option to cancel action.""" + Qstr::MP_QSTR_flow_confirm_set_new_wipe_code => obj_fn_kw!(0, new_flow_confirm_set_new_wipe_code).as_obj(), + /// def flow_get_address( /// *, /// address: str | bytes, diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs index e4c042f8ea..b5c32cb7dc 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_pin.rs @@ -65,13 +65,14 @@ impl FlowController for SetNewPin { pub fn new_set_new_pin( title: TString<'static>, description: TString<'static>, + cancel_title: TString<'static>, ) -> Result { - // TODO: supply more arguments for Wipe code setting when figma done let paragraphs = Paragraphs::new(Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, description)); let content_intro = Frame::left_aligned(title, SwipeContent::new(paragraphs)) .with_menu_button() .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) + .with_subtitle(TR::words__settings.into()) .with_swipe(Direction::Left, SwipeSettings::default()) .map(|msg| match msg { FrameMsg::Button(bm) => Some(bm), @@ -80,7 +81,7 @@ pub fn new_set_new_pin( let content_menu = Frame::left_aligned( "".into(), - VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::pin__cancel_setup.into()), + VerticalMenu::empty().danger(theme::ICON_CANCEL, cancel_title), ) .with_cancel_button() .with_swipe(Direction::Right, SwipeSettings::immediate()) @@ -95,24 +96,22 @@ pub fn new_set_new_pin( Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, TR::pin__cancel_info), ]) .into_paragraphs(); - let content_cancel_intro = Frame::left_aligned( - TR::pin__cancel_setup.into(), - SwipeContent::new(paragraphs_cancel_intro), - ) - .with_cancel_button() - .with_footer( - TR::instructions__swipe_up.into(), - Some(TR::pin__cancel_description.into()), - ) - .with_swipe(Direction::Up, SwipeSettings::default()) - .with_swipe(Direction::Right, SwipeSettings::immediate()) - .map(|msg| match msg { - FrameMsg::Button(bm) => Some(bm), - _ => None, - }); + let content_cancel_intro = + Frame::left_aligned(cancel_title, SwipeContent::new(paragraphs_cancel_intro)) + .with_cancel_button() + .with_footer( + TR::instructions__swipe_up.into(), + Some(TR::pin__cancel_description.into()), + ) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_swipe(Direction::Right, SwipeSettings::immediate()) + .map(|msg| match msg { + FrameMsg::Button(bm) => Some(bm), + _ => None, + }); let content_cancel_confirm = Frame::left_aligned( - TR::pin__cancel_setup.into(), + cancel_title, SwipeContent::new(PromptScreen::new_tap_to_cancel()), ) .with_cancel_button() diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_wipe_code.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_wipe_code.rs new file mode 100644 index 0000000000..b9d6270c3a --- /dev/null +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_set_new_wipe_code.rs @@ -0,0 +1,89 @@ +use crate::{ + error, + strutil::TString, + translations::TR, + ui::{ + component::{ + swipe_detect::SwipeSettings, + text::paragraphs::{Paragraph, Paragraphs}, + ComponentExt, + }, + flow::{ + base::{Decision, DecisionBuilder as _}, + FlowController, FlowMsg, SwipeFlow, + }, + geometry::Direction, + model_mercury::component::SwipeContent, + }, +}; + +use super::super::{ + component::{Frame, FrameMsg, VerticalMenu, VerticalMenuChoiceMsg}, + theme, +}; + +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum SetNewWipeCode { + Intro, + Menu, +} + +impl FlowController for SetNewWipeCode { + #[inline] + fn index(&'static self) -> usize { + *self as usize + } + + fn handle_swipe(&'static self, direction: Direction) -> Decision { + match (self, direction) { + (Self::Intro, Direction::Left) => Self::Menu.swipe(direction), + (Self::Intro, Direction::Up) => self.return_msg(FlowMsg::Confirmed), + (Self::Menu, Direction::Right) => Self::Intro.swipe(direction), + _ => self.do_nothing(), + } + } + + fn handle_event(&'static self, msg: FlowMsg) -> Decision { + match (self, msg) { + (Self::Intro, FlowMsg::Info) => Self::Menu.goto(), + (Self::Menu, FlowMsg::Choice(0)) => self.return_msg(FlowMsg::Cancelled), + (Self::Menu, FlowMsg::Cancelled) => self.return_msg(FlowMsg::Cancelled), + _ => self.do_nothing(), + } + } +} + +pub fn new_set_new_wipe_code( + title: TString<'static>, + description: TString<'static>, + cancel_title: TString<'static>, +) -> Result { + let paragraphs = Paragraphs::new(Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, description)); + let content_intro = Frame::left_aligned(title, SwipeContent::new(paragraphs)) + .with_menu_button() + .with_footer(TR::instructions__swipe_up.into(), None) + .with_swipe(Direction::Up, SwipeSettings::default()) + .with_subtitle(TR::words__settings.into()) + .with_swipe(Direction::Left, SwipeSettings::default()) + .map(|msg| match msg { + FrameMsg::Button(bm) => Some(bm), + _ => None, + }); + + let content_menu = Frame::left_aligned( + "".into(), + VerticalMenu::empty().danger(theme::ICON_CANCEL, cancel_title), + ) + .with_cancel_button() + .with_swipe(Direction::Right, SwipeSettings::immediate()) + .map(|msg| match msg { + FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), + FrameMsg::Button(FlowMsg::Cancelled) => Some(FlowMsg::Cancelled), + FrameMsg::Button(_) => None, + }); + + let res = SwipeFlow::new(&SetNewWipeCode::Intro)? + .with_page(&SetNewWipeCode::Intro, content_intro)? + .with_page(&SetNewWipeCode::Menu, content_menu)?; + Ok(res) +} diff --git a/core/embed/rust/src/ui/model_mercury/flow/mod.rs b/core/embed/rust/src/ui/model_mercury/flow/mod.rs index 150455bddb..4e03b2ab9b 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/mod.rs @@ -6,6 +6,7 @@ pub mod confirm_homescreen; pub mod confirm_output; pub mod confirm_reset; pub mod confirm_set_new_pin; +pub mod confirm_set_new_wipe_code; pub mod confirm_summary; pub mod continue_recovery_homepage; pub mod get_address; @@ -29,6 +30,7 @@ pub use confirm_homescreen::new_confirm_homescreen; pub use confirm_output::new_confirm_output; pub use confirm_reset::new_confirm_reset; pub use confirm_set_new_pin::SetNewPin; +pub use confirm_set_new_wipe_code::SetNewWipeCode; pub use confirm_summary::new_confirm_summary; pub use continue_recovery_homepage::new_continue_recovery_homepage; pub use get_address::GetAddress; diff --git a/core/embed/rust/src/ui/model_mercury/ui_firmware.rs b/core/embed/rust/src/ui/model_mercury/ui_firmware.rs index 716eabdf20..2935bee2b2 100644 --- a/core/embed/rust/src/ui/model_mercury/ui_firmware.rs +++ b/core/embed/rust/src/ui/model_mercury/ui_firmware.rs @@ -631,8 +631,22 @@ impl FirmwareUI for UIMercury { fn flow_confirm_set_new_pin( title: TString<'static>, description: TString<'static>, + cancel_title: TString<'static>, ) -> Result { - let flow = flow::confirm_set_new_pin::new_set_new_pin(title, description)?; + let flow = flow::confirm_set_new_pin::new_set_new_pin(title, description, cancel_title)?; + Ok(flow) + } + + fn flow_confirm_set_new_wipe_code( + title: TString<'static>, + description: TString<'static>, + cancel_title: TString<'static>, + ) -> Result { + let flow = flow::confirm_set_new_wipe_code::new_set_new_wipe_code( + title, + description, + cancel_title, + )?; Ok(flow) } diff --git a/core/embed/rust/src/ui/model_tr/ui_firmware.rs b/core/embed/rust/src/ui/model_tr/ui_firmware.rs index 8f8fdde3d2..7ee62bafde 100644 --- a/core/embed/rust/src/ui/model_tr/ui_firmware.rs +++ b/core/embed/rust/src/ui/model_tr/ui_firmware.rs @@ -724,12 +724,23 @@ impl FirmwareUI for UIModelTR { fn flow_confirm_set_new_pin( _title: TString<'static>, _description: TString<'static>, + _cancel_title: TString<'static>, ) -> Result { Err::, Error>(Error::ValueError( c"flow_confirm_set_new_pin not supported", )) } + fn flow_confirm_set_new_wipe_code( + _title: TString<'static>, + _description: TString<'static>, + _cancel_title: TString<'static>, + ) -> Result { + Err::, Error>(Error::ValueError( + c"flow_confirm_set_new_wipe_code not supported", + )) + } + fn flow_get_address( _address: Obj, _title: TString<'static>, diff --git a/core/embed/rust/src/ui/model_tt/ui_firmware.rs b/core/embed/rust/src/ui/model_tt/ui_firmware.rs index 4f9b0c5085..f16d6c2de5 100644 --- a/core/embed/rust/src/ui/model_tt/ui_firmware.rs +++ b/core/embed/rust/src/ui/model_tt/ui_firmware.rs @@ -575,12 +575,23 @@ impl FirmwareUI for UIModelTT { fn flow_confirm_set_new_pin( _title: TString<'static>, _description: TString<'static>, + _cancel_title: TString<'static>, ) -> Result { Err::, Error>(Error::ValueError( c"flow_confirm_set_new_pin not supported", )) } + fn flow_confirm_set_new_wipe_code( + _title: TString<'static>, + _description: TString<'static>, + _cancel_title: TString<'static>, + ) -> Result { + Err::, Error>(Error::ValueError( + c"flow_confirm_set_new_wipe_code not supported", + )) + } + fn flow_get_address( _address: Obj, _title: TString<'static>, diff --git a/core/embed/rust/src/ui/ui_firmware.rs b/core/embed/rust/src/ui/ui_firmware.rs index 5179674511..a382d8eae6 100644 --- a/core/embed/rust/src/ui/ui_firmware.rs +++ b/core/embed/rust/src/ui/ui_firmware.rs @@ -197,6 +197,13 @@ pub trait FirmwareUI { fn flow_confirm_set_new_pin( title: TString<'static>, description: TString<'static>, + cancel_title: TString<'static>, + ) -> Result; + + fn flow_confirm_set_new_wipe_code( + title: TString<'static>, + description: TString<'static>, + cancel_title: TString<'static>, ) -> Result; #[allow(clippy::too_many_arguments)] diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index 2b21ee96cd..bfc6341a8b 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -340,10 +340,21 @@ def flow_confirm_set_new_pin( *, title: str, description: str, + cancel_title: str, ) -> LayoutObj[UiResult]: """Confirm new PIN setup with an option to cancel action.""" +# rust/src/ui/api/firmware_micropython.rs +def flow_confirm_set_new_wipe_code( + *, + title: str, + description: str, + cancel_title: str, +) -> LayoutObj[UiResult]: + """Confirm new wipe code setup with an option to cancel action.""" + + # rust/src/ui/api/firmware_micropython.rs def flow_get_address( *, diff --git a/core/mocks/trezortranslate_keys.pyi b/core/mocks/trezortranslate_keys.pyi index 8454099bfd..06c5686d41 100644 --- a/core/mocks/trezortranslate_keys.pyi +++ b/core/mocks/trezortranslate_keys.pyi @@ -526,7 +526,7 @@ class TR: pin__enter: str = "Enter PIN" pin__enter_new: str = "Enter new PIN" pin__entered_not_valid: str = "The PIN you have entered is not valid." - pin__info: str = "PIN will be required to access this device." + pin__info: str = "The PIN will be required to access this device." pin__invalid_pin: str = "Invalid PIN" pin__last_attempt: str = "Last attempt" pin__mismatch: str = "Entered PINs do not match!" @@ -536,7 +536,7 @@ class TR: pin__reenter_to_confirm: str = "Please re-enter PIN to confirm." pin__should_be_long: str = "PIN should be 4-50 digits long." pin__title_check_pin: str = "Check PIN" - pin__title_settings: str = "PIN settings" + pin__title_settings: str = "PIN" pin__title_wrong_pin: str = "Wrong PIN" pin__tries_left: str = "tries left" pin__turn_off: str = "Are you sure you want to turn off PIN protection?" @@ -902,8 +902,8 @@ class TR: wipe_code__change: str = "Change wipe code?" wipe_code__changed: str = "Wipe code changed." wipe_code__diff_from_pin: str = "The wipe code must be different from your PIN." - wipe_code__disabled: str = "Wipe code disabled." - wipe_code__enabled: str = "Wipe code enabled." + wipe_code__disabled: str = "Wipe code protection turned off." + wipe_code__enabled: str = "Wipe code protection turned on." wipe_code__enter_new: str = "Enter new wipe code" wipe_code__info: str = "Wipe code can be used to erase all data from this device." wipe_code__invalid: str = "Invalid wipe code" @@ -912,7 +912,7 @@ class TR: wipe_code__reenter_to_confirm: str = "Please re-enter wipe code to confirm." wipe_code__title_check: str = "Check wipe code" wipe_code__title_invalid: str = "Invalid wipe code" - wipe_code__title_settings: str = "Wipe code settings" + wipe_code__title_settings: str = "Wipe code" wipe_code__turn_off: str = "Turn off wipe code protection?" wipe_code__turn_on: str = "Turn on wipe code protection?" wipe_code__wipe_code_mismatch: str = "Wipe code mismatch" diff --git a/core/src/apps/bitcoin/sign_tx/layout.py b/core/src/apps/bitcoin/sign_tx/layout.py index 8f9fed1e51..2c667b22da 100644 --- a/core/src/apps/bitcoin/sign_tx/layout.py +++ b/core/src/apps/bitcoin/sign_tx/layout.py @@ -265,7 +265,7 @@ async def confirm_feeoverthreshold( await layouts.show_warning( "fee_over_threshold", TR.bitcoin__unusually_high_fee, - fee_amount, + subheader=fee_amount, br_code=ButtonRequestType.FeeOverThreshold, ) @@ -274,7 +274,7 @@ async def confirm_change_count_over_threshold(change_count: int) -> None: await layouts.show_warning( "change_count_over_threshold", TR.bitcoin__lot_of_change_outputs, - f"{str(change_count)} {TR.words__outputs}", + subheader=f"{str(change_count)} {TR.words__outputs}", br_code=ButtonRequestType.SignTx, ) @@ -283,7 +283,7 @@ async def confirm_unverified_external_input() -> None: await layouts.show_warning( "unverified_external_input", TR.bitcoin__unverified_external_inputs, - TR.words__continue_anyway_question, + subheader=TR.words__continue_anyway_question, button=TR.buttons__continue, br_code=ButtonRequestType.SignTx, ) @@ -293,7 +293,7 @@ async def confirm_multiple_accounts() -> None: await layouts.show_warning( "sending_from_multiple_accounts", TR.send__from_multiple_accounts, - TR.words__continue_anyway_question, + subheader=TR.words__continue_anyway_question, button=TR.buttons__continue, br_code=ButtonRequestType.SignTx, ) @@ -306,7 +306,7 @@ async def confirm_nondefault_locktime(lock_time: int, lock_time_disabled: bool) await layouts.show_warning( "nondefault_locktime", TR.bitcoin__locktime_no_effect, - TR.words__continue_anyway_question, + subheader=TR.words__continue_anyway_question, button=TR.buttons__continue, br_code=ButtonRequestType.SignTx, ) diff --git a/core/src/apps/cardano/layout.py b/core/src/apps/cardano/layout.py index 55b1052b6f..14654455d6 100644 --- a/core/src/apps/cardano/layout.py +++ b/core/src/apps/cardano/layout.py @@ -486,7 +486,7 @@ async def warn_unknown_total_collateral() -> None: await layouts.show_warning( "confirm_unknown_total_collateral", TR.cardano__unknown_collateral_amount, - TR.cardano__check_all_items, + subheader=TR.cardano__check_all_items, br_code=BRT_Other, ) diff --git a/core/src/apps/management/change_pin.py b/core/src/apps/management/change_pin.py index cf0cc95179..941ad5dfe3 100644 --- a/core/src/apps/management/change_pin.py +++ b/core/src/apps/management/change_pin.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING -from trezor import TR, config, wire +from trezor import TR, config, utils, wire if TYPE_CHECKING: from typing import Awaitable @@ -67,10 +67,16 @@ def _require_confirm_change_pin(msg: ChangePin) -> Awaitable[None]: has_pin = config.has_pin() + if utils.UI_LAYOUT == "MERCURY": + title = TR.pin__title_settings + else: + title = TR.pin__title_settings + " " + TR.words__settings + if msg.remove and has_pin: # removing pin return confirm_action( "disable_pin", - TR.pin__title_settings, + title, + subtitle=TR.words__settings, description=TR.pin__turn_off, verb=TR.buttons__turn_off, ) @@ -78,7 +84,8 @@ def _require_confirm_change_pin(msg: ChangePin) -> Awaitable[None]: if not msg.remove and has_pin: # changing pin return confirm_action( "change_pin", - TR.pin__title_settings, + title, + subtitle=TR.words__settings, description=TR.pin__change, verb=TR.buttons__change, prompt_screen=False, @@ -87,8 +94,9 @@ def _require_confirm_change_pin(msg: ChangePin) -> Awaitable[None]: if not msg.remove and not has_pin: # setting new pin return confirm_set_new_pin( "set_pin", - TR.pin__title_settings, + title, TR.pin__turn_on, + TR.pin__cancel_setup, TR.pin__info, ) diff --git a/core/src/apps/management/change_wipe_code.py b/core/src/apps/management/change_wipe_code.py index b5256fd459..0f735bb91d 100644 --- a/core/src/apps/management/change_wipe_code.py +++ b/core/src/apps/management/change_wipe_code.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING -from trezor import TR +from trezor import TR, utils if TYPE_CHECKING: from typing import Awaitable @@ -62,10 +62,16 @@ def _require_confirm_action( from trezor.ui.layouts import confirm_action, confirm_set_new_pin from trezor.wire import ProcessError + if utils.UI_LAYOUT == "MERCURY": + title = TR.wipe_code__title_settings + else: + title = TR.wipe_code__title_settings + " " + TR.words__settings + if msg.remove and has_wipe_code: return confirm_action( "disable_wipe_code", - TR.wipe_code__title_settings, + title, + subtitle=TR.words__settings, description=TR.wipe_code__turn_off, verb=TR.buttons__turn_off, prompt_screen=True, @@ -74,7 +80,8 @@ def _require_confirm_action( if not msg.remove and has_wipe_code: return confirm_action( "change_wipe_code", - TR.wipe_code__title_settings, + title, + subtitle=TR.words__settings, description=TR.wipe_code__change, verb=TR.buttons__change, ) @@ -82,9 +89,11 @@ def _require_confirm_action( if not msg.remove and not has_wipe_code: return confirm_set_new_pin( "set_wipe_code", - TR.wipe_code__title_settings, + title, TR.wipe_code__turn_on, + TR.buttons__cancel, TR.wipe_code__info, + is_wipe_code=True, ) # Removing non-existing wipe code. diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index 54b1e49b26..c31cab9a7d 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -309,14 +309,16 @@ async def show_error_and_raise( def show_warning( br_name: str, content: str, + title: str | None = None, subheader: str | None = None, button: str | None = None, br_code: ButtonRequestType = ButtonRequestType.Warning, ) -> Awaitable[None]: button = button or TR.buttons__continue # def_arg + title = title or TR.words__important return raise_if_not_confirmed( trezorui_api.show_warning( - title=TR.words__important, + title=title, value=content, button=subheader or TR.words__continue_anyway_question, danger=True, @@ -1173,31 +1175,30 @@ async def confirm_reenter_pin(is_wipe_code: bool = False) -> None: pass -def pin_mismatch_popup(is_wipe_code: bool = False) -> Awaitable[ui.UiResult]: - title = TR.wipe_code__mismatch if is_wipe_code else TR.pin__mismatch +def pin_mismatch_popup(is_wipe_code: bool = False) -> Awaitable[None]: + content = TR.wipe_code__mismatch if is_wipe_code else TR.pin__mismatch description = TR.wipe_code__enter_new if is_wipe_code else TR.pin__reenter_new br_name = "wipe_code_mismatch" if is_wipe_code else "pin_mismatch" - return interact( - error_popup( - title, - description, - button=TR.buttons__try_again, - ), + return show_warning( br_name, - BR_CODE_OTHER, + content=content, + title=TR.words__warning, + subheader=description, + button="button", + br_code=BR_CODE_OTHER, ) -def wipe_code_same_as_pin_popup() -> Awaitable[ui.UiResult]: - return interact( - error_popup( - TR.wipe_code__invalid, - TR.wipe_code__diff_from_pin, - button=TR.buttons__try_again, - ), +def wipe_code_same_as_pin_popup() -> Awaitable[None]: + + return show_warning( "wipe_code_same_as_pin", - BR_CODE_OTHER, + content=TR.wipe_code__diff_from_pin, + title=TR.words__warning, + subheader=TR.wipe_code__enter_new, + button="button", + br_code=BR_CODE_OTHER, ) @@ -1205,14 +1206,31 @@ def confirm_set_new_pin( br_name: str, title: str, description: str, + cancel_title: str, information: str, + is_wipe_code: bool = False, br_code: ButtonRequestType = BR_CODE_OTHER, ) -> Awaitable[None]: - return raise_if_not_confirmed( - trezorui_api.flow_confirm_set_new_pin(title=title, description=description), - br_name, - br_code, - ) + if is_wipe_code: + return raise_if_not_confirmed( + trezorui_api.flow_confirm_set_new_wipe_code( + title=title, + description=description + "\n" + information, + cancel_title=cancel_title, + ), + br_name, + br_code, + ) + else: + return raise_if_not_confirmed( + trezorui_api.flow_confirm_set_new_pin( + title=title, + description=description + "\n" + information, + cancel_title=cancel_title, + ), + br_name, + br_code, + ) def confirm_firmware_update(description: str, fingerprint: str) -> Awaitable[None]: diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 807baeac02..3182c1c21a 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1295,7 +1295,9 @@ async def confirm_set_new_pin( br_name: str, title: str, description: str, + cancel_title: str, # unused for model r information: str, + is_wipe_code: bool = False, # unused for model r br_code: ButtonRequestType = BR_CODE_OTHER, ) -> None: await _confirm_multiple_pages_texts( diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 9248293c95..34488d2269 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -1277,7 +1277,9 @@ def confirm_set_new_pin( br_name: str, title: str, description: str, + cancel_title: str, # unused for model t information: str, + is_wipe_code: bool = False, # unused for model t br_code: ButtonRequestType = BR_CODE_OTHER, ) -> Awaitable[None]: return raise_if_not_confirmed( diff --git a/core/translations/en.json b/core/translations/en.json index 02edf7b9fe..ed6ba97de4 100644 --- a/core/translations/en.json +++ b/core/translations/en.json @@ -528,7 +528,7 @@ "pin__enter": "Enter PIN", "pin__enter_new": "Enter new PIN", "pin__entered_not_valid": "The PIN you have entered is not valid.", - "pin__info": "PIN will be required to access this device.", + "pin__info": "The PIN will be required to access this device.", "pin__invalid_pin": "Invalid PIN", "pin__last_attempt": "Last attempt", "pin__mismatch": "Entered PINs do not match!", @@ -538,7 +538,7 @@ "pin__reenter_to_confirm": "Please re-enter PIN to confirm.", "pin__should_be_long": "PIN should be 4-50 digits long.", "pin__title_check_pin": "Check PIN", - "pin__title_settings": "PIN settings", + "pin__title_settings": "PIN", "pin__title_wrong_pin": "Wrong PIN", "pin__tries_left": "tries left", "pin__turn_off": "Are you sure you want to turn off PIN protection?", @@ -904,8 +904,8 @@ "wipe_code__change": "Change wipe code?", "wipe_code__changed": "Wipe code changed.", "wipe_code__diff_from_pin": "The wipe code must be different from your PIN.", - "wipe_code__disabled": "Wipe code disabled.", - "wipe_code__enabled": "Wipe code enabled.", + "wipe_code__disabled": "Wipe code protection turned off.", + "wipe_code__enabled": "Wipe code protection turned on.", "wipe_code__enter_new": "Enter new wipe code", "wipe_code__info": "Wipe code can be used to erase all data from this device.", "wipe_code__invalid": "Invalid wipe code", @@ -914,7 +914,7 @@ "wipe_code__reenter_to_confirm": "Please re-enter wipe code to confirm.", "wipe_code__title_check": "Check wipe code", "wipe_code__title_invalid": "Invalid wipe code", - "wipe_code__title_settings": "Wipe code settings", + "wipe_code__title_settings": "Wipe code", "wipe_code__turn_off": "Turn off wipe code protection?", "wipe_code__turn_on": "Turn on wipe code protection?", "wipe_code__wipe_code_mismatch": "Wipe code mismatch", diff --git a/core/translations/signatures.json b/core/translations/signatures.json index 7c7b10a022..25c31822c5 100644 --- a/core/translations/signatures.json +++ b/core/translations/signatures.json @@ -1,8 +1,8 @@ { "current": { "merkle_root": "53515eead12df806f139761eddc91f2aa2d3de3b9e0eb831552167ee25897f4a", - "datetime": "2024-12-16T11:26:54.578708", - "commit": "76301b1e97ea5ce0a2e17967f44a9db2a2e905e4" + "datetime": "2024-12-18T22:06:09.895866", + "commit": "8dccc8e1d52ff8900bf7ef2a563ba230464fc831" }, "history": [ {