core: fix rendering issues in homescreens

pull/971/head
matejcik 4 years ago committed by matejcik
parent 9df7c84c56
commit 7579ac5274

@ -1,18 +1,25 @@
import storage.device
from trezor import loop, res, ui
from trezor import io, loop, res, ui
class HomescreenBase(ui.Layout):
RENDER_SLEEP = loop.SLEEP_FOREVER
def __init__(self) -> None:
self.repaint = True
self.label = storage.device.get_label() or "My Trezor"
self.image = storage.device.get_homescreen() or res.load(
"apps/homescreen/res/bg.toif"
)
def render_homescreen(self) -> None:
ui.display.avatar(48, 48 - 10, self.image, ui.WHITE, ui.BLACK)
ui.display.text_center(ui.WIDTH // 2, 220, self.label, ui.BOLD, ui.FG, ui.BG)
def on_tap(self) -> None:
"""Called when the user taps the screen."""
pass
def dispatch(self, event: int, x: int, y: int) -> None:
if event is ui.REPAINT:
self.repaint = True
elif event is ui.RENDER and self.repaint:
self.repaint = False
self.on_render()
elif event is io.TOUCH_END:
self.on_tap()

@ -15,7 +15,8 @@ class Homescreen(HomescreenBase):
if not storage.is_initialized():
self.label = "Go to trezor.io/start"
def render_warning(self) -> None:
def on_render(self) -> None:
# warning bar on top
if storage.is_initialized() and storage.device.no_backup():
ui.header_error("SEEDLESS")
elif storage.is_initialized() and storage.device.unfinished_backup():
@ -27,6 +28,6 @@ class Homescreen(HomescreenBase):
else:
ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
def on_render(self) -> None:
self.render_warning()
self.render_homescreen()
# homescreen with shifted avatar and text on bottom
ui.display.avatar(48, 48 - 10, self.image, ui.WHITE, ui.BLACK)
ui.display.text_center(ui.WIDTH // 2, 220, self.label, ui.BOLD, ui.FG, ui.BG)

@ -22,28 +22,36 @@ async def lockscreen() -> None:
class Lockscreen(HomescreenBase):
BACKLIGHT_LEVEL = ui.BACKLIGHT_LOW
def __init__(
self, lock_label: str = "Locked", tap_label: str = "Tap to unlock"
) -> None:
self.lock_label = lock_label
self.tap_label = tap_label
def __init__(self, bootscreen: bool = False) -> None:
if bootscreen:
self.BACKLIGHT_LEVEL = ui.BACKLIGHT_NORMAL
self.lock_label = "Not connected"
self.tap_label = "Tap to connect"
else:
self.lock_label = "Locked"
self.tap_label = "Tap to unlock"
super().__init__()
def render_lock(self) -> None:
def on_render(self) -> None:
# homescreen with label text on top
ui.display.text_center(
ui.WIDTH // 2, 35, self.label, ui.BOLD, ui.TITLE_GREY, ui.BG
)
ui.display.avatar(48, 48, self.image, ui.WHITE, ui.BLACK)
# lock bar
ui.display.bar_radius(40, 100, 160, 40, ui.TITLE_GREY, ui.BG, 4)
ui.display.bar_radius(42, 102, 156, 36, ui.BG, ui.TITLE_GREY, 4)
ui.display.text_center(
ui.WIDTH // 2, 128, self.lock_label, ui.BOLD, ui.TITLE_GREY, ui.BG
)
# "tap to unlock"
ui.display.text_center(
ui.WIDTH // 2 + 10, 220, self.tap_label, ui.BOLD, ui.TITLE_GREY, ui.BG
)
ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.TITLE_GREY, ui.BG)
def on_render(self) -> None:
self.render_homescreen()
self.render_lock()
def on_touch_end(self, x: int, y: int) -> None:
def on_tap(self) -> None:
raise ui.Result(None)

@ -9,7 +9,7 @@ from apps.homescreen.lockscreen import Lockscreen
async def bootscreen() -> None:
lockscreen = Lockscreen(lock_label="Not connected", tap_label="Tap to connect")
lockscreen = Lockscreen(bootscreen=True)
ui.display.orientation(storage.device.get_rotation())
while True:
try:

@ -1,13 +1,13 @@
{
"test_autolock.py::test_apply_auto_lock_delay": "4b671a301ac7ed5e22d4c119f0eb3055320d8277bb5a6e0fbdc05c208d72174e",
"test_autolock.py::test_apply_minimal_auto_lock_delay": "8302f8bf2e5bf80c0b48c0e93eff1564e3863520fa8c90379a2e4073b08461cb",
"test_autolock.py::test_autolock_cancels_ui": "9a88227db5011134cbc64b7a156f5e16a40c60d1dce819e5e2e6886da3eeff57",
"test_autolock.py::test_apply_auto_lock_delay": "1997527e85989f3ca5719f93cd76bcfb8f125fb96ef3025073b13fd4de7a5fa2",
"test_autolock.py::test_apply_minimal_auto_lock_delay": "adc5da99fcc8b4023d6989fa59f69c3918e70165bdeb693a887364e2009ee2fa",
"test_autolock.py::test_autolock_cancels_ui": "eedc6196565bf6d53bc9c3f8984acc2bb91d2d71e57f3a28f8afbe35b02fb4dc",
"test_basic.py-test_device_id_different": "bc6acd0386b9d009e6550519917d6e08632b3badde0b0cf04c95abe5f773038a",
"test_basic.py-test_device_id_same": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_basic.py-test_features": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_basic.py-test_ping": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_msg_applysettings.py-test_apply_settings": "a090100b4edbc0557800629ab7d2a9501fdae3ca524705230fab2870de3250f5",
"test_msg_applysettings.py-test_apply_settings_passphrase": "43a570cf42e912a33612d4fd17fbcb092a2c79e36ee50014a1b9fc709238c37c",
"test_msg_applysettings.py-test_apply_settings": "2cc8bf660f3be815d19a4bf1265936162a58386fbe632ca4be01541245b79134",
"test_msg_applysettings.py-test_apply_settings_passphrase": "5c1ed9a0be3d14475102d447da0b5d51bbb6dfaaeceff5ea9179064609db7870",
"test_msg_applysettings.py-test_apply_settings_passphrase_on_device": "3e6527e227bdde54f51bc9c417b176d0d87fdb6c40c4761368f50eb201b4beed",
"test_msg_backup_device.py::test_backup_bip39": "2b63928444b8188eb2241fc03a3b9bc81191cfa9bbf3ef5431894c04ee0ed01f",
"test_msg_backup_device.py::test_backup_slip39_advanced": "31900e0e8ad694ce894eee1ce289b425558c1fcd7bcb6128a19c049af436d35f",
@ -38,14 +38,14 @@
"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[764824073-inputs0-outputs0-transactio": "85fb1f1bf90131d6cd04e58b2303bf8d3b9a641b1f418852bc27c4432d427976",
"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[764824073-inputs1-outputs1-transactio": "15f55a8fc499364aa239c319100072d16ae5dc1ee9dd0db3cd1795363fde679a",
"test_msg_change_wipe_code_t2.py::test_set_pin_to_wipe_code": "85e21add9954b5337d904ce4be7081f89a20bcfce29bf8e9d9a97ffcf5f49329",
"test_msg_change_wipe_code_t2.py::test_set_remove_wipe_code": "a92756269a5129fdf6e90e01cffdaeedde6f422f40b19519c62d521e0fe49fcc",
"test_msg_change_wipe_code_t2.py::test_set_remove_wipe_code": "da0a39a0b0f2121fb8c3f55c3e79e56c0cc5d686f754757cdc7ec2e000252d2b",
"test_msg_change_wipe_code_t2.py::test_set_wipe_code_mismatch": "e8568ac366ab049eefb9e1432d715e87e70caf221c09f8218b84457135534ffd",
"test_msg_change_wipe_code_t2.py::test_set_wipe_code_to_pin": "03b381c2693ee6114cd9021e072801b9a78eb4a87d2c059a3237ab552f49ad19",
"test_msg_changepin_t2.py::test_change_failed": "dc85d4a4585137b675161212debe532505b2105c97c842d0350c39a3fe5ca112",
"test_msg_changepin_t2.py::test_change_pin": "ee4941584d16d3c9e1c6839c189f3b2709f46c62255a63e8c8389f6a879468c8",
"test_msg_changepin_t2.py::test_remove_pin": "0ecd93140d10d797748abc51aaf114742ec03871719860ed79c4d7b1415620ab",
"test_msg_change_wipe_code_t2.py::test_set_wipe_code_to_pin": "0ebeccd017365d082ca2ac7bfede52ee5cc4dd35293c4562d1ae257c0e960469",
"test_msg_changepin_t2.py::test_change_failed": "56d2d2a18feb99a8ffa94fa96d6d01f0ff594bf4b6461e9b827c467543e92b98",
"test_msg_changepin_t2.py::test_change_pin": "edeb52387df6abbe29a0dcce56ee666edd66caa31c3ab7f386391dd428688dbd",
"test_msg_changepin_t2.py::test_remove_pin": "ef73e69ce2dfd7fa0bde8b65e670eccede315d340e0cf881f104ba20676c3c73",
"test_msg_changepin_t2.py::test_set_failed": "c245b7364ade692122eb9a5a64b62769c0d9e27c66b66eda8dc77c6a37577522",
"test_msg_changepin_t2.py::test_set_pin": "14e6be2c7d29f1b1553bd1fa23f658f1d64883afa3f94892961bdf4676025a64",
"test_msg_changepin_t2.py::test_set_pin": "b024766b28b6965fd946547726a360f1ce0c297261cd0125ad979ae0c443091f",
"test_msg_cipherkeyvalue.py-test_decrypt": "166d85b1bf11aeaeb5b93ef5d047b6f8910c28b8fce1d853e6912d89d7bfca2f",
"test_msg_cipherkeyvalue.py-test_decrypt_badlen": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_msg_cipherkeyvalue.py-test_encrypt": "3a37e4004c87bc6df6a8fa7c93b6fe3e3524986914709fda2f9c99ba0ff69775",
@ -357,6 +357,6 @@
"test_reset_backup.py::test_skip_backup_msg[2-backup_flow_slip39_advanced]": "b980c758e8c0aacf6cbb047a9f1acaf3a1d1f3ab84a01ee9e52e5c466caf344c",
"test_sdcard.py::test_sd_format": "6bb7486932a5d38cdbb9b1368ee92aca3fad384115c744feadfade80c1605dd8",
"test_sdcard.py::test_sd_no_format": "f47e897caee95cf98c1b4506732825f853c4b8afcdc2713e38e3b4055973c9ac",
"test_sdcard.py::test_sd_protect_unlock": "9cf77317b32a6ab58fff8b5b4ed9d11445ae7635ec0ac8b46a1a7c59ce51f6e9",
"test_sdcard.py::test_sd_protect_unlock": "d0a8dd770d91dd6dac61f54da78f522d3a6c0717e647785c5f7f46ee501511cc",
"test_u2f_counter.py::test_u2f_counter": "7d96a4d262b9d8a2c1158ac1e5f0f7b2c3ed5f2ba9d6235a014320313f9488fe"
}

Loading…
Cancel
Save