diff --git a/retroshare-qml-app/src/ContactDetails.qml b/retroshare-qml-app/src/ContactDetails.qml index 7b7cfedf8..f3d3b6697 100644 --- a/retroshare-qml-app/src/ContactDetails.qml +++ b/retroshare-qml-app/src/ContactDetails.qml @@ -27,6 +27,15 @@ Item property var md property bool is_contact: cntDt.md.is_contact + Button + { + text: "Open f d " + onClicked: + { + androidImagePicker.openPicker() + } + } + ColorHash { id: colorHash diff --git a/retroshare-qml-app/src/android/AndroidManifest.xml b/retroshare-qml-app/src/android/AndroidManifest.xml index f7bb601cb..7f7913dd2 100644 --- a/retroshare-qml-app/src/android/AndroidManifest.xml +++ b/retroshare-qml-app/src/android/AndroidManifest.xml @@ -83,6 +83,18 @@ + + + + + + + + @@ -206,4 +218,6 @@ + + diff --git a/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroshareImagePicker.java b/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroshareImagePicker.java new file mode 100644 index 000000000..c2a2c5739 --- /dev/null +++ b/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroshareImagePicker.java @@ -0,0 +1,23 @@ +package org.retroshare.android.qml_app; + +/** + * Created by Angesoc on 10/07/17. + */ + +import org.qtproject.qt5.android.bindings.QtActivity; +import android.content.Intent; +import android.provider.MediaStore; +import android.util.Log; + + +public class RetroshareImagePicker extends QtActivity{ + + public static Intent imagePickerIntent() { + + Log.i("RetroshareImagePicker", "imagePickerIntent()"); + + Intent intent = new Intent( Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI ); + intent.setType("image/*"); + return Intent.createChooser(intent, "Select Image"); + } +} diff --git a/retroshare-qml-app/src/androidimagepicker.h b/retroshare-qml-app/src/androidimagepicker.h new file mode 100644 index 000000000..d30026701 --- /dev/null +++ b/retroshare-qml-app/src/androidimagepicker.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +#ifdef __ANDROID__ +# include +# include +#endif // __ANDROID__ + +struct AndroidImagePicker : QObject +{ + Q_OBJECT + +public slots: + + static void openPicker() + { + qDebug() << "Starting image picker intent"; + + #ifdef __ANDROID__ + QAndroidJniObject::callStaticMethod( + "org/retroshare/android/qml_app/RetroshareImagePicker", + "imagePickerIntent", + "()Landroid/content/Intent;" ); + #endif // __ANDROID__ + } +}; diff --git a/retroshare-qml-app/src/main-app.cpp b/retroshare-qml-app/src/main-app.cpp index 52dd19962..6c66961b1 100644 --- a/retroshare-qml-app/src/main-app.cpp +++ b/retroshare-qml-app/src/main-app.cpp @@ -34,6 +34,8 @@ #include "libresapilocalclient.h" #include "rsqmlappengine.h" +#include "androidimagepicker.h" + int main(int argc, char *argv[]) { @@ -46,6 +48,7 @@ int main(int argc, char *argv[]) "org.retroshare.qml_components.LibresapiLocalClient", 1, 0, "LibresapiLocalClient"); + QString sockPath = QDir::homePath() + "/.retroshare"; sockPath.append("/libresapi.sock"); @@ -55,6 +58,14 @@ int main(int argc, char *argv[]) RsQmlAppEngine engine(true); QQmlContext& rootContext = *engine.rootContext(); + qmlRegisterType( + "org.retroshare.qml_components.AndroidImagePicker", 1, 0, + "AndroidImagePicker"); + + AndroidImagePicker androidImagePicker; + engine.rootContext()->setContextProperty("androidImagePicker", + &androidImagePicker); + QStringList mainArgs = app.arguments(); #ifdef Q_OS_ANDROID diff --git a/retroshare-qml-app/src/retroshare-qml-app.pro b/retroshare-qml-app/src/retroshare-qml-app.pro index 338935419..9aad93153 100644 --- a/retroshare-qml-app/src/retroshare-qml-app.pro +++ b/retroshare-qml-app/src/retroshare-qml-app.pro @@ -5,7 +5,8 @@ QT += core network qml quick CONFIG += c++11 HEADERS += libresapilocalclient.h \ - rsqmlappengine.h + rsqmlappengine.h \ + androidimagepicker.h SOURCES += main-app.cpp \ libresapilocalclient.cpp \ rsqmlappengine.cpp