kivy: move set_URI method to Receive screen
This commit is contained in:
@@ -70,7 +70,8 @@ class ElectrumWindow(App):
|
|||||||
if intent.getScheme() != 'bitcoin':
|
if intent.getScheme() != 'bitcoin':
|
||||||
return
|
return
|
||||||
uri = intent.getDataString()
|
uri = intent.getDataString()
|
||||||
self.uri = uri
|
self.switch_to('send')
|
||||||
|
self.send_screen.set_URI(uri)
|
||||||
|
|
||||||
def on_language(self, instance, language):
|
def on_language(self, instance, language):
|
||||||
Logger.info('language: {}'.format(language))
|
Logger.info('language: {}'.format(language))
|
||||||
@@ -164,8 +165,6 @@ class ElectrumWindow(App):
|
|||||||
:data:`ui_mode` is a read only `AliasProperty` Defaults to 'phone'
|
:data:`ui_mode` is a read only `AliasProperty` Defaults to 'phone'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
uri = StringProperty('', allownone=True)
|
|
||||||
|
|
||||||
wallet = ObjectProperty(None)
|
wallet = ObjectProperty(None)
|
||||||
'''Holds the electrum wallet
|
'''Holds the electrum wallet
|
||||||
|
|
||||||
@@ -195,8 +194,6 @@ class ElectrumWindow(App):
|
|||||||
self.contacts = Contacts(self.electrum_config)
|
self.contacts = Contacts(self.electrum_config)
|
||||||
self.invoices = InvoiceStore(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
|
# create triggers so as to minimize updation a max of 2 times a sec
|
||||||
self._trigger_update_wallet =\
|
self._trigger_update_wallet =\
|
||||||
Clock.create_trigger(self.update_wallet, .5)
|
Clock.create_trigger(self.update_wallet, .5)
|
||||||
@@ -228,17 +225,10 @@ class ElectrumWindow(App):
|
|||||||
self.show_error("invoice error:" + pr.error)
|
self.show_error("invoice error:" + pr.error)
|
||||||
self.send_screen.do_clear()
|
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):
|
def on_qr(self, data):
|
||||||
if data.startswith('bitcoin:'):
|
if data.startswith('bitcoin:'):
|
||||||
self.set_URI(data)
|
self.switch_to('send')
|
||||||
|
self.send_screen.set_URI(data)
|
||||||
else:
|
else:
|
||||||
from electrum.bitcoin import base_decode
|
from electrum.bitcoin import base_decode
|
||||||
from electrum.transaction import Transaction
|
from electrum.transaction import Transaction
|
||||||
@@ -246,12 +236,6 @@ class ElectrumWindow(App):
|
|||||||
tx = Transaction(text)
|
tx = Transaction(text)
|
||||||
self.tx_dialog(tx)
|
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):
|
def update_tab(self, name):
|
||||||
s = getattr(self, name + '_screen', None)
|
s = getattr(self, name + '_screen', None)
|
||||||
if s:
|
if s:
|
||||||
@@ -339,9 +323,9 @@ class ElectrumWindow(App):
|
|||||||
# init plugins
|
# init plugins
|
||||||
run_hook('init_kivy', self)
|
run_hook('init_kivy', self)
|
||||||
# were we sent a url?
|
# were we sent a url?
|
||||||
self.uri = self.electrum_config.get('url')
|
#self.uri = self.electrum_config.get('url')
|
||||||
# default tab
|
# default tab
|
||||||
self.switch_to('send' if self.uri else 'history')
|
self.switch_to('history')
|
||||||
# bind intent for bitcoin: URI scheme
|
# bind intent for bitcoin: URI scheme
|
||||||
if platform == 'android':
|
if platform == 'android':
|
||||||
from android import activity
|
from android import activity
|
||||||
|
|||||||
@@ -184,12 +184,17 @@ class SendScreen(CScreen):
|
|||||||
kvname = 'send'
|
kvname = 'send'
|
||||||
payment_request = None
|
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.address = uri.get('address', '')
|
||||||
self.screen.message = uri.get('message', '')
|
self.screen.message = uri.get('message', '')
|
||||||
amount = uri.get('amount')
|
amount = uri.get('amount')
|
||||||
if amount:
|
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
|
||||||
self.screen.amount = self.app.format_amount_and_units(amount)
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
pass
|
pass
|
||||||
@@ -204,8 +209,7 @@ class SendScreen(CScreen):
|
|||||||
self.payment_request = pr
|
self.payment_request = pr
|
||||||
self.screen.address = pr.get_requestor()
|
self.screen.address = pr.get_requestor()
|
||||||
amount = pr.get_amount()
|
amount = pr.get_amount()
|
||||||
if amount:
|
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
|
||||||
self.screen.amount = self.app.format_amount_and_units(amount)
|
|
||||||
self.screen.message = pr.get_memo()
|
self.screen.message = pr.get_memo()
|
||||||
|
|
||||||
def do_save(self):
|
def do_save(self):
|
||||||
@@ -230,7 +234,7 @@ class SendScreen(CScreen):
|
|||||||
if not contents:
|
if not contents:
|
||||||
self.app.show_info(_("Clipboard is empty"))
|
self.app.show_info(_("Clipboard is empty"))
|
||||||
return
|
return
|
||||||
self.app.set_URI(contents)
|
self.set_URI(contents)
|
||||||
|
|
||||||
def do_send(self):
|
def do_send(self):
|
||||||
if self.payment_request:
|
if self.payment_request:
|
||||||
|
|||||||
Reference in New Issue
Block a user