core: add option to omit cancel button in HoldToConfirm; add it to reset

release/2020-04
Tomas Susanka 4 years ago
parent 8ae0535e69
commit bf20537f41

@ -84,6 +84,7 @@ async def hold_to_confirm(
confirm: str = HoldToConfirm.DEFAULT_CONFIRM,
confirm_style: ButtonStyleType = HoldToConfirm.DEFAULT_CONFIRM_STYLE,
loader_style: LoaderStyleType = HoldToConfirm.DEFAULT_LOADER_STYLE,
cancel: bool = True,
) -> bool:
await ctx.call(ButtonRequest(code=code), ButtonAck)
@ -93,11 +94,11 @@ async def hold_to_confirm(
assert isinstance(content, Paginated)
content.pages[-1] = HoldToConfirm(
content.pages[-1], confirm, confirm_style, loader_style
content.pages[-1], confirm, confirm_style, loader_style, cancel
)
dialog = content # type: ui.Layout
else:
dialog = HoldToConfirm(content, confirm, confirm_style, loader_style)
dialog = HoldToConfirm(content, confirm, confirm_style, loader_style, cancel)
return await ctx.wait(dialog) is CONFIRMED

@ -127,7 +127,7 @@ async def _show_share_words(ctx, share_words, share_index=None, group_index=None
utils.ensure(share_words == shares_words_check)
# confirm the share
await require_hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice)
await require_hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice, cancel=False)
def _split_share_into_pages(share_words):

@ -241,19 +241,25 @@ class HoldToConfirm(ui.Layout):
confirm: str = DEFAULT_CONFIRM,
confirm_style: ButtonStyleType = DEFAULT_CONFIRM_STYLE,
loader_style: LoaderStyleType = DEFAULT_LOADER_STYLE,
cancel: bool = True,
):
self.content = content
self.loader = Loader(loader_style)
self.loader.on_start = self._on_loader_start # type: ignore
self.confirm = Button(ui.grid(17, n_x=4, cells_x=3), confirm, confirm_style)
if cancel:
self.confirm = Button(ui.grid(17, n_x=4, cells_x=3), confirm, confirm_style)
else:
self.confirm = Button(ui.grid(4, n_x=1), confirm, confirm_style)
self.confirm.on_press_start = self._on_press_start # type: ignore
self.confirm.on_press_end = self._on_press_end # type: ignore
self.confirm.on_click = self._on_click # type: ignore
self.cancel = Button(ui.grid(16, n_x=4), res.load(ui.ICON_CANCEL), ButtonAbort)
self.cancel.on_click = self.on_cancel # type: ignore
self.cancel = None
if cancel:
self.cancel = Button(ui.grid(16, n_x=4), res.load(ui.ICON_CANCEL), ButtonAbort)
self.cancel.on_click = self.on_cancel # type: ignore
def _on_press_start(self) -> None:
self.loader.start()
@ -278,7 +284,8 @@ class HoldToConfirm(ui.Layout):
else:
self.content.dispatch(event, x, y)
self.confirm.dispatch(event, x, y)
self.cancel.dispatch(event, x, y)
if self.cancel:
self.cancel.dispatch(event, x, y)
def on_confirm(self) -> None:
raise ui.Result(CONFIRMED)

@ -9,9 +9,9 @@
"test_cancel.py::test_cancel_message_via_initialize[message1]": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_msg_applysettings.py-test_apply_settings": "b698654871541258f97d58ada0f010b2d77b74829791566746cad619d3740a94",
"test_msg_applysettings.py-test_apply_settings_passphrase": "fb38537b921f8064f7ea6e1a584e70a8be74968a3be6726b7d36cf57de0d7865",
"test_msg_backup_device.py::test_backup_bip39": "ff34ef60d2bbb92fc4e4ab00a1e4f9c2c7884e3186bb6861398f74dd3e05e3cf",
"test_msg_backup_device.py::test_backup_slip39_advanced": "edfccb742254ab1c5945c27f0c70926c2a4adb6fff4df0ed561bd58b05043034",
"test_msg_backup_device.py::test_backup_slip39_basic": "ca04ca33f05b5b0f3c762f0cad293a376e056e43a28ce94ffb77b36d491cbc1f",
"test_msg_backup_device.py::test_backup_bip39": "749f543f21fe0005ef43b00e23162cf68522d1460cee5cc77d933324e85b5ded",
"test_msg_backup_device.py::test_backup_slip39_advanced": "efb31ae0ed0565d0c044e0aeabe3d32a524e99155d50d6b72100627c68a1d472",
"test_msg_backup_device.py::test_backup_slip39_basic": "ffef65aa4bb5f265644a5df0063542c3f261f815db65914893a690760d0d0b6a",
"test_msg_backup_device.py::test_interrupt_backup_fails": "225b3da1acac6e9a65106fcc4a01de8a44de035aedb4dcc21c09f439199fdf40",
"test_msg_backup_device.py::test_no_backup_fails": "93039a9472cfc9058563bd56e4a3dbe2e41af64744a61f6ee3255a04bd3a9366",
"test_msg_backup_device.py::test_no_backup_show_entropy_fails": "14fcdd2ded299ca099a35966cc9f21204b31de8d6bab9ec91cb64537bd70440c",
@ -219,11 +219,11 @@
"test_msg_recoverydevice_slip39_basic_dryrun.py::test_2of3_invalid_seed_dryrun": "55f2dd6b4958659f071c3f57e06286f872ac38af4828f446a0f4e91c657dfccc",
"test_msg_resetdevice_bip39_t2.py-test_already_initialized": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_msg_resetdevice_bip39_t2.py-test_failed_pin": "f284b630fef6ae437c9726cd0ee0d1728a77f677f37cd5f88aabb21e596f589e",
"test_msg_resetdevice_bip39_t2.py-test_reset_device": "aaa37f33897fbdf33858a9cbb8982be1b1c1d1e2cbff83ebfd4c49fa8fc4b342",
"test_msg_resetdevice_bip39_t2.py-test_reset_device": "c5fc35eab68889c0b3315cad09afd573ce32c1e94c2cb942388638414145f631",
"test_msg_resetdevice_bip39_t2.py-test_reset_device_192": "febbacc3370cf9219faa49bbc542a7aa1280d9fc3e6e9776dacbcd2f09231636",
"test_msg_resetdevice_bip39_t2.py-test_reset_device_pin": "dd95b1f1e7b496828314a4baf77f5f9f3aa54fc11754236e35f7519da9fd44c8",
"test_msg_resetdevice_slip39_advanced.py-test_reset_device_slip39_advanced": "b1ca19a20f4d2be96847c8d2373921a68c5c9bd1292790229c64f93a0319cb69",
"test_msg_resetdevice_slip39_basic.py-test_reset_device_slip39_basic": "77e9d45a9fb16a8759478ac1d433bb86ce58c01fa135bc4524596955de20552d",
"test_msg_resetdevice_bip39_t2.py-test_reset_device_pin": "e5957c6790bb3319b90da678949d09bfdd2d641d8d315ffa6b98a316cffeef0c",
"test_msg_resetdevice_slip39_advanced.py-test_reset_device_slip39_advanced": "77fae06d2427b6626debb71448e0b79c81afb99da10df9b9e987259eb045edf2",
"test_msg_resetdevice_slip39_basic.py-test_reset_device_slip39_basic": "ad0d71e21112456fa99fdbd36563aa1ccbf49343a94ca1ed74068b2ec04ebd61",
"test_msg_resetdevice_slip39_basic.py-test_reset_device_slip39_basic_256": "5f21f628ada58d9b519aec96f99a087df1098825de33421ddb36777dc4f578f1",
"test_msg_ripple_get_address.py-test_ripple_get_address": "2bb7d7bf48f1218530b4d7045d48480cad6411e110df537551b2f80b342007f2",
"test_msg_ripple_get_address.py-test_ripple_get_address_other": "2bb7d7bf48f1218530b4d7045d48480cad6411e110df537551b2f80b342007f2",
@ -378,12 +378,12 @@
"test_passphrase_slip39_advanced.py::test_256bit_passphrase": "69b6b8b22c819e1282d7d2c14b31bf8d015c81ac05fe034540dbb11c8a20dbdb",
"test_passphrase_slip39_basic.py::test_2of5_passphrase": "1e00b1a7840bc144b98b7bce26f74fc913a0abf9d1c500571d7803b6b2e0943c",
"test_passphrase_slip39_basic.py::test_3of6_passphrase": "1e00b1a7840bc144b98b7bce26f74fc913a0abf9d1c500571d7803b6b2e0943c",
"test_reset_backup.py::test_skip_backup_manual[0-backup_flow_bip39]": "458d09ef5b84b80093f904e9cdd04172b2781ccc303239a077daba586781f186",
"test_reset_backup.py::test_skip_backup_manual[1-backup_flow_slip39_basic]": "ff23780ce790c0f0c53961a94f9faa00873878130cc4ddd4d0a74bebeb4fdcde",
"test_reset_backup.py::test_skip_backup_manual[2-backup_flow_slip39_advanced]": "d43f68e08d989766fd0b75403fa75aea5bf6f746383198ed0bdc55467c5595bd",
"test_reset_backup.py::test_skip_backup_msg[0-backup_flow_bip39]": "718a277f77290cfd28bf16de1fc46b4da13540015ae3d2566472906389d5a69d",
"test_reset_backup.py::test_skip_backup_msg[1-backup_flow_slip39_basic]": "34a27fe6d204808149b2de3c15c04a52f5d2335ef4a43b2468f218dc0cf20102",
"test_reset_backup.py::test_skip_backup_msg[2-backup_flow_slip39_advanced]": "25a4e8a2ca91518b481538c7c9e70e1769f1aa26c85455bfaadf33c47ae185c2",
"test_reset_backup.py::test_skip_backup_manual[0-backup_flow_bip39]": "1002b2e5c75fcd7dc8d421283e2eccb5b747a4014af274ad335b3cff7d27db9d",
"test_reset_backup.py::test_skip_backup_manual[1-backup_flow_slip39_basic]": "c37acfae2609b03bd84f9eb53b0642c73b16cf78300271fc94a6d9a311b144b9",
"test_reset_backup.py::test_skip_backup_manual[2-backup_flow_slip39_advanced]": "26d8bbbdc25f3105f60fd2367fbb765e41ebd42b8545c42fd9398b62233ec363",
"test_reset_backup.py::test_skip_backup_msg[0-backup_flow_bip39]": "6e26d95a67a27f5bb0fc2bb5eaaca01bce3a30e20391ccb5208179edb768b52e",
"test_reset_backup.py::test_skip_backup_msg[1-backup_flow_slip39_basic]": "bea2ebcb056e300f5b8f731af8ee284bf38d3cc725b79d0772fd85f7b09d32bd",
"test_reset_backup.py::test_skip_backup_msg[2-backup_flow_slip39_advanced]": "fd2001fe6960aa7c527266a4030a93bb189435703033cba7337a77c534b87e89",
"test_sdcard.py::test_sd_format": "6bb7486932a5d38cdbb9b1368ee92aca3fad384115c744feadfade80c1605dd8",
"test_sdcard.py::test_sd_no_format": "f47e897caee95cf98c1b4506732825f853c4b8afcdc2713e38e3b4055973c9ac",
"test_sdcard.py::test_sd_protect_unlock": "621294fce5df0a5f381450647b3a45d71696cca0c46bec368a0fea675709956d",

Loading…
Cancel
Save