Skip to content

Commit

Permalink
Merge pull request #2 from paulondcdev/NativeFileDialogImprovements
Browse files Browse the repository at this point in the history
Native file dialog improvements
  • Loading branch information
paulondc authored Aug 30, 2016
2 parents b9a5231 + 4893d35 commit 2a58175
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion qpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions source/cpp/nativefiledialogandroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<jint>("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<jobject>(), true);
}
Expand Down Expand Up @@ -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<jstring>());

QAndroidJniObject contentResolver = QtAndroid::androidActivity().callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");

Expand Down
14 changes: 5 additions & 9 deletions source/cpp/nativefiledialogext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeFileDialogExt>("QuickNative", 0, 1, "NativeFileDialog");
}
};
static void registerNativeFileDialogExt() {
// overriding the qml version when this component is avaiable
qmlRegisterType<NativeFileDialogExt>("QuickNative", 0, 1, "NativeFileDialog");
}

static const NativeFileDialogExtTypeRegisterHelper typeRegisterHelper;
Q_COREAPP_STARTUP_FUNCTION(registerNativeFileDialogExt)

0 comments on commit 2a58175

Please sign in to comment.