Browse Source

kivy: add intent filter for bitcoin scheme

283
ThomasV 9 years ago
parent
commit
ccff1c2a88
  1. 19
      gui/kivy/main_window.py
  2. 7
      gui/kivy/tools/bitcoin_intent.xml
  3. 2
      gui/kivy/tools/buildozer.spec

19
gui/kivy/main_window.py

@ -66,6 +66,12 @@ class ElectrumWindow(App):
language = StringProperty('en')
def on_new_intent(self, intent):
if intent.getScheme() != 'bitcoin':
return
uri = intent.getDataString()
self.uri = uri
def on_language(self, instance, language):
Logger.info('language: {}'.format(language))
_.switch_lang(language)
@ -234,7 +240,7 @@ class ElectrumWindow(App):
def on_uri(self, instance, uri):
if uri:
Logger.info("on uri:", uri)
Logger.info("on uri:" + uri)
self.switch_to('send')
self.set_URI(uri)
@ -323,6 +329,10 @@ class ElectrumWindow(App):
self.uri = self.electrum_config.get('url')
# default tab
self.switch_to('send' if self.uri else 'history')
# bind intent for bitcoin: URI scheme
if platform == 'android':
from android import activity
activity.bind(on_new_intent=self.on_new_intent)
def load_wallet_by_name(self, wallet_path):
if not wallet_path:
@ -543,8 +553,6 @@ class ElectrumWindow(App):
Logger.Error('Notification: needs plyer; `sudo pip install plyer`')
def on_pause(self):
'''
'''
# pause nfc
if self.qrscanner:
self.qrscanner.stop()
@ -553,8 +561,6 @@ class ElectrumWindow(App):
return True
def on_resume(self):
'''
'''
if self.qrscanner and qrscanner.get_parent_window():
self.qrscanner.start()
if self.nfcscanner:
@ -564,9 +570,6 @@ class ElectrumWindow(App):
width, height = value
self._orientation = 'landscape' if width > height else 'portrait'
self._ui_mode = 'tablet' if min(width, height) > inch(3.51) else 'phone'
#Logger.info("size: {} {}".format(width, height))
#Logger.info('orientation: {}'.format(self._orientation))
#Logger.info('ui_mode: {}'.format(self._ui_mode))
def set_send(self, address, amount, label, message):
self.send_payment(address, amount=amount, label=label, message=message)

7
gui/kivy/tools/bitcoin_intent.xml

@ -0,0 +1,7 @@
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="bitcoin" />
</intent-filter>

2
gui/kivy/tools/buildozer.spec

@ -101,7 +101,7 @@ android.private_storage = True
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters = nfc_filter.xml
android.manifest.intent_filters = gui/kivy/tools/bitcoin_intent.xml
# (list) Android additionnal libraries to copy into libs/armeabi
#android.add_libs_armeabi = lib/android/*.so

Loading…
Cancel
Save