From f22edd7609364ac5bf4eaf3a54d44715371c4db9 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 26 Sep 2017 14:09:52 +0200 Subject: [PATCH] trezor/ui/confirm: in HoldToConfirm, stop when button is not active --- src/trezor/ui/confirm.py | 6 +++--- src/trezor/ui/loader.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/trezor/ui/confirm.py b/src/trezor/ui/confirm.py index 1c69eb3d6f..4a903bffc8 100644 --- a/src/trezor/ui/confirm.py +++ b/src/trezor/ui/confirm.py @@ -2,7 +2,7 @@ from micropython import const from trezor import loop from trezor import ui, res from trezor.ui import Widget -from trezor.ui.button import Button, BTN_CLICKED, BTN_STARTED +from trezor.ui.button import Button, BTN_CLICKED, BTN_STARTED, BTN_ACTIVE from trezor.ui.loader import Loader CONFIRMED = const(1) @@ -61,9 +61,9 @@ class HoldToConfirmDialog(Widget): def touch(self, event, pos): button = self.button - was_started = button.state & BTN_STARTED + was_started = button.state & BTN_STARTED and button.state & BTN_ACTIVE button.touch(event, pos) - is_started = button.state & BTN_STARTED + is_started = button.state & BTN_STARTED and button.state & BTN_ACTIVE if is_started and not was_started: self.loader.start() return _STARTED diff --git a/src/trezor/ui/loader.py b/src/trezor/ui/loader.py index 8661e92b09..0b037c2a78 100644 --- a/src/trezor/ui/loader.py +++ b/src/trezor/ui/loader.py @@ -18,7 +18,10 @@ class Loader(ui.Widget): def stop(self): ui.display.bar(0, 32, 240, 240 - 80, ui.BG) - ticks_diff = utime.ticks_ms() - self.start_ticks_ms + if self.start_ticks_ms is not None: + ticks_diff = utime.ticks_ms() - self.start_ticks_ms + else: + ticks_diff = 0 self.start_ticks_ms = None return ticks_diff >= self.target_ms