From 808317424df1646cd478a5af7e87d6f07caccfe0 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 26 Sep 2017 12:05:05 +0200 Subject: [PATCH] use trezor.ui.{BG,FG} --- src/apps/common/request_pin.py | 2 +- src/apps/fido_u2f/__init__.py | 4 ++-- src/apps/homescreen/homescreen.py | 4 ++-- src/apps/management/recovery_device.py | 6 +++--- src/apps/management/reset_device.py | 12 ++++++------ src/apps/wallet/cipher_key_value.py | 4 ++-- src/apps/wallet/sign_identity.py | 6 +++--- src/apps/wallet/sign_message.py | 4 ++-- src/apps/wallet/verify_message.py | 6 +++--- src/trezor/ui/__init__.py | 2 +- src/trezor/ui/button.py | 2 +- src/trezor/ui/keyboard.py | 16 ++++++++-------- src/trezor/ui/loader.py | 4 ++-- src/trezor/ui/pin.py | 4 ++-- src/trezor/ui/scroll.py | 10 +++++----- src/trezor/ui/text.py | 6 +++--- 16 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/apps/common/request_pin.py b/src/apps/common/request_pin.py index a2fdb6da26..e0c6fd82a2 100644 --- a/src/apps/common/request_pin.py +++ b/src/apps/common/request_pin.py @@ -123,7 +123,7 @@ protect_by_pin = protect_by_pin_or_fail def _render_pin_failure(sleep_ms: int): ui.display.clear() ui.display.text_center(240, 240, 'Sleeping for %d seconds' % (sleep_ms / 1000), - ui.BOLD, ui.RED, ui.BLACK) + ui.BOLD, ui.RED, ui.BG) def _get_code_and_label(code: int): diff --git a/src/apps/fido_u2f/__init__.py b/src/apps/fido_u2f/__init__.py index 9bb27c5c33..9f26320c37 100644 --- a/src/apps/fido_u2f/__init__.py +++ b/src/apps/fido_u2f/__init__.py @@ -425,9 +425,9 @@ class ConfirmContent(ui.Widget): header = 'U2F Register' else: header = 'U2F Authenticate' - ui.header(header, ui.ICON_RESET, ui.GREEN, ui.BLACK) + ui.header(header, ui.ICON_RESET, ui.GREEN, ui.BG) ui.display.image((240 - 64) // 2, 90, self.app_icon) - ui.display.text_center(120, 185, self.app_name, ui.MONO, ui.WHITE, ui.BLACK) + ui.display.text_center(120, 185, self.app_name, ui.MONO, ui.FG, ui.BG) _CONFIRM_STATE_TIMEOUT_MS = const(10 * 1000) diff --git a/src/apps/homescreen/homescreen.py b/src/apps/homescreen/homescreen.py index 09641961b0..f493b6a855 100644 --- a/src/apps/homescreen/homescreen.py +++ b/src/apps/homescreen/homescreen.py @@ -20,7 +20,7 @@ def display_homescreen(): from apps.common import storage image = res.load('apps/homescreen/res/trezor_logo.toig') - ui.display.icon(0, 0, image, ui.WHITE, ui.BLACK) + ui.display.icon(0, 0, image, ui.FG, ui.BG) if not storage.is_initialized(): label = 'Go to trezor.io/start' @@ -28,7 +28,7 @@ def display_homescreen(): label = storage.get_label() if not label: label = 'My TREZOR' - ui.display.text_center(120, 210, label, ui.BOLD, ui.WHITE, ui.BLACK) + ui.display.text_center(120, 210, label, ui.BOLD, ui.FG, ui.BG) @unimport diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index 3dc2dd2cc5..15c3f22511 100644 --- a/src/apps/management/recovery_device.py +++ b/src/apps/management/recovery_device.py @@ -16,8 +16,8 @@ async def layout_recovery_device(ctx, msg): msg = 'Please enter ' + nth(msg.word_count) + ' word' ui.display.clear() - ui.header('Recovery device', ui.ICON_RECOVERY, ui.BLACK, ui.LIGHT_GREEN) - ui.display.text(10, 74, msg, ui.BOLD, ui.WHITE, ui.BLACK) - ui.display.text(10, 104, 'of your mnemonic.', ui.BOLD, ui.WHITE, ui.BLACK) + ui.header('Recovery device', ui.ICON_RECOVERY, ui.BG, ui.LIGHT_GREEN) + ui.display.text(10, 74, msg, ui.BOLD, ui.FG, ui.BG) + ui.display.text(10, 104, 'of your mnemonic.', ui.BOLD, ui.FG, ui.BG) # TODO diff --git a/src/apps/management/reset_device.py b/src/apps/management/reset_device.py index 0990b1f903..294cde75d9 100644 --- a/src/apps/management/reset_device.py +++ b/src/apps/management/reset_device.py @@ -104,11 +104,11 @@ async def show_mnemonic(mnemonic): async def show_mnemonic_page(page, page_count, mnemonic): - from trezor.ui.button import Button, CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE + from trezor.ui.button import Button from trezor.ui.scroll import render_scrollbar, animate_swipe ui.display.clear() - ui.header('Write down your seed', ui.ICON_RESET, ui.BLACK, ui.LIGHT_GREEN) + ui.header('Write down your seed', ui.ICON_RESET, ui.BG, ui.LIGHT_GREEN) render_scrollbar(page, page_count) for pi, (wi, word) in enumerate(mnemonic[page]): @@ -118,14 +118,14 @@ async def show_mnemonic_page(page, page_count, mnemonic): if pos > 9: offset += 12 ui.display.text( - 10, top, '%d.' % pos, ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) + 10, top, '%d.' % pos, ui.BOLD, ui.LIGHT_GREEN, ui.BG) ui.display.text( - 30 + offset, top, '%s' % word, ui.BOLD, ui.WHITE, ui.BLACK) + 30 + offset, top, '%s' % word, ui.BOLD, ui.FG, ui.BG) if page + 1 == page_count: await Button( (0, 240 - 48, 240, 48), 'Finish', - normal_style=CONFIRM_BUTTON, - active_style=CONFIRM_BUTTON_ACTIVE) + normal_style=ui.BTN_CONFIRM, + active_style=ui.BTN_CONFIRM_ACTIVE) else: await animate_swipe() diff --git a/src/apps/wallet/cipher_key_value.py b/src/apps/wallet/cipher_key_value.py index f8eded02f0..fc9bca60ab 100644 --- a/src/apps/wallet/cipher_key_value.py +++ b/src/apps/wallet/cipher_key_value.py @@ -35,8 +35,8 @@ async def layout_cipher_key_value(ctx, msg): ui.display.clear() ui.display.text(10, 30, 'CipherKeyValue', - ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) - ui.display.text(10, 60, msg.key, ui.MONO, ui.WHITE, ui.BLACK) + ui.BOLD, ui.LIGHT_GREEN, ui.BG) + ui.display.text(10, 60, msg.key, ui.MONO, ui.FG, ui.BG) node = await seed.get_root(ctx) node.derive_path(msg.address_n) diff --git a/src/apps/wallet/sign_identity.py b/src/apps/wallet/sign_identity.py index d653f454ac..2ffdc3601c 100644 --- a/src/apps/wallet/sign_identity.py +++ b/src/apps/wallet/sign_identity.py @@ -20,9 +20,9 @@ def serialize_identity(identity): def display_identity(identity: str, challenge_visual: str): ui.display.clear() ui.display.text(10, 30, 'Identity:', - ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) - ui.display.text(10, 60, challenge_visual, ui.MONO, ui.WHITE, ui.BLACK) - ui.display.text(10, 80, identity, ui.MONO, ui.WHITE, ui.BLACK) + ui.BOLD, ui.LIGHT_GREEN, ui.BG) + ui.display.text(10, 60, challenge_visual, ui.MONO, ui.FG, ui.BG) + ui.display.text(10, 80, identity, ui.MONO, ui.FG, ui.BG) def get_identity_path(identity: str, index: int): diff --git a/src/apps/wallet/sign_message.py b/src/apps/wallet/sign_message.py index 26b54f6112..0b63a72b50 100644 --- a/src/apps/wallet/sign_message.py +++ b/src/apps/wallet/sign_message.py @@ -12,8 +12,8 @@ async def layout_sign_message(ctx, msg): ui.display.clear() ui.display.text(10, 30, 'Signing message', - ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) - ui.display.text(10, 60, msg.message, ui.MONO, ui.WHITE, ui.BLACK) + ui.BOLD, ui.LIGHT_GREEN, ui.BG) + ui.display.text(10, 60, msg.message, ui.MONO, ui.FG, ui.BG) coin_name = msg.coin_name or 'Bitcoin' coin = coins.by_name(coin_name) diff --git a/src/apps/wallet/verify_message.py b/src/apps/wallet/verify_message.py index c3731cbb8a..92d348c5af 100644 --- a/src/apps/wallet/verify_message.py +++ b/src/apps/wallet/verify_message.py @@ -30,8 +30,8 @@ async def layout_verify_message(ctx, msg): ui.display.clear() ui.display.text(10, 30, 'Verifying message', - ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) - ui.display.text(10, 60, msg.message, ui.MONO, ui.WHITE, ui.BLACK) - ui.display.text(10, 80, msg.address, ui.MONO, ui.WHITE, ui.BLACK) + ui.BOLD, ui.LIGHT_GREEN, ui.BG) + ui.display.text(10, 60, msg.message, ui.MONO, ui.FG, ui.BG) + ui.display.text(10, 80, msg.address, ui.MONO, ui.FG, ui.BG) return Success(message='Message verified') diff --git a/src/trezor/ui/__init__.py b/src/trezor/ui/__init__.py index 1a6728d592..8549fae375 100644 --- a/src/trezor/ui/__init__.py +++ b/src/trezor/ui/__init__.py @@ -101,7 +101,7 @@ def layout(f): return inner -def header(title: str, icon: bytes=ICON_RESET, fg: int=BLACK, bg: int=BLACK): +def header(title: str, icon: bytes=ICON_RESET, fg: int=BG, bg: int=BG): display.bar(0, 0, 240, 32, bg) if icon is not None: display.icon(8, 4, res.load(icon), fg, bg) diff --git a/src/trezor/ui/button.py b/src/trezor/ui/button.py index 39f20811dc..c8749ae031 100644 --- a/src/trezor/ui/button.py +++ b/src/trezor/ui/button.py @@ -56,7 +56,7 @@ class Button(Widget): ty = ay + ah // 2 + 8 display.bar_radius(ax, ay, aw, ah, s['border-color'], - ui.BLACK, + ui.BG, s['radius']) display.bar_radius(ax + 1, ay + 1, aw - 2, ah - 2, s['bg-color'], diff --git a/src/trezor/ui/keyboard.py b/src/trezor/ui/keyboard.py index 7e4a1da43c..1f83a15612 100644 --- a/src/trezor/ui/keyboard.py +++ b/src/trezor/ui/keyboard.py @@ -49,29 +49,29 @@ class KeyboardMultiTap(ui.Widget): def render(self): # clear canvas under input line - display.bar(0, 0, 205, 40, ui.BLACK) + display.bar(0, 0, 205, 40, ui.BG) # input line content_width = display.text_width(self.content, ui.BOLD) - display.text(20, 30, self.content, ui.BOLD, ui.WHITE, ui.BLACK) + display.text(20, 30, self.content, ui.BOLD, ui.FG, ui.BG) # pending marker if self.pending_button is not None: pending_width = display.text_width(self.content[-1:], ui.BOLD) pending_x = 20 + content_width - pending_width - display.bar(pending_x, 33, pending_width + 2, 3, ui.WHITE) + display.bar(pending_x, 33, pending_width + 2, 3, ui.FG) # auto-suggest if self.sugg_word is not None: sugg_rest = self.sugg_word[len(self.content):] sugg_x = 20 + content_width - display.text(sugg_x, 30, sugg_rest, ui.BOLD, ui.GREY, ui.BLACK) + display.text(sugg_x, 30, sugg_rest, ui.BOLD, ui.GREY, ui.BG) # render backspace button if self.content: self.bs_button.render() else: - display.bar(240 - 48, 0, 48, 42, ui.BLACK) + display.bar(240 - 48, 0, 48, 42, ui.BG) # key buttons for btn in self.key_buttons: @@ -173,10 +173,10 @@ class KeyboardZooming(ui.Widget): def render_input(self): if self.content: - display.bar(0, 0, 200, 40, ui.BLACK) + display.bar(0, 0, 200, 40, ui.BG) else: - display.bar(0, 0, 240, 40, ui.BLACK) - display.text(20, 30, self.content, ui.BOLD, ui.GREY, ui.BLACK) + display.bar(0, 0, 240, 40, ui.BG) + display.text(20, 30, self.content, ui.BOLD, ui.GREY, ui.BG) if self.content: self.bs_button.render() diff --git a/src/trezor/ui/loader.py b/src/trezor/ui/loader.py index 9070c8722e..8661e92b09 100644 --- a/src/trezor/ui/loader.py +++ b/src/trezor/ui/loader.py @@ -14,10 +14,10 @@ class Loader(ui.Widget): def start(self): self.start_ticks_ms = utime.ticks_ms() - ui.display.bar(0, 32, 240, 240 - 80, ui.BLACK) + ui.display.bar(0, 32, 240, 240 - 80, ui.BG) def stop(self): - ui.display.bar(0, 32, 240, 240 - 80, ui.BLACK) + ui.display.bar(0, 32, 240, 240 - 80, ui.BG) ticks_diff = utime.ticks_ms() - self.start_ticks_ms self.start_ticks_ms = None return ticks_diff >= self.target_ms diff --git a/src/trezor/ui/pin.py b/src/trezor/ui/pin.py index 39737ad1cc..f1de3f0b57 100644 --- a/src/trezor/ui/pin.py +++ b/src/trezor/ui/pin.py @@ -45,10 +45,10 @@ class PinMatrix(ui.Widget): header = '*' * len(self.pin) if self.pin else self.label # clear canvas under input line - display.bar(0, 0, 205, 48, ui.BLACK) + display.bar(0, 0, 205, 48, ui.BG) # input line with a header - display.text_center(120, 30, header, ui.BOLD, ui.GREY, ui.BLACK) + display.text_center(120, 30, header, ui.BOLD, ui.GREY, ui.BG) # pin matrix buttons for btn in self.pin_buttons: diff --git a/src/trezor/ui/scroll.py b/src/trezor/ui/scroll.py index aa5f3b17e5..2eabbd7a7c 100644 --- a/src/trezor/ui/scroll.py +++ b/src/trezor/ui/scroll.py @@ -37,9 +37,9 @@ async def animate_swipe(): sleep = loop.sleep(time_delay) for t in ui.pulse(draw_delay): fg = ui.blend(ui.GREY, ui.DARK_GREY, t) - ui.display.bar_radius(102, 214, 36, 4, fg, ui.BLACK, 2) - ui.display.bar_radius(106, 222, 28, 4, fg, ui.BLACK, 2) - ui.display.bar_radius(110, 230, 20, 4, fg, ui.BLACK, 2) + ui.display.bar_radius(102, 214, 36, 4, fg, ui.BG, 2) + ui.display.bar_radius(106, 222, 28, 4, fg, ui.BG, 2) + ui.display.bar_radius(110, 230, 20, 4, fg, ui.BG, 2) await sleep @@ -57,6 +57,6 @@ def render_scrollbar(page, page_count): for i in range(0, page_count): if i != page: ui.display.bar_radius(x, y + i * padding, size, - size, ui.DARK_GREY, ui.BLACK, 4) + size, ui.DARK_GREY, ui.BG, 4) ui.display.bar_radius(x, y + page * padding, size, - size, ui.WHITE, ui.BLACK, 4) + size, ui.FG, ui.BG, 4) diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index 1c03599756..7b49b6591c 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -17,9 +17,9 @@ class Text(ui.Widget): offset_x = TEXT_MARGIN_LEFT offset_y = TEXT_LINE_HEIGHT + TEXT_HEADER_HEIGHT style = ui.NORMAL - fg = ui.WHITE - bg = ui.BLACK - ui.header(self.header_text, self.header_icon, ui.GREEN, ui.BLACK) + fg = ui.FG + bg = ui.BG + ui.header(self.header_text, self.header_icon, ui.GREEN, ui.BG) for item in self.content: if isinstance(item, str):