apps/common/request_passphrase: update UI dialog of pp entry and keyboard
This commit is contained in:
parent
7b2fd6ae4c
commit
07c11228e6
|
@ -2,13 +2,12 @@ from trezor import res, ui, wire
|
||||||
|
|
||||||
|
|
||||||
async def request_passphrase_on_display(ctx):
|
async def request_passphrase_on_display(ctx):
|
||||||
from trezor.messages.FailureType import ActionCancelled
|
|
||||||
from trezor.ui.passphrase import PassphraseKeyboard, CANCELLED
|
from trezor.ui.passphrase import PassphraseKeyboard, CANCELLED
|
||||||
|
|
||||||
ui.display.clear()
|
ui.display.clear()
|
||||||
passphrase = await PassphraseKeyboard('Enter passphrase')
|
passphrase = await PassphraseKeyboard('Enter passphrase')
|
||||||
if passphrase == CANCELLED:
|
if passphrase == CANCELLED:
|
||||||
raise wire.FailureError(ActionCancelled, 'Passphrase cancelled')
|
return False
|
||||||
return passphrase
|
return passphrase
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,17 +32,22 @@ async def request_passphrase(ctx):
|
||||||
from trezor.ui.text import Text
|
from trezor.ui.text import Text
|
||||||
from trezor.ui.entry_select import EntrySelector
|
from trezor.ui.entry_select import EntrySelector
|
||||||
|
|
||||||
ui.display.clear()
|
res = False
|
||||||
text = Text(
|
text = Text(
|
||||||
'Enter passphrase', ui.ICON_RESET,
|
'Enter passphrase', ui.ICON_RESET,
|
||||||
'Where to enter your', 'passphrase?')
|
'Where to enter your', 'passphrase?')
|
||||||
entry = EntrySelector(text)
|
|
||||||
entry_type = await entry
|
|
||||||
|
|
||||||
if entry_type == 1:
|
while not res:
|
||||||
return await request_passphrase_on_host(ctx)
|
ui.display.clear()
|
||||||
else:
|
entry = EntrySelector(text)
|
||||||
return await request_passphrase_on_display(ctx)
|
entry_type = await entry
|
||||||
|
|
||||||
|
if entry_type == 1:
|
||||||
|
res = await request_passphrase_on_host(ctx)
|
||||||
|
else:
|
||||||
|
res = await request_passphrase_on_display(ctx)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
async def protect_by_passphrase(ctx):
|
async def protect_by_passphrase(ctx):
|
||||||
|
|
|
@ -87,7 +87,7 @@ class PassphraseKeyboard(ui.Widget):
|
||||||
self.prompt = prompt
|
self.prompt = prompt
|
||||||
self.page = page
|
self.page = page
|
||||||
self.input = Input(ui.grid(0, n_x=1, n_y=6), '')
|
self.input = Input(ui.grid(0, n_x=1, n_y=6), '')
|
||||||
self.back = Button(ui.grid(12), res.load(ui.ICON_BACK), style=ui.BTN_CLEAR)
|
self.back = Button(ui.grid(12), res.load(ui.ICON_CLEAR), style=ui.BTN_CANCEL)
|
||||||
self.done = Button(ui.grid(14), res.load(ui.ICON_CONFIRM), style=ui.BTN_CONFIRM)
|
self.done = Button(ui.grid(14), res.load(ui.ICON_CONFIRM), style=ui.BTN_CONFIRM)
|
||||||
self.keys = key_buttons(KEYBOARD_KEYS[self.page])
|
self.keys = key_buttons(KEYBOARD_KEYS[self.page])
|
||||||
self.pbutton = None # pending key button
|
self.pbutton = None # pending key button
|
||||||
|
@ -146,9 +146,12 @@ class PassphraseKeyboard(ui.Widget):
|
||||||
self.pindex = index
|
self.pindex = index
|
||||||
self.input.edit(content, button is not None)
|
self.input.edit(content, button is not None)
|
||||||
if content:
|
if content:
|
||||||
self.back.enable()
|
self.back = Button(ui.grid(12), res.load(ui.ICON_BACK), style=ui.BTN_CLEAR)
|
||||||
|
self.back.render()
|
||||||
else:
|
else:
|
||||||
self.back.disable()
|
self.back.content = res.load(ui.ICON_CLEAR)
|
||||||
|
self.back.normal_style = ui.BTN_CANCEL['normal']
|
||||||
|
self.back.enable()
|
||||||
|
|
||||||
async def __iter__(self):
|
async def __iter__(self):
|
||||||
self.edit(self.input.content) # init button state
|
self.edit(self.input.content) # init button state
|
||||||
|
|
Loading…
Reference in New Issue