kivy: improve settings and password dialogs
This commit is contained in:
parent
0d5114b6c2
commit
37e93928ab
|
@ -317,6 +317,27 @@
|
|||
if self.parent: self.parent.parent.dismiss()
|
||||
app.popup_dialog(self.name)
|
||||
|
||||
|
||||
<SettingsItem@ButtonBehavior+BoxLayout>
|
||||
orientation: 'vertical'
|
||||
title: ''
|
||||
description: ''
|
||||
size_hint: 1, None
|
||||
Label:
|
||||
id: title
|
||||
text: self.parent.title
|
||||
size_hint: 1, 1
|
||||
bold: True
|
||||
text_size: self.size
|
||||
halign: 'left'
|
||||
Label:
|
||||
text: self.parent.description
|
||||
size_hint: 1, 1
|
||||
text_size: self.size
|
||||
color: 0.8, 0.8, 0.8, 1
|
||||
halign: 'left'
|
||||
|
||||
|
||||
BoxLayout:
|
||||
|
||||
orientation: 'vertical'
|
||||
|
|
|
@ -9,7 +9,7 @@ import electrum
|
|||
from electrum import WalletStorage, Wallet
|
||||
from electrum.i18n import _, set_language
|
||||
from electrum.contacts import Contacts
|
||||
from electrum.util import profiler
|
||||
from electrum.util import profiler, InvalidPassword
|
||||
from electrum.plugins import run_hook
|
||||
from electrum.util import format_satoshis, format_satoshis_plain
|
||||
|
||||
|
@ -798,19 +798,40 @@ class ElectrumWindow(App):
|
|||
popup.on_dismiss = cb
|
||||
popup.open()
|
||||
|
||||
def change_password(self):
|
||||
self.password_dialog(self._change_password, ())
|
||||
|
||||
def _change_password(self, password):
|
||||
print "zs", password
|
||||
|
||||
def password_dialog(self, f, args):
|
||||
def protected(self, f, args):
|
||||
if self.wallet.use_encryption:
|
||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv')
|
||||
def callback():
|
||||
pw = popup.ids.kb.password
|
||||
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.5)
|
||||
popup.on_dismiss = callback
|
||||
popup.open()
|
||||
self.password_dialog(_('Enter PIN'), f, args)
|
||||
else:
|
||||
apply(f, args + (None,))
|
||||
|
||||
def change_password(self):
|
||||
self.protected(self._change_password, ())
|
||||
|
||||
def _change_password(self, old_password):
|
||||
if old_password:
|
||||
try:
|
||||
self.wallet.check_password(old_password)
|
||||
except InvalidPassword:
|
||||
self.show_error("Invalid PIN")
|
||||
return
|
||||
self.password_dialog(_('Enter new PIN'), self._change_password2, (old_password,))
|
||||
|
||||
def _change_password2(self, old_password, new_password):
|
||||
self.password_dialog(_('Confirm new PIN'), self._change_password3, (old_password, new_password))
|
||||
|
||||
def _change_password3(self, old_password, new_password, confirmed_password):
|
||||
if new_password == confirmed_password:
|
||||
self.wallet.update_password(old_password, new_password)
|
||||
else:
|
||||
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
|
||||
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.1)
|
||||
popup.on_dismiss = callback
|
||||
popup.open()
|
||||
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ class SendScreen(CScreen):
|
|||
message = unicode(self.screen.message)
|
||||
fee = None
|
||||
outputs = [('address', address, amount)]
|
||||
self.app.password_dialog(self.send_tx, (outputs, fee, message))
|
||||
self.app.protected(self.send_tx, (outputs, fee, message))
|
||||
|
||||
def send_tx(self, *args):
|
||||
self.app.show_info("Sending...")
|
||||
|
|
|
@ -3,38 +3,24 @@ Popup:
|
|||
title: _('Settings')
|
||||
|
||||
BoxLayout:
|
||||
|
||||
orientation: 'vertical'
|
||||
|
||||
Button:
|
||||
text: _('Set PIN Code')
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
on_release: app.change_password()
|
||||
|
||||
GridLayout:
|
||||
cols: 2
|
||||
size_hint: 1, None
|
||||
height: '100dp'
|
||||
Label:
|
||||
text: _('Base unit')
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
Button:
|
||||
text: app.base_unit
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
on_release:
|
||||
app._rotate_bu()
|
||||
self.text = app.base_unit
|
||||
Label:
|
||||
size_hint: 1, None
|
||||
text: 'OpenAlias'
|
||||
height: '48dp'
|
||||
TextInput:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
multiline: False
|
||||
SettingsItem:
|
||||
title: _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||
description: _("Your PIN code will be required in order to spend bitcoins.")
|
||||
on_release:
|
||||
app.change_password()
|
||||
self.title = _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||
CardSeparator
|
||||
SettingsItem:
|
||||
title: _('Denomination') + ' (' + app.base_unit + ')'
|
||||
description: "Base unit for Bitcoin amounts."
|
||||
on_release:
|
||||
app._rotate_bu()
|
||||
self.title = _('Denomination') + ' (' + app.base_unit + ')'
|
||||
CardSeparator
|
||||
SettingsItem:
|
||||
title: _('OpenAlias')
|
||||
description: "Email-like address."
|
||||
|
||||
Widget:
|
||||
size_hint: 1, 1
|
||||
|
|
Loading…
Reference in New Issue