Merge v0.6.0 and v0.6.1 #29

Merged
dorian merged 30 commits from version/0.5.1 into master 2024-10-17 17:52:37 +02:00
11 changed files with 101 additions and 27 deletions
Showing only changes of commit 275fff2d22 - Show all commits

View file

@ -69,17 +69,14 @@
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
<!-- Handle shared incoming urls -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="*/*"/>
</intent-filter>
<intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="*/*"/>
<data android:scheme="file"/>
<data android:scheme="content"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!-- Accepts URIs that begin with "https://l.bluerock.dev/” -->
<data android:scheme="https" android:host="l.bluerock.dev" android:pathPattern=".*"/>
<!-- Accepts URIs that begin with "https://app.bluerock.dev” -->
<data android:scheme="https" android:host="app.bluerock.dev" android:pathPattern=".*"/>
</intent-filter>
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
@ -89,5 +86,5 @@
</application>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>

View file

@ -39,6 +39,8 @@ public class MainActivity extends QtActivity
// native - must be implemented in Cpp via JNI
// 'file' scheme or resolved from 'content' scheme:
public static native void setFileUrlReceived(String url);
//
public static native void setOtherUrlReceived(String url, String scheme);
// InputStream from 'content' scheme:
public static native void setFileReceivedAndSaved(String url);
//
@ -178,6 +180,7 @@ public class MainActivity extends QtActivity
}
if(!intentScheme.equals("content")){
Log.d("ekkescorner Intent URI unknown scheme: ", intentScheme);
setOtherUrlReceived(intentUri.toString(), intentScheme);
return;
}
// ok - it's a content scheme URI

View file

@ -48,8 +48,9 @@ private:
ShareUtils* _shareUtils;
const QStringList _validBaseDomains = {"digitalrock.de", "bluerock.dev"};
bool _pendingIntentsChecked;
signals:
Q_INVOKABLE void openedViaUrl(QString url, QString scheme);
public slots:
@ -57,6 +58,9 @@ public slots:
QVariantMap getParamsFromUrl(QString url);
void shareResultsAsUrl(QString url, QString compName);
void shareResultsAsPoster(QString url, QString compName);
#if defined(Q_OS_ANDROID)
void onApplicationStateChanged(Qt::ApplicationState applicationState);
#endif
};

View file

@ -31,6 +31,7 @@ public:
public slots:
void setFileUrlReceived(const QString &url);
void setOtherUrlReceived(const QString &url, const QString &scheme);
void setFileReceivedAndSaved(const QString &url);
bool checkFileExits(const QString &url);

View file

@ -31,6 +31,7 @@ signals:
void shareNoAppAvailable(int requestCode);
void shareError(int requestCode, QString message);
void fileUrlReceived(QString url);
void otherUrlReceived(QString url, QString scheme);
void fileReceivedAndSaved(QString url);
public:

View file

@ -32,6 +32,7 @@ signals:
void shareNoAppAvailable(int requestCode);
void shareError(int requestCode, QString message);
void fileUrlReceived(QString url);
void otherUrlReceived(QString url, QString scheme);
void fileReceivedAndSaved(QString url);
public slots:
@ -40,6 +41,7 @@ public slots:
void onShareNoAppAvailable(int requestCode);
void onShareError(int requestCode, QString message);
void onFileUrlReceived(QString url);
void onOtherUrlReceived(QString url, QString scheme);
void onFileReceivedAndSaved(QString url);
public:

View file

@ -110,10 +110,17 @@ DataListView {
initFilters()
initFavorites()
if(model){
console.log(JSON.stringify(widgetData))
if(model && widgetData["competitions"].length > 0){
control.status = 200
control.ready = true
}
else if(widgetData["competitions"].length === 0) {
control.status = 404
control.ready = false
}
else {
control.ready = false
control.status = 901

View file

@ -134,7 +134,7 @@ Window {
//app.openAthlete() // dorian: 53139 , rustam: 6933 , helen: 53300
//openWidget({nation:'GER'})
//mainStack.push("Pages/AthleteSearchPage.qml")
openWidget({comp: 11651, cat: 26})
//openWidget({comp: 11651, cat: 26})
//openWidget({person: 6623})
//console.log(JSON.stringify(serverConn.getParamsFromUrl("")))
}
@ -157,6 +157,10 @@ Window {
BlueRockBackend {
id: serverConn
onOpenedViaUrl: {
app.openWidgetFromUrl(url)
}
}
AppSettings {

View file

@ -18,26 +18,28 @@
#include "headers/bluerockbackend.h"
BlueRockBackend::BlueRockBackend(QObject *parent) : QObject(parent)
BlueRockBackend::BlueRockBackend(QObject *parent) : QObject(parent), _pendingIntentsChecked(false)
{
this->_shareUtils = new ShareUtils(this);
connect(this->_shareUtils, &ShareUtils::otherUrlReceived, this, &BlueRockBackend::openedViaUrl);
#if defined(Q_OS_ANDROID)
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
#endif
}
QVariant BlueRockBackend::getWidgetData(QVariantMap params) {
QString requestUrl;
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?";
QStringList nations = {"ICC", "GER", "SUI"};
if(params["nation"].toString() == "ICC") {
requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?";
params["nation"] = "";
}
else if (params["nation"].toString() == "GER") {
requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?";
}
else if (params["nation"].toString() == "SUI") {
requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?";
}
else {
else if(params["nation"].toString() == "") {
params.remove("nation");
requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?";
}
else if(!nations.contains(params["nation"].toString())) {
// a non-empty nation which ist not one of the above is invalid
return QVariantMap({{"status", 404}});
}
for(QVariantMap::const_iterator iter = params.begin(); iter != params.end(); ++iter) {
@ -203,9 +205,27 @@ QVariantMap BlueRockBackend::_senddata(QUrl serviceUrl, QUrlQuery pdata)
return(ret);
}
#if defined(Q_OS_ANDROID)
void BlueRockBackend::onApplicationStateChanged(Qt::ApplicationState applicationState)
{
qDebug() << "S T A T E changed into: " << applicationState;
if(applicationState == Qt::ApplicationState::ApplicationSuspended) {
// nothing to do
return;
}
if(applicationState == Qt::ApplicationState::ApplicationActive) {
// if App was launched from VIEW or SEND Intent
// there's a race collision: the event will be lost,
// because App and UI wasn't completely initialized
// workaround: QShareActivity remembers that an Intent is pending
if(!_pendingIntentsChecked) {
_pendingIntentsChecked = true;
_shareUtils->checkPendingIntents(this->_shareUtils->getTemporaryFileLocationPath());
}
}
}
#endif
// -------------------------
// --- Functions for QML ---
// -------------------------

View file

@ -236,6 +236,18 @@ void AndroidShareUtils::setFileUrlReceived(const QString &url)
}
}
void AndroidShareUtils::setOtherUrlReceived(const QString &url, const QString &scheme)
{
if(url.isEmpty()) {
qWarning() << "setFileUrlReceived: we got an empty URL";
emit shareError(0, tr("Empty URL received"));
return;
}
qDebug() << "AndroidShareUtils setOtherUrlReceived: we got the Other URL from JAVA: " << url;
emit otherUrlReceived(url, scheme);
}
void AndroidShareUtils::setFileReceivedAndSaved(const QString &url)
{
if(url.isEmpty()) {
@ -311,6 +323,21 @@ Java_de_itsblue_blueROCK_MainActivity_setFileUrlReceived(JNIEnv *env,
return;
}
JNIEXPORT void JNICALL
Java_de_itsblue_blueROCK_MainActivity_setOtherUrlReceived(JNIEnv *env,
jobject obj,
jstring url,
jstring scheme)
{
const char *urlStr = env->GetStringUTFChars(url, NULL);
const char *schemeStr = env->GetStringUTFChars(scheme, NULL);
Q_UNUSED (obj)
AndroidShareUtils::getInstance()->setOtherUrlReceived(urlStr, schemeStr);
env->ReleaseStringUTFChars(url, urlStr);
env->ReleaseStringUTFChars(scheme, schemeStr);
return;
}
JNIEXPORT void JNICALL
Java_de_itsblue_blueROCK_MainActivity_setFileReceivedAndSaved(JNIEnv *env,
jobject obj,

View file

@ -38,6 +38,9 @@ ShareUtils::ShareUtils(QObject *parent)
connectResult = connect(mPlatformShareUtils, &PlatformShareUtils::fileUrlReceived, this, &ShareUtils::onFileUrlReceived);
Q_ASSERT(connectResult);
connectResult = connect(mPlatformShareUtils, &PlatformShareUtils::otherUrlReceived, this, &ShareUtils::onOtherUrlReceived);
Q_ASSERT(connectResult);
connectResult = connect(mPlatformShareUtils, &PlatformShareUtils::fileReceivedAndSaved, this, &ShareUtils::onFileReceivedAndSaved);
Q_ASSERT(connectResult);
@ -109,6 +112,11 @@ void ShareUtils::onFileUrlReceived(QString url)
emit fileUrlReceived(url);
}
void ShareUtils::onOtherUrlReceived(QString url, QString scheme)
{
emit otherUrlReceived(url, scheme);
}
void ShareUtils::onFileReceivedAndSaved(QString url)
{
emit fileReceivedAndSaved(url);