kivy: move set_URI method to Receive screen

This commit is contained in:
ThomasV 2016-02-15 10:25:00 +01:00
parent a7d3175799
commit d91d321dfa
2 changed files with 16 additions and 28 deletions

View File

@ -70,7 +70,8 @@ class ElectrumWindow(App):
if intent.getScheme() != 'bitcoin':
return
uri = intent.getDataString()
self.uri = uri
self.switch_to('send')
self.send_screen.set_URI(uri)
def on_language(self, instance, language):
Logger.info('language: {}'.format(language))
@ -164,8 +165,6 @@ class ElectrumWindow(App):
:data:`ui_mode` is a read only `AliasProperty` Defaults to 'phone'
'''
uri = StringProperty('', allownone=True)
wallet = ObjectProperty(None)
'''Holds the electrum wallet
@ -195,8 +194,6 @@ class ElectrumWindow(App):
self.contacts = Contacts(self.electrum_config)
self.invoices = InvoiceStore(self.electrum_config)
self.bind(uri=self.on_uri)
# create triggers so as to minimize updation a max of 2 times a sec
self._trigger_update_wallet =\
Clock.create_trigger(self.update_wallet, .5)
@ -228,17 +225,10 @@ class ElectrumWindow(App):
self.show_error("invoice error:" + pr.error)
self.send_screen.do_clear()
def set_URI(self, url):
try:
d = electrum.util.parse_URI(url, self.on_pr)
except:
self.show_info(_("Not a Bitcoin URI") + ':\n', url)
return
self.send_screen.set_URI(d)
def on_qr(self, data):
if data.startswith('bitcoin:'):
self.set_URI(data)
self.switch_to('send')
self.send_screen.set_URI(data)
else:
from electrum.bitcoin import base_decode
from electrum.transaction import Transaction
@ -246,12 +236,6 @@ class ElectrumWindow(App):
tx = Transaction(text)
self.tx_dialog(tx)
def on_uri(self, instance, uri):
if uri:
Logger.info("on uri:" + uri)
self.switch_to('send')
self.set_URI(uri)
def update_tab(self, name):
s = getattr(self, name + '_screen', None)
if s:
@ -339,9 +323,9 @@ class ElectrumWindow(App):
# init plugins
run_hook('init_kivy', self)
# were we sent a url?
self.uri = self.electrum_config.get('url')
#self.uri = self.electrum_config.get('url')
# default tab
self.switch_to('send' if self.uri else 'history')
self.switch_to('history')
# bind intent for bitcoin: URI scheme
if platform == 'android':
from android import activity

View File

@ -184,12 +184,17 @@ class SendScreen(CScreen):
kvname = 'send'
payment_request = None
def set_URI(self, uri):
def set_URI(self, text):
import electrum
try:
uri = electrum.util.parse_URI(text, self.app.on_pr)
except:
self.app.show_info(_("Not a Bitcoin URI") + ':\n', text)
return
self.screen.address = uri.get('address', '')
self.screen.message = uri.get('message', '')
amount = uri.get('amount')
if amount:
self.screen.amount = self.app.format_amount_and_units(amount)
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
def update(self):
pass
@ -204,8 +209,7 @@ class SendScreen(CScreen):
self.payment_request = pr
self.screen.address = pr.get_requestor()
amount = pr.get_amount()
if amount:
self.screen.amount = self.app.format_amount_and_units(amount)
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
self.screen.message = pr.get_memo()
def do_save(self):
@ -230,7 +234,7 @@ class SendScreen(CScreen):
if not contents:
self.app.show_info(_("Clipboard is empty"))
return
self.app.set_URI(contents)
self.set_URI(contents)
def do_send(self):
if self.payment_request: