kivy: add intent filter for bitcoin scheme
This commit is contained in:
@@ -66,6 +66,12 @@ class ElectrumWindow(App):
|
|||||||
|
|
||||||
language = StringProperty('en')
|
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):
|
def on_language(self, instance, language):
|
||||||
Logger.info('language: {}'.format(language))
|
Logger.info('language: {}'.format(language))
|
||||||
_.switch_lang(language)
|
_.switch_lang(language)
|
||||||
@@ -234,7 +240,7 @@ class ElectrumWindow(App):
|
|||||||
|
|
||||||
def on_uri(self, instance, uri):
|
def on_uri(self, instance, uri):
|
||||||
if uri:
|
if uri:
|
||||||
Logger.info("on uri:", uri)
|
Logger.info("on uri:" + uri)
|
||||||
self.switch_to('send')
|
self.switch_to('send')
|
||||||
self.set_URI(uri)
|
self.set_URI(uri)
|
||||||
|
|
||||||
@@ -323,6 +329,10 @@ class ElectrumWindow(App):
|
|||||||
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('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):
|
def load_wallet_by_name(self, wallet_path):
|
||||||
if not wallet_path:
|
if not wallet_path:
|
||||||
@@ -543,8 +553,6 @@ class ElectrumWindow(App):
|
|||||||
Logger.Error('Notification: needs plyer; `sudo pip install plyer`')
|
Logger.Error('Notification: needs plyer; `sudo pip install plyer`')
|
||||||
|
|
||||||
def on_pause(self):
|
def on_pause(self):
|
||||||
'''
|
|
||||||
'''
|
|
||||||
# pause nfc
|
# pause nfc
|
||||||
if self.qrscanner:
|
if self.qrscanner:
|
||||||
self.qrscanner.stop()
|
self.qrscanner.stop()
|
||||||
@@ -553,8 +561,6 @@ class ElectrumWindow(App):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def on_resume(self):
|
def on_resume(self):
|
||||||
'''
|
|
||||||
'''
|
|
||||||
if self.qrscanner and qrscanner.get_parent_window():
|
if self.qrscanner and qrscanner.get_parent_window():
|
||||||
self.qrscanner.start()
|
self.qrscanner.start()
|
||||||
if self.nfcscanner:
|
if self.nfcscanner:
|
||||||
@@ -564,9 +570,6 @@ class ElectrumWindow(App):
|
|||||||
width, height = value
|
width, height = value
|
||||||
self._orientation = 'landscape' if width > height else 'portrait'
|
self._orientation = 'landscape' if width > height else 'portrait'
|
||||||
self._ui_mode = 'tablet' if min(width, height) > inch(3.51) else 'phone'
|
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):
|
def set_send(self, address, amount, label, message):
|
||||||
self.send_payment(address, amount=amount, label=label, message=message)
|
self.send_payment(address, amount=amount, label=label, message=message)
|
||||||
|
|||||||
7
gui/kivy/tools/bitcoin_intent.xml
Normal file
7
gui/kivy/tools/bitcoin_intent.xml
Normal file
@@ -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>
|
||||||
@@ -101,7 +101,7 @@ android.private_storage = True
|
|||||||
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
|
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
|
||||||
|
|
||||||
# (str) XML file to include as an intent filters in <activity> tag
|
# (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
|
# (list) Android additionnal libraries to copy into libs/armeabi
|
||||||
#android.add_libs_armeabi = lib/android/*.so
|
#android.add_libs_armeabi = lib/android/*.so
|
||||||
|
|||||||
Reference in New Issue
Block a user