2016-11-23 05:52:02 -08:00
|
|
|
from trezor import ui, wire
|
2018-02-27 07:35:21 -08:00
|
|
|
from trezor.messages import ButtonRequestType, FailureType
|
|
|
|
from trezor.messages.Success import Success
|
|
|
|
from trezor.ui.text import Text
|
|
|
|
from apps.common import storage
|
|
|
|
from apps.common.confirm import require_confirm
|
2016-11-23 05:52:02 -08:00
|
|
|
|
|
|
|
|
2018-02-27 05:50:34 -08:00
|
|
|
async def apply_settings(ctx, msg):
|
2017-12-12 17:41:59 -08:00
|
|
|
if msg.homescreen is None and msg.label is None and msg.language is None and msg.use_passphrase is None:
|
2018-02-26 16:50:52 -08:00
|
|
|
raise wire.FailureError(FailureType.ProcessError, 'No setting provided')
|
2016-11-23 05:52:02 -08:00
|
|
|
|
2017-12-12 17:41:59 -08:00
|
|
|
if msg.homescreen is not None:
|
|
|
|
await require_confirm(ctx, Text(
|
2018-02-27 14:48:51 -08:00
|
|
|
'Change homescreen', ui.ICON_CONFIG,
|
2018-02-26 16:50:52 -08:00
|
|
|
'Do you really want to', 'change homescreen?'),
|
|
|
|
code=ButtonRequestType.ProtectCall)
|
2017-12-12 17:41:59 -08:00
|
|
|
|
2016-11-23 05:52:02 -08:00
|
|
|
if msg.label is not None:
|
2017-08-15 06:09:09 -07:00
|
|
|
await require_confirm(ctx, Text(
|
2018-02-27 14:48:51 -08:00
|
|
|
'Change label', ui.ICON_CONFIG,
|
2016-11-23 05:52:02 -08:00
|
|
|
'Do you really want to', 'change label to',
|
2018-02-26 16:50:52 -08:00
|
|
|
ui.BOLD, '%s?' % msg.label), # TODO: split label (bold) and '?' (normal) once we support mixed styles on one line
|
|
|
|
code=ButtonRequestType.ProtectCall)
|
2016-11-23 05:52:02 -08:00
|
|
|
|
|
|
|
if msg.language is not None:
|
2017-08-15 06:09:09 -07:00
|
|
|
await require_confirm(ctx, Text(
|
2018-02-27 14:48:51 -08:00
|
|
|
'Change language', ui.ICON_CONFIG,
|
2016-11-23 05:52:02 -08:00
|
|
|
'Do you really want to', 'change language to',
|
2018-02-26 16:50:52 -08:00
|
|
|
ui.BOLD, '%s?' % msg.language), # TODO: split lang (bold) and '?' (normal) once we support mixed styles on one line
|
|
|
|
code=ButtonRequestType.ProtectCall)
|
2016-11-23 05:52:02 -08:00
|
|
|
|
|
|
|
if msg.use_passphrase is not None:
|
2017-08-15 06:09:09 -07:00
|
|
|
await require_confirm(ctx, Text(
|
2016-11-23 05:52:02 -08:00
|
|
|
'Enable passphrase' if msg.use_passphrase else 'Disable passphrase',
|
2018-02-27 14:48:51 -08:00
|
|
|
ui.ICON_CONFIG,
|
2016-11-23 05:52:02 -08:00
|
|
|
'Do you really want to',
|
|
|
|
'enable passphrase' if msg.use_passphrase else 'disable passphrase',
|
2018-02-26 16:50:52 -08:00
|
|
|
'encryption?'),
|
|
|
|
code=ButtonRequestType.ProtectCall)
|
2016-11-23 05:52:02 -08:00
|
|
|
|
|
|
|
storage.load_settings(label=msg.label,
|
2017-12-12 17:41:59 -08:00
|
|
|
use_passphrase=msg.use_passphrase,
|
|
|
|
homescreen=msg.homescreen)
|
2016-11-23 05:52:02 -08:00
|
|
|
|
|
|
|
return Success(message='Settings applied')
|