Browse Source

PASS1-112: Passphrase input dialog improvements

The passphrase is limited to 64 characters. The line spacing was reduced to make room for 7 lines. 63 capital W's will fill all 7 lines (+1 over), otherwise 64 characters usually takes about 4 lines.
PASS1-112
coreylakey 4 years ago
parent
commit
061633d032
  1. 13
      ports/stm32/boards/Passport/modules/actions.py
  2. 9
      ports/stm32/boards/Passport/modules/display.py

13
ports/stm32/boards/Passport/modules/actions.py

@ -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...")

9
ports/stm32/boards/Passport/modules/display.py

@ -195,7 +195,11 @@ class Display:
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:
msg = msg[:64]
if hasattr(msg, 'readline'):
lines = split_by_char_size(msg.getvalue(), font)
else:
@ -209,7 +213,8 @@ class Display:
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):

Loading…
Cancel
Save