diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d195636..1cdd863a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ From the wonderful land of Korea, a new creation arrives: the WonderK PRO. Creat ### Other Bug Fixes and Improvements - Added backtick ` to keypad - Bugfix: Screensaver not activating in menu pages without statusbar +- Screensaver: Now appears on menu screens that display info boxes - Embit: Improved BIP39 mnemonic validation # Changelog 25.10.1 - October 2025 diff --git a/src/krux/pages/__init__.py b/src/krux/pages/__init__.py index 9da6dc759..a368109bd 100644 --- a/src/krux/pages/__init__.py +++ b/src/krux/pages/__init__.py @@ -651,9 +651,11 @@ def __init__( disable_statusbar=False, back_label="Back", back_status=lambda: MENU_EXIT, + infobox_callback=lambda: None, ): self.ctx = ctx self.menu = menu + self.infobox_callback = infobox_callback if back_label: back_label = t("Back") if back_label == "Back" else back_label self.menu += [("< " + back_label, back_status)] @@ -785,9 +787,10 @@ def run_loop(self, start_from_index=None, swipe_up_fnc=None, swipe_down_fnc=None ) if isinstance(selected_item_index, tuple): return selected_item_index - elif btn is None and self.menu_offset <= STATUS_BAR_HEIGHT: - # Activates screensaver if there's no info_box(other things draw on the screen) + elif btn is None: + # Activate screensaver (it's time!) self.screensaver() + self.infobox_callback() def _clicked_item(self, selected_item_index): item = self.menu_view[selected_item_index] diff --git a/src/krux/pages/datum_tool.py b/src/krux/pages/datum_tool.py index 39c2c9605..edd996bba 100644 --- a/src/krux/pages/datum_tool.py +++ b/src/krux/pages/datum_tool.py @@ -823,7 +823,8 @@ def view_contents(self, try_decrypt=True, offer_convert=False): self.ctx, todo_menu, offset=info_len * FONT_HEIGHT + DEFAULT_PADDING, - **back_status + **back_status, + infobox_callback=self._info_box ) _, status = menu.run_loop() diff --git a/src/krux/pages/device_tests.py b/src/krux/pages/device_tests.py index 739f59907..8b014ab43 100644 --- a/src/krux/pages/device_tests.py +++ b/src/krux/pages/device_tests.py @@ -159,28 +159,31 @@ def test_suite(self, interactive=False): wdt.feed() # info_box summary - self.ctx.display.clear() - failures = len([x for x in self.results if not x[1]]) - total = len(self.results) - num_lines = self.ctx.display.draw_hcentered_text( - "\n".join( - [ - x - for x in [ - t("Test Suite Results"), - t("success rate:") - + " {}%".format(int((total - failures) / (total) * 100)), - ( - t("failed:") + " {}/{}".format(failures, total) - if failures - else None - ), + def _print_infobox(): + self.ctx.display.clear() + failures = len([x for x in self.results if not x[1]]) + total = len(self.results) + return self.ctx.display.draw_hcentered_text( + "\n".join( + [ + x + for x in [ + t("Test Suite Results"), + t("success rate:") + + " {}%".format(int((total - failures) / (total) * 100)), + ( + t("failed:") + " {}/{}".format(failures, total) + if failures + else None + ), + ] + if x is not None ] - if x is not None - ] - ), - info_box=True, - ) + ), + info_box=True, + ) + + num_lines = _print_infobox() # results menu line_fmt = "{:" + str(chars_per_line - 3) + "s} {:>2s}" @@ -201,6 +204,7 @@ def test_suite(self, interactive=False): for x in self.results ], offset=(num_lines + 1) * FONT_HEIGHT, + infobox_callback=_print_infobox, ) idx, _ = results_menu.run_loop() if idx == len(self.results): diff --git a/src/krux/pages/home_pages/bip85.py b/src/krux/pages/home_pages/bip85.py index c18402487..c28de69f5 100644 --- a/src/krux/pages/home_pages/bip85.py +++ b/src/krux/pages/home_pages/bip85.py @@ -159,16 +159,19 @@ def _derive_base64_password(self): ), ), ] - self.ctx.display.clear() - info_len = self.ctx.display.draw_hcentered_text( - info, info_box=True, highlight_prefix=":" - ) - info_len *= FONT_HEIGHT - info_len += DEFAULT_PADDING + + def _print_infobox(): + self.ctx.display.clear() + return self.ctx.display.draw_hcentered_text( + info, info_box=True, highlight_prefix=":" + ) + + info_len = _print_infobox() submenu = Menu( self.ctx, menu_items, - offset=info_len, + offset=info_len * FONT_HEIGHT + DEFAULT_PADDING, + infobox_callback=_print_infobox, ) index, _ = submenu.run_loop() if index == submenu.back_index: diff --git a/src/krux/pages/home_pages/pub_key_view.py b/src/krux/pages/home_pages/pub_key_view.py index 9e167fcfe..0afde78fa 100644 --- a/src/krux/pages/home_pages/pub_key_view.py +++ b/src/krux/pages/home_pages/pub_key_view.py @@ -78,19 +78,28 @@ def _pub_key_text(version): + "\n\n" + full_pub_key ) + + def _print_infobox(): + self.ctx.display.clear() + self.ctx.display.draw_hcentered_text( + info_text, + offset_y=FONT_HEIGHT, + info_box=True, + ) + self.ctx.display.draw_hcentered_text( + self.ctx.wallet.key.fingerprint_hex_str(pretty=True), + offset_y=FONT_HEIGHT, + color=theme.highlight_color, + bg_color=theme.info_bg_color, + ) + + _print_infobox() menu_offset = (len(self.ctx.display.to_lines(info_text)) + 1) * FONT_HEIGHT - pub_key_menu = Menu(self.ctx, pub_text_menu_items, offset=menu_offset) - self.ctx.display.clear() - self.ctx.display.draw_hcentered_text( - info_text, - offset_y=FONT_HEIGHT, - info_box=True, - ) - self.ctx.display.draw_hcentered_text( - self.ctx.wallet.key.fingerprint_hex_str(pretty=True), - offset_y=FONT_HEIGHT, - color=theme.highlight_color, - bg_color=theme.info_bg_color, + pub_key_menu = Menu( + self.ctx, + pub_text_menu_items, + offset=menu_offset, + infobox_callback=_print_infobox, ) pub_key_menu.run_loop() diff --git a/src/krux/pages/login.py b/src/krux/pages/login.py index 82e32cfca..b9eb202a2 100644 --- a/src/krux/pages/login.py +++ b/src/krux/pages/login.py @@ -203,6 +203,7 @@ def new_key_from_snapshot(self): return self._load_key_from_words(entropy_mnemonic.split(), new=True) return MENU_CONTINUE + # pylint: disable=too-many-locals def _load_key_from_words(self, words, charset=LETTERS, new=False): mnemonic = " ".join(words) @@ -218,7 +219,6 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False): if mnemonic is None: return MENU_CONTINUE - passphrase = "" if not hasattr(Settings().wallet, "policy_type") and hasattr( Settings().wallet, "multisig" ): @@ -257,6 +257,7 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False): Settings().wallet.script_type, P2WSH ) + passphrase = "" derivation_path = "" from ..wallet import Wallet @@ -287,7 +288,31 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False): else t("Passphrase") + " (%d): *…*" % len(passphrase) ) - self.ctx.display.clear() + def _print_infobox(): + self.ctx.display.clear() + num_lines = self.ctx.display.draw_hcentered_text( + wallet_info, info_box=True + ) + + # draw fingerprint with highlight color + self.ctx.display.draw_hcentered_text( + key.fingerprint_hex_str(True), + color=theme.highlight_color, + bg_color=theme.info_bg_color, + ) + + # draw network with highlight color + self.ctx.display.draw_hcentered_text( + network_name, + DEFAULT_PADDING + FONT_HEIGHT, + color=Utils.get_network_color(network_name), + bg_color=theme.info_bg_color, + ) + + return num_lines + + num_lines = _print_infobox() + submenu = Menu( self.ctx, [ @@ -295,26 +320,8 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False): (t("Passphrase"), lambda: None), (t("Customize"), lambda: None), ], - offset=( - self.ctx.display.draw_hcentered_text(wallet_info, info_box=True) - * FONT_HEIGHT - + DEFAULT_PADDING - ), - ) - - # draw fingerprint with highlight color - self.ctx.display.draw_hcentered_text( - key.fingerprint_hex_str(True), - color=theme.highlight_color, - bg_color=theme.info_bg_color, - ) - - # draw network with highlight color - self.ctx.display.draw_hcentered_text( - network_name, - DEFAULT_PADDING + FONT_HEIGHT, - color=Utils.get_network_color(network_name), - bg_color=theme.info_bg_color, + offset=num_lines * FONT_HEIGHT + DEFAULT_PADDING, + infobox_callback=_print_infobox, ) index, _ = submenu.run_loop() diff --git a/src/krux/pages/new_mnemonic/dice_rolls.py b/src/krux/pages/new_mnemonic/dice_rolls.py index 01ea1aa89..e70cb9849 100644 --- a/src/krux/pages/new_mnemonic/dice_rolls.py +++ b/src/krux/pages/new_mnemonic/dice_rolls.py @@ -308,25 +308,31 @@ def delete_roll(buffer): entropy = ( "".join(self.rolls) if self.num_sides < 10 else "-".join(self.rolls) ) - self.ctx.display.clear() rolls_str = "\n\n%s" % entropy max_lines = TOTAL_LINES - 6 # room for menu - menu_offset = self.ctx.display.draw_hcentered_text( - rolls_str, info_box=True, max_lines=max_lines - ) - self.ctx.display.draw_hcentered_text( - t("Rolls:"), color=theme.highlight_color, bg_color=theme.info_bg_color - ) - menu_offset *= FONT_HEIGHT - menu_offset += DEFAULT_PADDING + + def _print_infobox(): + self.ctx.display.clear() + n_lines = self.ctx.display.draw_hcentered_text( + rolls_str, info_box=True, max_lines=max_lines + ) + self.ctx.display.draw_hcentered_text( + t("Rolls:"), + color=theme.highlight_color, + bg_color=theme.info_bg_color, + ) + return n_lines + + menu_offset = _print_infobox() submenu = Menu( self.ctx, [ (t("Stats for Nerds"), lambda: MENU_EXIT), (t("Generate Mnemonic"), lambda: MENU_EXIT), ], - offset=menu_offset, + offset=menu_offset * FONT_HEIGHT + DEFAULT_PADDING, back_label=None, + infobox_callback=_print_infobox, ) index, _ = submenu.run_loop() if index == 0: diff --git a/src/krux/pages/qr_view.py b/src/krux/pages/qr_view.py index 9abe9c15e..6b29eb54a 100644 --- a/src/krux/pages/qr_view.py +++ b/src/krux/pages/qr_view.py @@ -460,10 +460,15 @@ def save_qr_image_menu(self): resolution *= 2 if resolution <= 480: bmp_resolutions.append(resolution) - self.ctx.display.clear() - self.ctx.display.draw_hcentered_text( - t("Res. - Format"), FONT_HEIGHT, info_box=True - ) + + def _print_infobox(): + self.ctx.display.clear() + self.ctx.display.draw_hcentered_text( + t("Res. - Format"), FONT_HEIGHT, info_box=True + ) + + _print_infobox() + qr_menu = [] qr_menu.append( ( @@ -486,7 +491,13 @@ def save_qr_image_menu(self): lambda: self.save_svg_image(suggested_file_name), ) ) - submenu = Menu(self.ctx, qr_menu, offset=2 * FONT_HEIGHT, back_label=None) + submenu = Menu( + self.ctx, + qr_menu, + offset=2 * FONT_HEIGHT, + back_label=None, + infobox_callback=_print_infobox, + ) submenu.run_loop() return MENU_CONTINUE # return MENU_EXIT # Use this to exit QR Viewer after saving diff --git a/src/krux/pages/wallet_settings.py b/src/krux/pages/wallet_settings.py index bc3e9670d..bf47765fd 100644 --- a/src/krux/pages/wallet_settings.py +++ b/src/krux/pages/wallet_settings.py @@ -195,9 +195,24 @@ def customize_wallet(self, key): network_name, policy_type, script_type, derivation_path ) - self.ctx.display.clear() derivation_path = self.fit_to_line(derivation_path, crop_middle=False) - info_len = self.ctx.display.draw_hcentered_text(wallet_info, info_box=True) + + def _print_infobox(): + self.ctx.display.clear() + n_lines = self.ctx.display.draw_hcentered_text( + wallet_info, info_box=True + ) + + # draw network with highlight color + self.ctx.display.draw_hcentered_text( + network_name, + color=Utils.get_network_color(network_name), + bg_color=theme.info_bg_color, + ) + + return n_lines + + info_len = _print_infobox() # if the wallet is P2SH, we need to change # the "Account" label to "Cossiger Index" @@ -216,13 +231,7 @@ def customize_wallet(self, key): (account_txt, lambda: None), ], offset=info_len * FONT_HEIGHT + DEFAULT_PADDING, - ) - - # draw network with highlight color - self.ctx.display.draw_hcentered_text( - network_name, - color=Utils.get_network_color(network_name), - bg_color=theme.info_bg_color, + infobox_callback=_print_infobox, ) index, _ = submenu.run_loop()