kivy: password dialog and wizard fixes
This commit is contained in:
parent
2226667437
commit
5f0a7db598
|
@ -243,6 +243,13 @@
|
||||||
background_active: 'atlas://gui/kivy/theming/light/textinput_active'
|
background_active: 'atlas://gui/kivy/theming/light/textinput_active'
|
||||||
|
|
||||||
|
|
||||||
|
<KButton@Button>:
|
||||||
|
size_hint: 1, None
|
||||||
|
height: '48dp'
|
||||||
|
on_release:
|
||||||
|
self.parent.update_amount(self.text)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TabbedPanelStrip>:
|
<TabbedPanelStrip>:
|
||||||
on_parent:
|
on_parent:
|
||||||
|
|
|
@ -483,17 +483,6 @@ class ElectrumWindow(App):
|
||||||
amount, fee = self.wallet.get_max_amount(self.electrum_config, inputs, None)
|
amount, fee = self.wallet.get_max_amount(self.electrum_config, inputs, None)
|
||||||
return format_satoshis_plain(amount, self.decimal_point())
|
return format_satoshis_plain(amount, self.decimal_point())
|
||||||
|
|
||||||
def update_password(self, label, c):
|
|
||||||
text = label.password
|
|
||||||
if c == '<':
|
|
||||||
text = text[:-1]
|
|
||||||
elif c == 'Clear':
|
|
||||||
text = ''
|
|
||||||
else:
|
|
||||||
text += c
|
|
||||||
label.password = text
|
|
||||||
|
|
||||||
|
|
||||||
def format_amount(self, x, is_diff=False, whitespaces=False):
|
def format_amount(self, x, is_diff=False, whitespaces=False):
|
||||||
return format_satoshis(x, is_diff, 0, self.decimal_point(), whitespaces)
|
return format_satoshis(x, is_diff, 0, self.decimal_point(), whitespaces)
|
||||||
|
|
||||||
|
@ -503,8 +492,8 @@ class ElectrumWindow(App):
|
||||||
@profiler
|
@profiler
|
||||||
def update_wallet(self, *dt):
|
def update_wallet(self, *dt):
|
||||||
self._trigger_update_status()
|
self._trigger_update_status()
|
||||||
if self.wallet.up_to_date or not self.network or not self.network.is_connected():
|
#if self.wallet.up_to_date or not self.network or not self.network.is_connected():
|
||||||
self.update_tabs()
|
self.update_tabs()
|
||||||
|
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
|
@ -736,12 +725,9 @@ class ElectrumWindow(App):
|
||||||
self.show_error("PIN numbers do not match")
|
self.show_error("PIN numbers do not match")
|
||||||
|
|
||||||
def password_dialog(self, title, f, args):
|
def password_dialog(self, title, f, args):
|
||||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv')
|
from uix.dialogs.password_dialog import PasswordDialog
|
||||||
popup.title = title
|
def callback(pw):
|
||||||
def callback():
|
|
||||||
pw = popup.ids.kb.password
|
|
||||||
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.1)
|
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.1)
|
||||||
popup.on_dismiss = callback
|
popup = PasswordDialog(title, callback)
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,6 @@ from kivy.lang import Builder
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
<KButton@Button>:
|
|
||||||
size_hint: 1, None
|
|
||||||
height: '48dp'
|
|
||||||
on_release:
|
|
||||||
self.parent.update_amount(self.text)
|
|
||||||
|
|
||||||
<AmountDialog@Popup>
|
<AmountDialog@Popup>
|
||||||
id: popup
|
id: popup
|
||||||
|
|
|
@ -43,7 +43,6 @@ Builder.load_string('''
|
||||||
on_release: if self.root: self.root.dispatch('on_release', self)
|
on_release: if self.root: self.root.dispatch('on_release', self)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<-CreateAccountDialog>
|
<-CreateAccountDialog>
|
||||||
text_color: .854, .925, .984, 1
|
text_color: .854, .925, .984, 1
|
||||||
auto_dismiss: False
|
auto_dismiss: False
|
||||||
|
@ -457,8 +456,7 @@ class RestoreSeedDialog(CreateAccountDialog):
|
||||||
self._trigger_check_seed = Clock.create_trigger(self.check_seed)
|
self._trigger_check_seed = Clock.create_trigger(self.check_seed)
|
||||||
|
|
||||||
def check_seed(self, dt):
|
def check_seed(self, dt):
|
||||||
self.ids.next.disabled = not bool(self._wizard.is_any(
|
self.ids.next.disabled = not bool(self._wizard.is_any(self.ids.text_input_seed))
|
||||||
self.ids.text_input_seed))
|
|
||||||
|
|
||||||
def on_parent(self, instance, value):
|
def on_parent(self, instance, value):
|
||||||
if value:
|
if value:
|
||||||
|
|
|
@ -73,7 +73,9 @@ class InstallWizard(Widget):
|
||||||
def is_any(self, seed_e):
|
def is_any(self, seed_e):
|
||||||
text = self.get_seed_text(seed_e)
|
text = self.get_seed_text(seed_e)
|
||||||
return (Wallet.is_seed(text) or
|
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_address(text) or
|
||||||
Wallet.is_private_key(text))
|
Wallet.is_private_key(text))
|
||||||
|
|
||||||
|
@ -129,8 +131,8 @@ class InstallWizard(Widget):
|
||||||
if Wallet.is_seed(seed):
|
if Wallet.is_seed(seed):
|
||||||
return self.password_dialog(wallet=wallet, mode='restore',
|
return self.password_dialog(wallet=wallet, mode='restore',
|
||||||
seed=seed)
|
seed=seed)
|
||||||
elif Wallet.is_mpk(seed):
|
elif Wallet.is_xpub(seed):
|
||||||
wallet = Wallet.from_mpk(seed, self.storage)
|
wallet = Wallet.from_xpub(seed, self.storage)
|
||||||
elif Wallet.is_address(seed):
|
elif Wallet.is_address(seed):
|
||||||
wallet = Wallet.from_address(seed, self.storage)
|
wallet = Wallet.from_address(seed, self.storage)
|
||||||
elif Wallet.is_private_key(seed):
|
elif Wallet.is_private_key(seed):
|
||||||
|
@ -257,18 +259,19 @@ class InstallWizard(Widget):
|
||||||
new_password = None
|
new_password = None
|
||||||
|
|
||||||
if mode == 'restore':
|
if mode == 'restore':
|
||||||
wallet = Wallet.from_seed(seed, self.storage)
|
password = unicode(ti_password.text)
|
||||||
password = (unicode(ti_password.text)
|
# if wallet and wallet.use_encryption else
|
||||||
if wallet and wallet.use_encryption else
|
# None)
|
||||||
None)
|
if not password:
|
||||||
|
password = None
|
||||||
|
wallet = Wallet.from_text(seed, password, self.storage)
|
||||||
|
|
||||||
def on_complete(*l):
|
def on_complete(*l):
|
||||||
wallet.create_accounts(new_password)
|
|
||||||
self.load_network(wallet, mode='restore')
|
self.load_network(wallet, mode='restore')
|
||||||
_dlg.close()
|
_dlg.close()
|
||||||
|
|
||||||
self.waiting_dialog(lambda: wallet.add_seed(seed, new_password),
|
self.waiting_dialog(wallet.synchronize,
|
||||||
msg=_("saving seed"),
|
msg=_("generating addresses"),
|
||||||
on_complete=on_complete)
|
on_complete=on_complete)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
Popup:
|
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
|
id: popup
|
||||||
title: _('Enter PIN Code')
|
title: _('Enter PIN Code')
|
||||||
size_hint: 0.9, 0.9
|
size_hint: 0.9, 0.9
|
||||||
|
@ -16,9 +24,9 @@ Popup:
|
||||||
|
|
||||||
GridLayout:
|
GridLayout:
|
||||||
id: kb
|
id: kb
|
||||||
update_text: app.update_password
|
update_amount: popup.update_password
|
||||||
password: ''
|
password: ''
|
||||||
on_password: if len(self.password) == 6: popup.dismiss()
|
on_password: popup.on_password(self.password)
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '300dp'
|
height: '300dp'
|
||||||
cols: 3
|
cols: 3
|
||||||
|
@ -49,3 +57,28 @@ Popup:
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 1
|
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)
|
|
@ -40,10 +40,13 @@ Builder.load_string('''
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
FileChooserListView:
|
FileChooserListView:
|
||||||
id: wallet_selector
|
id: wallet_selector
|
||||||
|
dirselect: False
|
||||||
|
filter_dirs: True
|
||||||
|
filter: '*.*'
|
||||||
path: os.path.dirname(app.wallet.storage.path)
|
path: os.path.dirname(app.wallet.storage.path)
|
||||||
on_selection:
|
on_selection:
|
||||||
wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
|
wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
|
||||||
size_hint_y: 0.5
|
size_hint_y: 0.4
|
||||||
Widget
|
Widget
|
||||||
size_hint_y: 0.1
|
size_hint_y: 0.1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue