-
Notifications
You must be signed in to change notification settings - Fork 70
Screensaver now appears in screens with infobox #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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=":" | ||
| ) | ||
|
Comment on lines
+163
to
+167
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not define it as a private method in the class instead a anon function?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I defined it inside the function because it’s an implementation detail, not a reusable behavior of the class. Its scope is explicit: it cannot be called from anywhere else. |
||
|
|
||
| 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: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
| ) | ||
|
Comment on lines
+82
to
+94
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| _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() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,34 +288,40 @@ 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 | ||
|
Comment on lines
+291
to
+312
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
|
|
||
| num_lines = _print_infobox() | ||
|
|
||
| submenu = Menu( | ||
| self.ctx, | ||
| [ | ||
| (t("Load Wallet"), lambda: None), | ||
| (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() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Comment on lines
+314
to
+324
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| 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: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ) | ||
|
Comment on lines
+464
to
+468
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same Here |
||
|
|
||
| _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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Comment on lines
+200
to
+213
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| 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() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here