mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge branch 'android_share_intent'
This commit is contained in:
commit
e46d91e9a4
@ -50,15 +50,15 @@ Item
|
||||
var radix = JSON.parse(par.response).data.cert_string
|
||||
var name = mainWindow.user_name
|
||||
var encodedName = UriJs.URI.encode(name)
|
||||
ClipboardWrapper.postToClipBoard(
|
||||
var nodeUrl = (
|
||||
"retroshare://certificate?" +
|
||||
"name=" + encodedName +
|
||||
"&radix=" + UriJs.URI.encode(radix) +
|
||||
"&location=" + encodedName
|
||||
)
|
||||
|
||||
"&location=" + encodedName )
|
||||
ClipboardWrapper.postToClipBoard(nodeUrl)
|
||||
linkCopiedPopup.itemName = name
|
||||
linkCopiedPopup.open()
|
||||
platformGW.shareUrl(nodeUrl);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ Item
|
||||
function(par)
|
||||
{
|
||||
var jD = JSON.parse(par.response).data
|
||||
ClipboardWrapper.postToClipBoard(
|
||||
var contactUrl = (
|
||||
"retroshare://" +
|
||||
"identity?gxsid=" +
|
||||
cntDt.md.gxs_id +
|
||||
@ -131,8 +131,10 @@ Item
|
||||
UriJs.URI.encode(cntDt.md.name) +
|
||||
"&groupdata=" +
|
||||
UriJs.URI.encode(jD.radix) )
|
||||
ClipboardWrapper.postToClipBoard(contactUrl)
|
||||
linkCopiedPopup.itemName = cntDt.md.name
|
||||
linkCopiedPopup.visible = true
|
||||
platformGW.shareUrl(contactUrl);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -65,6 +65,17 @@ public class RetroShareQmlActivity extends QtActivity
|
||||
if (uri != null) NativeCalls.notifyIntentUri(uri);
|
||||
}
|
||||
|
||||
@UsedByNativeCode @SuppressWarnings("unused")
|
||||
public void shareUrl(String urlStr)
|
||||
{
|
||||
Intent shareIntent = new Intent()
|
||||
.setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, urlStr)
|
||||
.setType("text/plain");
|
||||
startActivity(Intent.createChooser(shareIntent,"")); // TODO: Need proper title?
|
||||
}
|
||||
|
||||
|
||||
private boolean isMyServiceRunning(Class<?> serviceClass)
|
||||
{
|
||||
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
|
41
retroshare-qml-app/src/androidplatforminteracions.cpp
Normal file
41
retroshare-qml-app/src/androidplatforminteracions.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* RetroShare Android QML App
|
||||
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "androidplatforminteracions.h"
|
||||
|
||||
#include <QtAndroid>
|
||||
#include <QtAndroidExtras/QAndroidJniObject>
|
||||
|
||||
AndroidPlatformInteracions::AndroidPlatformInteracions(QObject *parent) :
|
||||
PlatformInteracions(parent) {}
|
||||
|
||||
void AndroidPlatformInteracions::shareUrl(QUrl url)
|
||||
{
|
||||
QString encUri = url.toString(QUrl::FullyEncoded);
|
||||
QAndroidJniObject uriStr = QAndroidJniObject::fromString(encUri);
|
||||
|
||||
QtAndroid::runOnAndroidThread(
|
||||
[uriStr]()
|
||||
{
|
||||
QtAndroid::androidActivity()
|
||||
.callMethod<void>(
|
||||
"shareUrl",
|
||||
"(Ljava/lang/String;)V",
|
||||
uriStr.object<jstring>());
|
||||
});
|
||||
}
|
34
retroshare-qml-app/src/androidplatforminteracions.h
Normal file
34
retroshare-qml-app/src/androidplatforminteracions.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
/*
|
||||
* RetroShare Android QML App
|
||||
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include "platforminteracions.h"
|
||||
|
||||
class AndroidPlatformInteracions : public PlatformInteracions
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AndroidPlatformInteracions(QObject *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
virtual void shareUrl(QUrl url);
|
||||
};
|
25
retroshare-qml-app/src/defaultplatforminteracions.cpp
Normal file
25
retroshare-qml-app/src/defaultplatforminteracions.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* RetroShare Android QML App
|
||||
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "defaultplatforminteracions.h"
|
||||
|
||||
DefaultPlatformInteracions::DefaultPlatformInteracions(QObject *parent) :
|
||||
PlatformInteracions(parent) {}
|
||||
|
||||
// Do nothing as the url is pasted to clipboard directly in QML
|
||||
void DefaultPlatformInteracions::shareUrl(QUrl /*url*/) {}
|
34
retroshare-qml-app/src/defaultplatforminteracions.h
Normal file
34
retroshare-qml-app/src/defaultplatforminteracions.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
/*
|
||||
* RetroShare Android QML App
|
||||
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include "platforminteracions.h"
|
||||
|
||||
class DefaultPlatformInteracions : public PlatformInteracions
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DefaultPlatformInteracions(QObject *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
virtual void shareUrl(QUrl url);
|
||||
};
|
@ -30,10 +30,16 @@
|
||||
# include <QtAndroid>
|
||||
# include <QtAndroidExtras/QAndroidJniObject>
|
||||
# include <atomic>
|
||||
# include "androidplatforminteracions.h"
|
||||
#else
|
||||
# include "defaultplatforminteracions.h"
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
|
||||
#include "libresapilocalclient.h"
|
||||
#include "rsqmlappengine.h"
|
||||
#include "platforminteracions.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -60,6 +66,8 @@ int main(int argc, char *argv[])
|
||||
#ifdef Q_OS_ANDROID
|
||||
rootContext.setContextProperty("Q_OS_ANDROID", QVariant(true));
|
||||
|
||||
AndroidPlatformInteracions platformGW(&app);
|
||||
|
||||
/* Add Activity Intent data to args, because onNewIntent is called only if
|
||||
* the Intet was triggered when the Activity was already created, so only in
|
||||
* case onCreate is not called.
|
||||
@ -114,10 +122,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(!uriStr.isEmpty()) mainArgs.append(uriStr);
|
||||
#else
|
||||
DefaultPlatformInteracions platformGW(&app);
|
||||
rootContext.setContextProperty("Q_OS_ANDROID", QVariant(false));
|
||||
#endif
|
||||
|
||||
rootContext.setContextProperty("mainArgs", mainArgs);
|
||||
rootContext.setContextProperty("platformGW", &platformGW);
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
rootContext.setContextProperty("QT_DEBUG", QVariant(true));
|
||||
|
32
retroshare-qml-app/src/platforminteracions.h
Normal file
32
retroshare-qml-app/src/platforminteracions.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
/*
|
||||
* RetroShare Android QML App
|
||||
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
class PlatformInteracions : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlatformInteracions(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
public slots:
|
||||
virtual void shareUrl(QUrl url) = 0;
|
||||
};
|
@ -5,17 +5,24 @@ QT += core network qml quick
|
||||
CONFIG += c++11
|
||||
|
||||
HEADERS += libresapilocalclient.h \
|
||||
rsqmlappengine.h
|
||||
rsqmlappengine.h \
|
||||
platforminteracions.h
|
||||
SOURCES += main-app.cpp \
|
||||
libresapilocalclient.cpp \
|
||||
rsqmlappengine.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
|
||||
# Platform interaction specific code
|
||||
|
||||
android-g++ {
|
||||
QT += androidextras
|
||||
SOURCES += NativeCalls.cpp
|
||||
HEADERS += NativeCalls.h
|
||||
HEADERS += NativeCalls.h androidplatforminteracions.h
|
||||
SOURCES += NativeCalls.cpp androidplatforminteracions.cpp
|
||||
} else {
|
||||
HEADERS += defaultplatforminteracions.h
|
||||
SOURCES += defaultplatforminteracions.cpp
|
||||
}
|
||||
|
||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
|
Loading…
Reference in New Issue
Block a user