qml: handle bitcoin: and lightning: uri intents
This commit is contained in:
@@ -175,8 +175,8 @@ RUN cd /opt \
|
||||
&& git remote add sombernight https://github.com/SomberNight/python-for-android \
|
||||
&& git remote add accumulator https://github.com/accumulator/python-for-android \
|
||||
&& git fetch --all \
|
||||
# commit: from branch sombernight/electrum_20210421d
|
||||
&& git checkout "1187e179aed6fddb19bf026274ff69903d3b04b2^{commit}" \
|
||||
# commit: from branch accumulator/electrum_20210421d
|
||||
&& git checkout "a16a3dd5cf8fe0f846663bce9e248e5432dbbf2d^{commit}" \
|
||||
&& python3 -m pip install --no-build-isolation --no-dependencies --user -e .
|
||||
|
||||
# build env vars
|
||||
|
||||
@@ -12,12 +12,32 @@ Item {
|
||||
|
||||
property string title: Daemon.currentWallet ? Daemon.currentWallet.name : ''
|
||||
|
||||
property var _sendDialog
|
||||
|
||||
function openInvoice(key) {
|
||||
var dialog = invoiceDialog.createObject(app, { invoice: invoiceParser, invoice_key: key })
|
||||
dialog.open()
|
||||
return dialog
|
||||
}
|
||||
|
||||
function openSendDialog() {
|
||||
_sendDialog = sendDialog.createObject(mainView, {invoiceParser: invoiceParser})
|
||||
_sendDialog.open()
|
||||
}
|
||||
|
||||
function closeSendDialog() {
|
||||
if (_sendDialog) {
|
||||
_sendDialog.close()
|
||||
_sendDialog = null
|
||||
}
|
||||
}
|
||||
|
||||
function restartSendDialog() {
|
||||
if (_sendDialog) {
|
||||
_sendDialog.restart()
|
||||
}
|
||||
}
|
||||
|
||||
property QtObject menu: Menu {
|
||||
id: menu
|
||||
MenuItem {
|
||||
@@ -136,11 +156,7 @@ Item {
|
||||
Layout.preferredWidth: 1
|
||||
icon.source: '../../icons/tab_send.png'
|
||||
text: qsTr('Send')
|
||||
onClicked: {
|
||||
console.log('send')
|
||||
_sendDialog = sendDialog.createObject(mainView, {invoiceParser: invoiceParser})
|
||||
_sendDialog.open()
|
||||
}
|
||||
onClicked: openSendDialog()
|
||||
}
|
||||
Rectangle {
|
||||
Layout.fillWidth: false
|
||||
@@ -168,7 +184,7 @@ Item {
|
||||
onValidationError: {
|
||||
var dialog = app.messageDialog.createObject(app, { text: message })
|
||||
dialog.closed.connect(function() {
|
||||
_sendDialog.restart()
|
||||
restartSendDialog()
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
@@ -181,7 +197,7 @@ Item {
|
||||
}
|
||||
}
|
||||
onValidationSuccess: {
|
||||
_sendDialog.close()
|
||||
closeSendDialog()
|
||||
var dialog = invoiceDialog.createObject(app, { invoice: invoiceParser })
|
||||
dialog.open()
|
||||
}
|
||||
@@ -193,6 +209,13 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: AppController
|
||||
function onUriReceived(uri) {
|
||||
invoiceParser.recipient = uri
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: invoiceDialog
|
||||
InvoiceDialog {
|
||||
@@ -233,8 +256,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
property var _sendDialog
|
||||
|
||||
Component {
|
||||
id: sendDialog
|
||||
SendDialog {
|
||||
|
||||
@@ -7,8 +7,9 @@ from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty, QObject, QUrl, QLoc
|
||||
from PyQt5.QtGui import QGuiApplication, QFontDatabase
|
||||
from PyQt5.QtQml import qmlRegisterType, qmlRegisterUncreatableType, QQmlApplicationEngine
|
||||
|
||||
from electrum.logging import Logger, get_logger
|
||||
from electrum import version
|
||||
from electrum.logging import Logger, get_logger
|
||||
from electrum.util import BITCOIN_BIP21_URI_SCHEME, LIGHTNING_URI_SCHEME
|
||||
|
||||
from .qeconfig import QEConfig
|
||||
from .qedaemon import QEDaemon, QEWalletListModel
|
||||
@@ -33,6 +34,7 @@ notification = None
|
||||
|
||||
class QEAppController(QObject):
|
||||
userNotify = pyqtSignal(str)
|
||||
uriReceived = pyqtSignal(str)
|
||||
|
||||
_dummy = pyqtSignal()
|
||||
|
||||
@@ -56,6 +58,8 @@ class QEAppController(QObject):
|
||||
|
||||
self.userNotify.connect(self.notifyAndroid)
|
||||
|
||||
self.bindIntent()
|
||||
|
||||
def on_wallet_loaded(self):
|
||||
qewallet = self._qedaemon.currentWallet
|
||||
if not qewallet:
|
||||
@@ -105,6 +109,23 @@ class QEAppController(QObject):
|
||||
except Exception as e:
|
||||
self.logger.error(repr(e))
|
||||
|
||||
def bindIntent(self):
|
||||
try:
|
||||
from android import activity
|
||||
from jnius import autoclass
|
||||
PythonActivity = autoclass('org.kivy.android.PythonActivity')
|
||||
mactivity = PythonActivity.mActivity
|
||||
self.on_new_intent(mactivity.getIntent())
|
||||
activity.bind(on_new_intent=self.on_new_intent)
|
||||
except Exception as e:
|
||||
self.logger.error(f'unable to bind intent: {repr(e)}')
|
||||
|
||||
def on_new_intent(self, intent):
|
||||
data = str(intent.getDataString())
|
||||
scheme = str(intent.getScheme()).lower()
|
||||
if scheme == BITCOIN_BIP21_URI_SCHEME or scheme == LIGHTNING_URI_SCHEME:
|
||||
self.uriReceived.emit(data)
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def doShare(self, data, title):
|
||||
#if platform != 'android':
|
||||
|
||||
Reference in New Issue
Block a user