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'
|
||||
|
||||
|
||||
<KButton@Button>:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
on_release:
|
||||
self.parent.update_amount(self.text)
|
||||
|
||||
|
||||
|
||||
<TabbedPanelStrip>:
|
||||
on_parent:
|
||||
|
|
|
@ -483,17 +483,6 @@ class ElectrumWindow(App):
|
|||
amount, fee = self.wallet.get_max_amount(self.electrum_config, inputs, None)
|
||||
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):
|
||||
return format_satoshis(x, is_diff, 0, self.decimal_point(), whitespaces)
|
||||
|
||||
|
@ -503,8 +492,8 @@ class ElectrumWindow(App):
|
|||
@profiler
|
||||
def update_wallet(self, *dt):
|
||||
self._trigger_update_status()
|
||||
if self.wallet.up_to_date or not self.network or not self.network.is_connected():
|
||||
self.update_tabs()
|
||||
#if self.wallet.up_to_date or not self.network or not self.network.is_connected():
|
||||
self.update_tabs()
|
||||
|
||||
|
||||
@profiler
|
||||
|
@ -736,12 +725,9 @@ class ElectrumWindow(App):
|
|||
self.show_error("PIN numbers do not match")
|
||||
|
||||
def password_dialog(self, title, f, args):
|
||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv')
|
||||
popup.title = title
|
||||
def callback():
|
||||
pw = popup.ids.kb.password
|
||||
from uix.dialogs.password_dialog import PasswordDialog
|
||||
def callback(pw):
|
||||
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.1)
|
||||
popup.on_dismiss = callback
|
||||
popup = PasswordDialog(title, callback)
|
||||
popup.open()
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
title: _('Enter PIN Code')
|
||||
size_hint: 0.9, 0.9
|
||||
|
@ -16,9 +24,9 @@ Popup:
|
|||
|
||||
GridLayout:
|
||||
id: kb
|
||||
update_text: app.update_password
|
||||
update_amount: popup.update_password
|
||||
password: ''
|
||||
on_password: if len(self.password) == 6: popup.dismiss()
|
||||
on_password: popup.on_password(self.password)
|
||||
size_hint: 1, None
|
||||
height: '300dp'
|
||||
cols: 3
|
||||
|
@ -49,3 +57,28 @@ Popup:
|
|||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue