1
0

kivy: password dialog and wizard fixes

This commit is contained in:
ThomasV
2015-12-20 17:37:07 +01:00
parent 2226667437
commit 5f0a7db598
7 changed files with 66 additions and 41 deletions

View File

@@ -5,11 +5,6 @@ from kivy.lang import Builder
from decimal import Decimal
Builder.load_string('''
<KButton@Button>:
size_hint: 1, None
height: '48dp'
on_release:
self.parent.update_amount(self.text)
<AmountDialog@Popup>
id: popup

View File

@@ -43,7 +43,6 @@ Builder.load_string('''
on_release: if self.root: self.root.dispatch('on_release', self)
<-CreateAccountDialog>
text_color: .854, .925, .984, 1
auto_dismiss: False
@@ -457,8 +456,7 @@ class RestoreSeedDialog(CreateAccountDialog):
self._trigger_check_seed = Clock.create_trigger(self.check_seed)
def check_seed(self, dt):
self.ids.next.disabled = not bool(self._wizard.is_any(
self.ids.text_input_seed))
self.ids.next.disabled = not bool(self._wizard.is_any(self.ids.text_input_seed))
def on_parent(self, instance, value):
if value:

View File

@@ -73,7 +73,9 @@ class InstallWizard(Widget):
def is_any(self, seed_e):
text = self.get_seed_text(seed_e)
return (Wallet.is_seed(text) or
Wallet.is_mpk(text) or
Wallet.is_old_mpk(text) or
Wallet.is_xpub(text) or
Wallet.is_xprv(text) or
Wallet.is_address(text) or
Wallet.is_private_key(text))
@@ -129,8 +131,8 @@ class InstallWizard(Widget):
if Wallet.is_seed(seed):
return self.password_dialog(wallet=wallet, mode='restore',
seed=seed)
elif Wallet.is_mpk(seed):
wallet = Wallet.from_mpk(seed, self.storage)
elif Wallet.is_xpub(seed):
wallet = Wallet.from_xpub(seed, self.storage)
elif Wallet.is_address(seed):
wallet = Wallet.from_address(seed, self.storage)
elif Wallet.is_private_key(seed):
@@ -257,18 +259,19 @@ class InstallWizard(Widget):
new_password = None
if mode == 'restore':
wallet = Wallet.from_seed(seed, self.storage)
password = (unicode(ti_password.text)
if wallet and wallet.use_encryption else
None)
password = unicode(ti_password.text)
# if wallet and wallet.use_encryption else
# None)
if not password:
password = None
wallet = Wallet.from_text(seed, password, self.storage)
def on_complete(*l):
wallet.create_accounts(new_password)
self.load_network(wallet, mode='restore')
_dlg.close()
self.waiting_dialog(lambda: wallet.add_seed(seed, new_password),
msg=_("saving seed"),
self.waiting_dialog(wallet.synchronize,
msg=_("generating addresses"),
on_complete=on_complete)
return

View File

@@ -0,0 +1,84 @@
from kivy.app import App
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from decimal import Decimal
Builder.load_string('''
<PasswordDialog@Popup>
id: popup
title: _('Enter PIN Code')
size_hint: 0.9, 0.9
BoxLayout:
orientation: 'vertical'
size_hint: 0.8, 1
Label:
id: a
text: ' * '*len(kb.password) + ' o '*(6-len(kb.password))
size_hint: 1, None
height: '48dp'
GridLayout:
id: kb
update_amount: popup.update_password
password: ''
on_password: popup.on_password(self.password)
size_hint: 1, None
height: '300dp'
cols: 3
KButton:
text: '1'
KButton:
text: '2'
KButton:
text: '3'
KButton:
text: '4'
KButton:
text: '5'
KButton:
text: '6'
KButton:
text: '7'
KButton:
text: '8'
KButton:
text: '9'
KButton:
text: 'Clear'
KButton:
text: '0'
KButton:
text: '<'
Widget:
size_hint: 1, 1
''')
class PasswordDialog(Factory.Popup):
def __init__(self, title, cb):
Factory.Popup.__init__(self)
self.title = title
self.callback = cb
def update_password(self, c):
kb = self.ids.kb
text = kb.password
if c == '<':
text = text[:-1]
elif c == 'Clear':
text = ''
else:
text += c
kb.password = text
def on_password(self, pw):
if len(pw) == 6:
self.dismiss()
self.callback(pw)

View File

@@ -40,10 +40,13 @@ Builder.load_string('''
size_hint_y: None
FileChooserListView:
id: wallet_selector
dirselect: False
filter_dirs: True
filter: '*.*'
path: os.path.dirname(app.wallet.storage.path)
on_selection:
wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
size_hint_y: 0.5
size_hint_y: 0.4
Widget
size_hint_y: 0.1