1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-11 07:50:57 +00:00

trezor/ui/confirm: in HoldToConfirm, stop when button is not active

This commit is contained in:
Jan Pochyla 2017-09-26 14:09:52 +02:00
parent f528b72f98
commit f22edd7609
2 changed files with 7 additions and 4 deletions

View File

@ -2,7 +2,7 @@ from micropython import const
from trezor import loop from trezor import loop
from trezor import ui, res from trezor import ui, res
from trezor.ui import Widget 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 from trezor.ui.loader import Loader
CONFIRMED = const(1) CONFIRMED = const(1)
@ -61,9 +61,9 @@ class HoldToConfirmDialog(Widget):
def touch(self, event, pos): def touch(self, event, pos):
button = self.button button = self.button
was_started = button.state & BTN_STARTED was_started = button.state & BTN_STARTED and button.state & BTN_ACTIVE
button.touch(event, pos) 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: if is_started and not was_started:
self.loader.start() self.loader.start()
return _STARTED return _STARTED

View File

@ -18,7 +18,10 @@ class Loader(ui.Widget):
def stop(self): def stop(self):
ui.display.bar(0, 32, 240, 240 - 80, ui.BG) 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 self.start_ticks_ms = None
return ticks_diff >= self.target_ms return ticks_diff >= self.target_ms