commit d91d321dfab60ab1171c9a580d7d98e21d92574a
parent a7d3175799018f9a378e8b2bcb5508dcf30c5be4
Author: ThomasV <thomasv@electrum.org>
Date: Mon, 15 Feb 2016 10:25:00 +0100
kivy: move set_URI method to Receive screen
Diffstat:
2 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -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
diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
@@ -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: