Skip to content
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

PASS1-112: Passphrase input dialog improvements #48

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ports/stm32/boards/Passport/modules/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,11 +1396,18 @@ async def enter_passphrase(menu, label, item):
title = item.arg
passphrase = await ux_enter_text(title, label="Enter Passphrase", max_length=MAX_PASSPHRASE_LENGTH)

# print("Chosen passphrase = {}".format(passphrase))

if not await ux_confirm('Are you sure you want to apply the passphrase:\n\n{}'.format(passphrase)):
# None is passed back when user chose "back"
if passphrase == None:
return

# print("Chosen passphrase = {}".format(passphrase))
if passphrase == '':
if not await ux_confirm('Are you sure you want to clear the passphrase?'):
return
else:
if not await ux_confirm('Are you sure you want to apply the passphrase:\n\n{}'.format(passphrase)):
return

# Applying the passphrase takes a bit of time so show message
dis.fullscreen("Applying Passphrase...")

Expand Down
9 changes: 7 additions & 2 deletions ports/stm32/boards/Passport/modules/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ def char_width(self, ch, font=FontSmall):
def text_input(self, x, y, msg, font=FontSmall, invert=0, cursor_pos=None, visible_spaces=False, fixed_spacing=None, cursor_shape='line'):
from ux import word_wrap
from utils import split_by_char_size


# Maximum message size is 64 characters
if len(msg) >= 64:
FoundationKen marked this conversation as resolved.
Show resolved Hide resolved
msg = msg[:64]

if hasattr(msg, 'readline'):
lines = split_by_char_size(msg.getvalue(), font)
else:
Expand All @@ -209,7 +213,8 @@ def text_input(self, x, y, msg, font=FontSmall, invert=0, cursor_pos=None, visib
for line in lines:
self.text(x, y, line, font, invert, cursor_pos,
visible_spaces, fixed_spacing, cursor_shape, True)
y += font.leading
# move the y down enough to make room for 7 lines of text (hence the -2)
y += font.leading - 2
cursor_pos -= len(line)

def text(self, x, y, msg, font=FontSmall, invert=0, cursor_pos=None, visible_spaces=False, fixed_spacing=None, cursor_shape='line', scrollbar_visible=False):
Expand Down