1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

feat(core/ui): drop T1 UI (fixes #2639)

[no changelog]
This commit is contained in:
matejcik 2022-11-23 15:45:30 +01:00 committed by matejcik
parent 95d26fe04a
commit ff2d1c3f1f
5 changed files with 3 additions and 158 deletions

View File

@ -586,9 +586,7 @@ if FROZEN:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/recovery.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/recovery.py'))
if EVERYTHING: if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/fido.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/fido.py'))
elif TREZOR_MODEL in ('1',): elif TREZOR_MODEL in ('1', 'R'):
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/t1.py'))
elif TREZOR_MODEL in ('R',):
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tr/__init__.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tr/__init__.py'))
else: else:
raise ValueError('Unknown Trezor model') raise ValueError('Unknown Trezor model')

View File

@ -540,9 +540,7 @@ if FROZEN:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/recovery.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/recovery.py'))
if EVERYTHING: if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/fido.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/fido.py'))
elif TREZOR_MODEL in ('1',): elif TREZOR_MODEL in ('1', 'R'):
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/t1.py'))
elif TREZOR_MODEL in ('R',):
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tr/__init__.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tr/__init__.py'))
else: else:
raise ValueError('Unknown Trezor model') raise ValueError('Unknown Trezor model')

View File

@ -145,10 +145,6 @@ trezor.strings
import trezor.strings import trezor.strings
trezor.ui trezor.ui
import trezor.ui import trezor.ui
trezor.ui.components
import trezor.ui.components
trezor.ui.components.common
import trezor.ui.components.common
trezor.ui.components.common.confirm trezor.ui.components.common.confirm
import trezor.ui.components.common.confirm import trezor.ui.components.common.confirm
trezor.ui.layouts trezor.ui.layouts
@ -161,8 +157,6 @@ trezor.ui.layouts.recovery
import trezor.ui.layouts.recovery import trezor.ui.layouts.recovery
trezor.ui.layouts.reset trezor.ui.layouts.reset
import trezor.ui.layouts.reset import trezor.ui.layouts.reset
trezor.ui.layouts.t1
import trezor.ui.layouts.t1
trezor.ui.layouts.tr trezor.ui.layouts.tr
import trezor.ui.layouts.tr import trezor.ui.layouts.tr
trezor.ui.layouts.tt_v2 trezor.ui.layouts.tt_v2

View File

@ -4,9 +4,7 @@ from .common import * # noqa: F401,F403
# NOTE: using any import magic probably causes mypy not to check equivalence of # NOTE: using any import magic probably causes mypy not to check equivalence of
# layout type signatures across models # layout type signatures across models
if utils.MODEL in ("1",): if utils.MODEL in ("1", "R"):
from .t1 import * # noqa: F401,F403
elif utils.MODEL in ("R",):
from .tr import * # noqa: F401,F403 from .tr import * # noqa: F401,F403
elif utils.MODEL in ("T",): elif utils.MODEL in ("T",):
from .tt_v2 import * # noqa: F401,F403 from .tt_v2 import * # noqa: F401,F403

View File

@ -1,143 +0,0 @@
from typing import TYPE_CHECKING
from trezor import io, log, loop, ui, wire, workflow
from trezor.enums import ButtonRequestType
import trezorui2
from ..components.common.confirm import is_confirmed
from .common import interact
if TYPE_CHECKING:
from typing import Any, NoReturn, Type
ExceptionType = BaseException | Type[BaseException]
class _RustLayout(ui.Layout):
# pylint: disable=super-init-not-called
def __init__(self, layout: Any):
self.layout = layout
self.timer = loop.Timer()
def set_timer(self, token: int, deadline: int) -> None:
self.timer.schedule(deadline, token)
def create_tasks(self) -> tuple[loop.Task, ...]:
return self.handle_timers(), self.handle_input_and_rendering()
def handle_input_and_rendering(self) -> loop.Task: # type: ignore [awaitable-is-generator]
button = loop.wait(io.BUTTON)
ui.display.clear()
self.layout.attach_timer_fn(self.set_timer)
self.layout.paint()
while True:
# Using `yield` instead of `await` to avoid allocations.
event, button_num = yield button
workflow.idle_timer.touch()
msg = None
if event in (io.BUTTON_PRESSED, io.BUTTON_RELEASED):
msg = self.layout.button_event(event, button_num)
self.layout.paint()
if msg is not None:
raise ui.Result(msg)
def handle_timers(self) -> loop.Task: # type: ignore [awaitable-is-generator]
while True:
# Using `yield` instead of `await` to avoid allocations.
token = yield self.timer
msg = self.layout.timer(token)
self.layout.paint()
if msg is not None:
raise ui.Result(msg)
async def confirm_action(
ctx: wire.GenericContext,
br_type: str,
title: str,
action: str | None = None,
description: str | None = None,
description_param: str | None = None,
description_param_font: int = ui.BOLD,
verb: str | bytes | None = "OK",
verb_cancel: str | bytes | None = "cancel",
hold: bool = False,
reverse: bool = False,
exc: ExceptionType = wire.ActionCancelled,
br_code: ButtonRequestType = ButtonRequestType.Other,
) -> None:
if isinstance(verb, bytes) or isinstance(verb_cancel, bytes):
raise NotImplementedError
if description is not None and description_param is not None:
if description_param_font != ui.BOLD:
log.error(__name__, "confirm_action description_param_font not implemented")
description = description.format(description_param)
if hold:
log.error(__name__, "confirm_action hold not implemented")
result = await interact(
ctx,
_RustLayout(
trezorui2.confirm_action(
title=title.upper(),
action=action,
description=description,
verb=verb,
verb_cancel=verb_cancel,
hold=hold,
reverse=reverse,
)
),
br_type,
br_code,
)
if not is_confirmed(result):
raise exc
async def confirm_text(
ctx: wire.GenericContext,
br_type: str,
title: str,
data: str,
description: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Other,
) -> None:
result = await interact(
ctx,
_RustLayout(
trezorui2.confirm_text(
title=title.upper(),
data=data,
description=description,
)
),
br_type,
br_code,
)
if not is_confirmed(result):
raise wire.ActionCancelled
async def show_error_and_raise(
ctx: wire.GenericContext,
br_type: str,
content: str,
subheader: str | None = None,
button: str = "Close",
exc: ExceptionType = wire.ActionCancelled,
) -> NoReturn:
raise NotImplementedError
async def show_popup(
title: str,
description: str,
subtitle: str | None = None,
description_param: str = "",
timeout_ms: int = 3000,
) -> None:
raise NotImplementedError