From 1fb5cfa3fcf70bd7c11ca61b9949619b949eb50f Mon Sep 17 00:00:00 2001 From: Paulo Nogueira Date: Tue, 30 Aug 2016 09:23:31 -0700 Subject: [PATCH 1/3] Querying android version directly from Qt, replaced convoluted casting in mediaStore --- source/cpp/nativefiledialogandroid.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/cpp/nativefiledialogandroid.cpp b/source/cpp/nativefiledialogandroid.cpp index 3c65237..2670ad9 100644 --- a/source/cpp/nativefiledialogandroid.cpp +++ b/source/cpp/nativefiledialogandroid.cpp @@ -13,10 +13,8 @@ void NativeFileDialogAndroid::open(QUrl initialFolder=QUrl()) { QAndroidJniObject intent("android/content/Intent"); QString contentType; - // querying the buildVersion to make sure the multiple selection feature is available - int buildVersion = QAndroidJniObject::getStaticField("android/os/Build$VERSION", "SDK_INT"); - - if (m_selectMultiple && buildVersion >= 19) { + // querying the android version to make sure the multiple selection feature is available + if (m_selectMultiple && QtAndroid::androidSdkVersion() >= 19) { intent.callObjectMethod("putExtra","(Ljava/lang/String;Z)Landroid/content/Intent;", QAndroidJniObject::getStaticObjectField("android/content/Intent", "EXTRA_ALLOW_MULTIPLE", "Ljava/lang/String;").object(), true); } @@ -117,13 +115,14 @@ QString NativeFileDialogAndroid::filePath(QAndroidJniObject & uri) { // otherwise query the file path through content resolver else { + QAndroidJniEnvironment env; QAndroidJniObject mediaStore = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$MediaColumns", "DATA", "Ljava/lang/String;"); jobjectArray projection = (jobjectArray)env->NewObjectArray(1, env->FindClass("java/lang/String"), env->NewStringUTF("")); - env->SetObjectArrayElement(projection, 0, env->NewStringUTF(mediaStore.toString().toStdString().c_str())); + env->SetObjectArrayElement(projection, 0, mediaStore.object()); QAndroidJniObject contentResolver = QtAndroid::androidActivity().callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;"); From 0ee78c56d86bffa1b94a6303d074cbdce2aafbb9 Mon Sep 17 00:00:00 2001 From: Paulo Nogueira Date: Tue, 30 Aug 2016 09:24:23 -0700 Subject: [PATCH 2/3] improved component registration --- source/cpp/nativefiledialogext.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/cpp/nativefiledialogext.cpp b/source/cpp/nativefiledialogext.cpp index 6095b8f..ac0de58 100644 --- a/source/cpp/nativefiledialogext.cpp +++ b/source/cpp/nativefiledialogext.cpp @@ -120,13 +120,9 @@ NativeFileDialogExt* NativeFileDialogExt::qmlAttachedProperties(QObject * object return new NativeFileDialogExt(); } -struct NativeFileDialogExtTypeRegisterHelper { - - NativeFileDialogExtTypeRegisterHelper() { - - // overriding the qml version when this component is avaiable - qmlRegisterType("QuickNative", 0, 1, "NativeFileDialog"); - } -}; +static void registerNativeFileDialogExt() { + // overriding the qml version when this component is avaiable + qmlRegisterType("QuickNative", 0, 1, "NativeFileDialog"); +} -static const NativeFileDialogExtTypeRegisterHelper typeRegisterHelper; +Q_COREAPP_STARTUP_FUNCTION(registerNativeFileDialogExt) From 4893d3553a1054ada274ee45da95dbcc74db9e07 Mon Sep 17 00:00:00 2001 From: Paulo Nogueira Date: Tue, 30 Aug 2016 09:24:36 -0700 Subject: [PATCH 3/3] bumped minor version --- qpm.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qpm.json b/qpm.json index 8e7c117..0394e9e 100644 --- a/qpm.json +++ b/qpm.json @@ -10,7 +10,7 @@ "url": "https://github.com/paulondc/quicknative.git" }, "version": { - "label": "0.1.0" + "label": "0.2.0" }, "pri_filename": "quicknative.pri", "license": "MIT"