From 5a79f318a444798f28d481e5882cb86e3b54ba00 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 10 Dec 2018 17:56:54 +0100 Subject: [PATCH] src/apps/management: add link to ToS to reset_device --- src/apps/management/reset_device.py | 12 ++++++++++-- src/trezor/ui/text.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/apps/management/reset_device.py b/src/apps/management/reset_device.py index cd155cb34..d711a7342 100644 --- a/src/apps/management/reset_device.py +++ b/src/apps/management/reset_device.py @@ -31,8 +31,16 @@ async def reset_device(ctx, msg): if storage.is_initialized(): raise wire.UnexpectedMessage("Already initialized") - text = Text("Create a new wallet", ui.ICON_RESET) - text.normal("Do you really want to", "create a new wallet?", "") + text = Text("Create a new wallet", ui.ICON_RESET, new_lines=False) + text.normal("Do you really want to") + text.br() + text.normal("create a new wallet?") + text.br() + text.br_half() + text.normal("By continuing you agree") + text.br() + text.normal("to") + text.bold("https://trezor.io/tos") await require_confirm(ctx, text, code=ButtonRequestType.ResetDevice) diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index 12ad405b6..e2304f151 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -4,11 +4,13 @@ from trezor import ui TEXT_HEADER_HEIGHT = const(48) TEXT_LINE_HEIGHT = const(26) +TEXT_LINE_HEIGHT_HALF = const(13) TEXT_MARGIN_LEFT = const(14) TEXT_MAX_LINES = const(5) # needs to be different from all colors and font ids BR = const(-256) +BR_HALF = const(-257) def render_text(words: list, new_lines: bool, max_lines: int) -> None: @@ -31,13 +33,13 @@ def render_text(words: list, new_lines: bool, max_lines: int) -> None: has_next_word = word_index < len(words) - 1 if isinstance(word, int): - if word == BR: - # line break + if word in [BR, BR_HALF]: + # line break or half-line break if offset_y >= OFFSET_Y_MAX: ui.display.text(offset_x, offset_y, "...", ui.BOLD, ui.GREY, bg) return offset_x = TEXT_MARGIN_LEFT - offset_y += TEXT_LINE_HEIGHT + offset_y += TEXT_LINE_HEIGHT if word == BR else TEXT_LINE_HEIGHT_HALF elif word in FONTS: # change of font style font = word @@ -141,6 +143,9 @@ class Text(ui.Widget): def br(self): self.content.append(BR) + def br_half(self): + self.content.append(BR_HALF) + def render(self): if self.tainted: ui.header(