diff --git a/android/androidfiledialog.cpp b/android/androidfiledialog.cpp index bb0b7e3e92b556e0fae24c071f1dd1e95ff09f24..e77b5c0b9525e5d4e196f3c289a90104d205873f 100755 --- a/android/androidfiledialog.cpp +++ b/android/androidfiledialog.cpp @@ -67,9 +67,18 @@ bool AndroidFileDialog::provideExistingFileName() QAndroidJniObject ACTION_GET_CONTENT = QAndroidJniObject::fromString( "android.intent.action.GET_CONTENT" ); QAndroidJniObject intent( "android/content/Intent" ); + QAndroidJniEnvironment env; + jobjectArray stringArray = env->NewObjectArray( 3, env->FindClass( "java/lang/String" ), NULL ); + env->SetObjectArrayElement( stringArray, 0, QAndroidJniObject::fromString( QStringLiteral( "file/*" ) ).object<jstring>() ); + env->SetObjectArrayElement( stringArray, 1, QAndroidJniObject::fromString( QStringLiteral( "image/*" ) ).object<jstring>() ); + env->SetObjectArrayElement( stringArray, 2, QAndroidJniObject::fromString( QStringLiteral( "video/*" ) ).object<jstring>() ); + QAndroidJniObject jniArray = QAndroidJniObject::fromLocalRef( stringArray ); + QAndroidJniObject EXTRA_MIME_TYPES = QAndroidJniObject::getStaticObjectField<jstring>( "android/content/Intent", "EXTRA_MIME_TYPES" ); + if ( ACTION_GET_CONTENT.isValid() && intent.isValid() ) { intent.callObjectMethod( "setAction", "(Ljava/lang/String;)Landroid/content/Intent;", ACTION_GET_CONTENT.object<jstring>() ); - intent.callObjectMethod( "setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString( "file/*" ).object<jstring>() ); + intent.callObjectMethod( "setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString( "*/*" ).object<jstring>() ); + intent.callObjectMethod( "putExtra", "(Ljava/lang/String;[Ljava/lang/String;)Landroid/content/Intent;", EXTRA_MIME_TYPES.object<jstring>(), jniArray.object<jobjectArray>() ); QtAndroid::startActivity( intent.object<jobject>(), EXISTING_FILE_NAME_REQUEST, receiver ); return true; } else { diff --git a/android/androidfiledialog.h b/android/androidfiledialog.h index bd96e5304d8502e13b4728f8816f9b064fc4359c..63f67a64cd1668c330cd7b54818d8b2f30605c2e 100755 --- a/android/androidfiledialog.h +++ b/android/androidfiledialog.h @@ -25,6 +25,8 @@ #include <QAndroidJniObject> #include <QtAndroid> #include <QAndroidActivityResultReceiver> +#include <QAndroidJniEnvironment> + class AndroidFileDialog : public QObject { Q_OBJECT public: diff --git a/api/meteorddp.cpp b/api/meteorddp.cpp index 8a130954e574cb0a089615830a7640ae9bc6d3b6..f44decb8826c72033a351528c5fe4713fb09384a 100755 --- a/api/meteorddp.cpp +++ b/api/meteorddp.cpp @@ -77,7 +77,7 @@ void MeteorDDP::connectWithServer() void MeteorDDP::onTextMessageReceived( const QString &pMsg ) { #if defined(Q_OS_LINUX)|| defined(Q_OS_IOS) - qWarning() << pMsg << "\n"; + qDebug() << pMsg << "\n"; #endif if ( Q_LIKELY( pMsg.length() ) ) { @@ -168,7 +168,7 @@ void MeteorDDP::sendJson( const QJsonObject &pMsgObj ) QJsonDocument msgJson = QJsonDocument( pMsgObj ); QString msgString = msgJson.toJson( QJsonDocument::Compact ); - qWarning() << "message String" << msgString; + qDebug() << "message String" << msgString; mWsClient->sendTextMessage( msgString ); } diff --git a/rocketchat.cpp b/rocketchat.cpp index 4e715570e688af290114ca00d9011d89ef2122fb..11b85d59ff7e108c7561955095d93d1e2d8c205b 100755 --- a/rocketchat.cpp +++ b/rocketchat.cpp @@ -750,19 +750,21 @@ void RocketChat::storageReadySlot() emit storageReady(); } #ifdef Q_OS_ANDROID +//TODO: do this in a clean way void RocketChat::openAndroidFileDialog( QString channelId ) { currentChannel = channelId; - AndroidFileDialog *fileDialog = new AndroidFileDialog(); - connect( fileDialog, &AndroidFileDialog::existingFileNameReady, this, &RocketChat::openFileNameReady, Qt::UniqueConnection ); + QSharedPointer<AndroidFileDialog> fileDialog( new AndroidFileDialog() ); + connect( fileDialog.data(), &AndroidFileDialog::existingFileNameReady, this, &RocketChat::openFileNameReady, Qt::UniqueConnection ); bool success = fileDialog->provideExistingFileName(); if ( !success ) { qWarning() << "Problem with JNI or sth like that..."; - disconnect( fileDialog, &AndroidFileDialog::existingFileNameReady, this, &RocketChat::openFileNameReady ); + disconnect( fileDialog.data(), &AndroidFileDialog::existingFileNameReady, this, &RocketChat::openFileNameReady ); //or just delete fileDialog instead of disconnect } } + #endif #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) diff --git a/rocketchat.h b/rocketchat.h index 9edefa30fda02a69bd506f81e1bf45522b4cb5c1..42ddb59586547b518c41936ee31b137bbd5c6275 100755 --- a/rocketchat.h +++ b/rocketchat.h @@ -35,7 +35,6 @@ #ifdef Q_OS_ANDROID #include "android/androidfiledialog.h" #include "android/androidstatusbarcolor.h" - #endif