mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Create logic for call android native image picker
This commit is contained in:
parent
59b77da6a2
commit
2cb6742dbc
@ -27,6 +27,15 @@ Item
|
|||||||
property var md
|
property var md
|
||||||
property bool is_contact: cntDt.md.is_contact
|
property bool is_contact: cntDt.md.is_contact
|
||||||
|
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
text: "Open f d "
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
androidImagePicker.openPicker()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColorHash
|
ColorHash
|
||||||
{
|
{
|
||||||
id: colorHash
|
id: colorHash
|
||||||
|
@ -83,6 +83,18 @@
|
|||||||
<!-- extract android style -->
|
<!-- extract android style -->
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
|
||||||
|
android:name="org.retroshare.android.qml_app.RetroshareImagePicker"
|
||||||
|
android:label="QtAndroidImagePicker"
|
||||||
|
android:screenOrientation="unspecified"
|
||||||
|
android:launchMode="singleTop">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
<receiver android:name=".BootCompletedReceiver" android:enabled="true">
|
<receiver android:name=".BootCompletedReceiver" android:enabled="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
@ -206,4 +218,6 @@
|
|||||||
|
|
||||||
<!-- Added by G10h4ck: Needed permission for autostart at boot -->
|
<!-- Added by G10h4ck: Needed permission for autostart at boot -->
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
|
<!-- Added by Angesoc: used to pick images from gallery or take it from camera -->
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
28
retroshare-qml-app/src/androidimagepicker.h
Normal file
28
retroshare-qml-app/src/androidimagepicker.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
# include <QtAndroid>
|
||||||
|
# include <QtAndroidExtras/QAndroidJniObject>
|
||||||
|
#endif // __ANDROID__
|
||||||
|
|
||||||
|
struct AndroidImagePicker : QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
static void openPicker()
|
||||||
|
{
|
||||||
|
qDebug() << "Starting image picker intent";
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
QAndroidJniObject::callStaticMethod<void>(
|
||||||
|
"org/retroshare/android/qml_app/RetroshareImagePicker",
|
||||||
|
"imagePickerIntent",
|
||||||
|
"()Landroid/content/Intent;" );
|
||||||
|
#endif // __ANDROID__
|
||||||
|
}
|
||||||
|
};
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#include "libresapilocalclient.h"
|
#include "libresapilocalclient.h"
|
||||||
#include "rsqmlappengine.h"
|
#include "rsqmlappengine.h"
|
||||||
|
#include "androidimagepicker.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -46,6 +48,7 @@ int main(int argc, char *argv[])
|
|||||||
"org.retroshare.qml_components.LibresapiLocalClient", 1, 0,
|
"org.retroshare.qml_components.LibresapiLocalClient", 1, 0,
|
||||||
"LibresapiLocalClient");
|
"LibresapiLocalClient");
|
||||||
|
|
||||||
|
|
||||||
QString sockPath = QDir::homePath() + "/.retroshare";
|
QString sockPath = QDir::homePath() + "/.retroshare";
|
||||||
sockPath.append("/libresapi.sock");
|
sockPath.append("/libresapi.sock");
|
||||||
|
|
||||||
@ -55,6 +58,14 @@ int main(int argc, char *argv[])
|
|||||||
RsQmlAppEngine engine(true);
|
RsQmlAppEngine engine(true);
|
||||||
QQmlContext& rootContext = *engine.rootContext();
|
QQmlContext& rootContext = *engine.rootContext();
|
||||||
|
|
||||||
|
qmlRegisterType<AndroidImagePicker>(
|
||||||
|
"org.retroshare.qml_components.AndroidImagePicker", 1, 0,
|
||||||
|
"AndroidImagePicker");
|
||||||
|
|
||||||
|
AndroidImagePicker androidImagePicker;
|
||||||
|
engine.rootContext()->setContextProperty("androidImagePicker",
|
||||||
|
&androidImagePicker);
|
||||||
|
|
||||||
QStringList mainArgs = app.arguments();
|
QStringList mainArgs = app.arguments();
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
|
@ -5,7 +5,8 @@ QT += core network qml quick
|
|||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
HEADERS += libresapilocalclient.h \
|
HEADERS += libresapilocalclient.h \
|
||||||
rsqmlappengine.h
|
rsqmlappengine.h \
|
||||||
|
androidimagepicker.h
|
||||||
SOURCES += main-app.cpp \
|
SOURCES += main-app.cpp \
|
||||||
libresapilocalclient.cpp \
|
libresapilocalclient.cpp \
|
||||||
rsqmlappengine.cpp
|
rsqmlappengine.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user