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()
|
if self.parent: self.parent.parent.dismiss()
|
||||||
app.popup_dialog(self.name)
|
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:
|
BoxLayout:
|
||||||
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
|
|
|
@ -9,7 +9,7 @@ import electrum
|
||||||
from electrum import WalletStorage, Wallet
|
from electrum import WalletStorage, Wallet
|
||||||
from electrum.i18n import _, set_language
|
from electrum.i18n import _, set_language
|
||||||
from electrum.contacts import Contacts
|
from electrum.contacts import Contacts
|
||||||
from electrum.util import profiler
|
from electrum.util import profiler, InvalidPassword
|
||||||
from electrum.plugins import run_hook
|
from electrum.plugins import run_hook
|
||||||
from electrum.util import format_satoshis, format_satoshis_plain
|
from electrum.util import format_satoshis, format_satoshis_plain
|
||||||
|
|
||||||
|
@ -798,19 +798,40 @@ class ElectrumWindow(App):
|
||||||
popup.on_dismiss = cb
|
popup.on_dismiss = cb
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
def change_password(self):
|
def protected(self, f, args):
|
||||||
self.password_dialog(self._change_password, ())
|
|
||||||
|
|
||||||
def _change_password(self, password):
|
|
||||||
print "zs", password
|
|
||||||
|
|
||||||
def password_dialog(self, f, args):
|
|
||||||
if self.wallet.use_encryption:
|
if self.wallet.use_encryption:
|
||||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv')
|
self.password_dialog(_('Enter PIN'), f, args)
|
||||||
def callback():
|
|
||||||
pw = popup.ids.kb.password
|
|
||||||
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.5)
|
|
||||||
popup.on_dismiss = callback
|
|
||||||
popup.open()
|
|
||||||
else:
|
else:
|
||||||
apply(f, args + (None,))
|
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)
|
message = unicode(self.screen.message)
|
||||||
fee = None
|
fee = None
|
||||||
outputs = [('address', address, amount)]
|
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):
|
def send_tx(self, *args):
|
||||||
self.app.show_info("Sending...")
|
self.app.show_info("Sending...")
|
||||||
|
|
|
@ -3,38 +3,24 @@ Popup:
|
||||||
title: _('Settings')
|
title: _('Settings')
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
|
SettingsItem:
|
||||||
Button:
|
title: _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||||
text: _('Set PIN Code')
|
description: _("Your PIN code will be required in order to spend bitcoins.")
|
||||||
size_hint: 1, None
|
on_release:
|
||||||
height: '48dp'
|
app.change_password()
|
||||||
on_release: app.change_password()
|
self.title = _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||||
|
CardSeparator
|
||||||
GridLayout:
|
SettingsItem:
|
||||||
cols: 2
|
title: _('Denomination') + ' (' + app.base_unit + ')'
|
||||||
size_hint: 1, None
|
description: "Base unit for Bitcoin amounts."
|
||||||
height: '100dp'
|
on_release:
|
||||||
Label:
|
app._rotate_bu()
|
||||||
text: _('Base unit')
|
self.title = _('Denomination') + ' (' + app.base_unit + ')'
|
||||||
size_hint: 1, None
|
CardSeparator
|
||||||
height: '48dp'
|
SettingsItem:
|
||||||
Button:
|
title: _('OpenAlias')
|
||||||
text: app.base_unit
|
description: "Email-like address."
|
||||||
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
|
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
|
|
Loading…
Reference in New Issue