mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 23:40:58 +00:00
trezor/ui/confirm: in HoldToConfirm, stop when button is not active
This commit is contained in:
parent
f528b72f98
commit
f22edd7609
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user