mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-15 08:39:08 -05:00
Merge remote-tracking branch 'retro/master' into qml_app_avatar_picker
This commit is contained in:
commit
0494dd7516
102 changed files with 4608 additions and 1861 deletions
|
|
@ -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);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
76
retroshare-qml-app/src/AvatarOrColorHash.qml
Normal file
76
retroshare-qml-app/src/AvatarOrColorHash.qml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.7
|
||||
|
||||
|
||||
Item
|
||||
{
|
||||
id: compRoot
|
||||
|
||||
property string gxs_id
|
||||
|
||||
height: 130
|
||||
width: height
|
||||
|
||||
|
||||
////////////// The following should be considered privates /////////////////////
|
||||
|
||||
property bool has_avatar: false
|
||||
property int avatarAttemptCnt: 0
|
||||
function getDetails()
|
||||
{
|
||||
++compRoot.avatarAttemptCnt
|
||||
rsApi.request(
|
||||
"/identity/get_identity_details",
|
||||
JSON.stringify({ gxs_id: compRoot.gxs_id }),
|
||||
function(par)
|
||||
{
|
||||
var jData = JSON.parse(par.response).data
|
||||
setDetails(jData)
|
||||
if(!compRoot.has_avatar &&
|
||||
compRoot.avatarAttemptCnt < 3) getDetails()
|
||||
})
|
||||
}
|
||||
function setDetails(data)
|
||||
{
|
||||
compRoot.has_avatar = data.avatar.length > 0
|
||||
if(compRoot.has_avatar)
|
||||
{
|
||||
contactAvatar.source =
|
||||
"data:image/png;base64," + data.avatar
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: if(visible && !has_avatar) getDetails()
|
||||
onVisibleChanged: if(visible && !has_avatar) getDetails()
|
||||
|
||||
Image
|
||||
{
|
||||
id: contactAvatar
|
||||
anchors.fill: parent
|
||||
visible: compRoot.has_avatar
|
||||
}
|
||||
|
||||
ColorHash
|
||||
{
|
||||
anchors.fill: parent
|
||||
visible: !compRoot.has_avatar
|
||||
hash: compRoot.gxs_id
|
||||
}
|
||||
}
|
||||
|
|
@ -58,21 +58,20 @@ Item
|
|||
|
||||
}
|
||||
|
||||
ColorHash
|
||||
AvatarOrColorHash
|
||||
{
|
||||
id: colorHash
|
||||
id: topFace
|
||||
|
||||
gxs_id: cntDt.md.gxs_id
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 6
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
height: 150
|
||||
hash: cntDt.md.gxs_id
|
||||
}
|
||||
|
||||
Column
|
||||
{
|
||||
anchors.top: colorHash.bottom
|
||||
anchors.top: topFace.bottom
|
||||
anchors.topMargin: 6
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
|
|
@ -84,6 +83,13 @@ Item
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 6
|
||||
|
||||
ColorHash
|
||||
{
|
||||
hash: cntDt.md.gxs_id
|
||||
height: parent.height - 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: cntDt.md.name
|
||||
|
|
@ -92,7 +98,6 @@ Item
|
|||
|
||||
Image
|
||||
{
|
||||
|
||||
source: cntDt.is_contact ?
|
||||
"qrc:/icons/rating.png" :
|
||||
"qrc:/icons/rating-unrated.png"
|
||||
|
|
@ -149,16 +154,18 @@ Item
|
|||
function(par)
|
||||
{
|
||||
var jD = JSON.parse(par.response).data
|
||||
ClipboardWrapper.postToClipBoard(
|
||||
var contactUrl = (
|
||||
"retroshare://" +
|
||||
"identity?gxsid=" +
|
||||
cntDt.md.gxs_id +
|
||||
"&name=" +
|
||||
UriJs.URI.encode(cntDt.md.name) +
|
||||
"&groupdata=" +
|
||||
UriJs.URI.encode(jD.radix))
|
||||
UriJs.URI.encode(jD.radix) )
|
||||
ClipboardWrapper.postToClipBoard(contactUrl)
|
||||
linkCopiedPopup.itemName = cntDt.md.name
|
||||
linkCopiedPopup.visible = true
|
||||
platformGW.shareUrl(contactUrl);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,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,12 +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 "androidimagepicker.h"
|
||||
|
||||
#include "platforminteracions.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -71,6 +75,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.
|
||||
|
|
@ -125,10 +131,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;
|
||||
};
|
||||
|
|
@ -30,5 +30,6 @@
|
|||
<file>icons/rating.png</file>
|
||||
<file>TimedPopup.qml</file>
|
||||
<file>components/CustomFileChooser.qml</file>
|
||||
<file>AvatarOrColorHash.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -6,17 +6,24 @@ CONFIG += c++11
|
|||
|
||||
HEADERS += libresapilocalclient.h \
|
||||
rsqmlappengine.h \
|
||||
androidimagepicker.h
|
||||
androidimagepicker.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…
Add table
Add a link
Reference in a new issue