-
Notifications
You must be signed in to change notification settings - Fork 62
/
androidutils.h
95 lines (72 loc) · 2.77 KB
/
androidutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ANDROIDUTILS_H
#define ANDROIDUTILS_H
#include "inputconfig.h"
#ifdef ANDROID
#include <QtCore/private/qandroidextras_p.h>
#include <QJniObject>
#include <QBluetoothLocalDevice>
#endif
#include <QObject>
class AndroidUtils: public QObject
#ifdef ANDROID
, QAndroidActivityResultReceiver
#endif
{
Q_OBJECT
Q_PROPERTY( bool isAndroid READ isAndroid CONSTANT )
public:
explicit AndroidUtils( QObject *parent = nullptr );
bool isAndroid() const;
bool checkAndAcquirePermissions( const QString &permissionString );
static QString externalStorageAppFolder();
/**
* Reads EXIF and returns value for given parameters.
* @param filePath Absolute path to a file
* @param tag EXIF string tag
* @return String value of EXIF attribute for given parameters. Note that rational numbers are still in rational string format.
*/
static QString readExif( const QString &filePath, const QString &tag );
bool requestStoragePermission();
bool requestCameraPermission();
bool requestMediaLocationPermission();
void turnBluetoothOn();
bool isBluetoothTurnedOn();
static void quitApp();
/**
* Starts ACTION_PICK activity which opens a gallery. If an image is selected,
* handler of the activity emits imageSelected signal.
* */
Q_INVOKABLE void callImagePicker();
Q_INVOKABLE void callCamera( const QString &targetPath );
Q_INVOKABLE void installQRCodeScanner();
Q_INVOKABLE void scanQRCode();
#ifdef ANDROID
const static int MEDIA_CODE = 101;
const static int CAMERA_CODE = 102;
const static int BLUETOOTH_CODE = 103;
const static int INSTALL_QR_SCANNER_CODE = 104;
const static int QR_SCAN_CODE = 105;
void handleActivityResult( int receiverRequestCode, int resultCode, const QJniObject &data ) override;
#endif
signals:
void imageSelected( QString imagePath );
void bluetoothEnabled( bool state );
void qrScanFinished( QString scanValue );
void qrScanAborted();
void qrScannerMissing();
public slots:
void showToast( QString message );
private:
#ifdef ANDROID
QBluetoothLocalDevice mBluetooth;
#endif
};
#endif // ANDROIDUTILS_H