Skip to content

Commit

Permalink
Merge branch '385-fix-start-camera-in-qr-code-scanning-view-5-9-4' in…
Browse files Browse the repository at this point in the history
…to 'development'

Resolve "Fix start camera in QR-code scanning view 5.9.4"

Closes #385

See merge request qt-team/graft-mobile-client!368
  • Loading branch information
vitalius-parubochyi-vakoms committed Sep 5, 2018
2 parents 4564c4f + ebc1f9d commit bdb55f0
Show file tree
Hide file tree
Showing 19 changed files with 408 additions and 99 deletions.
9 changes: 6 additions & 3 deletions GraftMobileClient/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

static const QString scUrl("%1/dapi");

namespace MainnetConfiguration {
namespace MainnetConfiguration
{
static const QString scConfigTitle("Mainnet");

static const QStringList scHttpSeedSupernodes{"mainnet-seed.graft.network:18900"
Expand All @@ -19,7 +20,8 @@ static const QStringList scHttpsSeedSupernodes{"mainnet-seed.graft.network:18943
static const QString scDAPIVersion("1.0G");
}

namespace TestnetConfiguration {
namespace TestnetConfiguration
{
static const QString scConfigTitle("Public Testnet");

static const QStringList scHttpSeedSupernodes{"testnet-pub-seed.graft.network:28900"
Expand All @@ -33,7 +35,8 @@ static const QStringList scHttpsSeedSupernodes{"testnet-pub-seed.graft.network:2
static const QString scDAPIVersion("1.0F");
}

namespace ExperimentalTestnetConfiguration {
namespace ExperimentalTestnetConfiguration
{
static const QString scConfigTitle("Public RTA Testnet");

static const QStringList scHttpSeedSupernodes{"testnet-rta-seed.graft.network:28900"
Expand Down
8 changes: 8 additions & 0 deletions GraftMobileClient/ios/ios.pri
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ contains(DEFINES, WALLET_BUILD) {

DISTFILES += \
$$PWD/wallet/Info.plist

HEADERS += \
$$PWD/wallet/permissiondelegate.h \
$$PWD/wallet/ioscamerapermission.h

SOURCES += \
$$PWD/wallet/permissiondelegate.mm \
$$PWD/wallet/ioscamerapermission.cpp
}

35 changes: 35 additions & 0 deletions GraftMobileClient/ios/wallet/ioscamerapermission.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "ioscamerapermission.h"
#include "permissiondelegate.h"

#include <QTimerEvent>

IOSCameraPermission::IOSCameraPermission(QObject *parent)
: QObject(parent)
,mTimer(-1)
{
}

bool IOSCameraPermission::hasPermission()
{
if (!PermissionDelegate::isCameraAuthorised())
{
mTimer = startTimer(50);
return false;
}
return true;
}

void IOSCameraPermission::stopTimer()
{
killTimer(mTimer);
}

void IOSCameraPermission::timerEvent(QTimerEvent *event)
{
if ((event->timerId() == mTimer) && PermissionDelegate::isCameraAuthorised())
{
emit hasCameraPermission(true);
stopTimer();
}
}

25 changes: 25 additions & 0 deletions GraftMobileClient/ios/wallet/ioscamerapermission.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef IOSCAMERAPERMISSION_H
#define IOSCAMERAPERMISSION_H

#include <QObject>

class IOSCameraPermission : public QObject
{
Q_OBJECT
public:
explicit IOSCameraPermission(QObject *parent = nullptr);

Q_INVOKABLE bool hasPermission();
Q_INVOKABLE void stopTimer();

signals:
void hasCameraPermission(bool result);

protected:
void timerEvent(QTimerEvent *event) override;

private:
int mTimer;
};

#endif // IOSCAMERAPERMISSION_H
9 changes: 9 additions & 0 deletions GraftMobileClient/ios/wallet/permissiondelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef PERMISSIONDELEGATE_H
#define PERMISSIONDELEGATE_H

class PermissionDelegate
{
public:
static bool isCameraAuthorised();
};
#endif // PERMISSIONDELEGATE_H
10 changes: 10 additions & 0 deletions GraftMobileClient/ios/wallet/permissiondelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "permissiondelegate.h"

#include <AVFoundation/AVFoundation.h>
#include <UIKit/UIKit.h>

bool PermissionDelegate::isCameraAuthorised()
{
NSString *mediaType = AVMediaTypeVideo;
return [AVCaptureDevice authorizationStatusForMediaType:mediaType] == AVAuthorizationStatusAuthorized;
}
12 changes: 12 additions & 0 deletions GraftMobileClient/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ static_assert(false, "QTBUG-65820 in Android Debug builds");
#include <QtAndroid>
#endif

#ifdef WALLET_BUILD
#if defined(Q_OS_IOS)
#include "ios/wallet/ioscamerapermission.h"
#endif
#endif

#ifdef POS_BUILD
#if defined(Q_OS_ANDROID) || defined (Q_OS_IOS)
#include "imagepicker.h"
Expand Down Expand Up @@ -109,6 +115,12 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("PaymentProductModel"),
client.paymentProductModel());
engine.rootContext()->setContextProperty(QStringLiteral("GraftClient"), &client);

#if defined(Q_OS_IOS)
IOSCameraPermission cameraPermission;
engine.rootContext()->setContextProperty(QStringLiteral("IOSCameraPermission"), &cameraPermission);
#endif

engine.load(QUrl(QLatin1String("qrc:/wallet/main.qml")));
#endif
if (engine.rootObjects().isEmpty())
Expand Down
1 change: 0 additions & 1 deletion GraftMobileClient/resources/LicenseAgreementScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ BaseScreen {
"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.")
}
}

}

WideActionButton {
Expand Down
91 changes: 0 additions & 91 deletions GraftMobileClient/resources/QRScanningView.qml

This file was deleted.

2 changes: 1 addition & 1 deletion GraftMobileClient/resources/SelectImageButton.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls.Material 2.2
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3

Button {
Expand Down
2 changes: 1 addition & 1 deletion GraftMobileClient/resources/SelectImageDialog.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls.Material 2.2
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3

Popup {
Expand Down
3 changes: 3 additions & 0 deletions GraftMobileClient/resources/SendCoinScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import QtQuick.Controls 2.2
import com.device.platform 1.0
import org.graft 1.0
import "components"
import "wallet"

BaseScreen {
id: sendCoinScreen
Expand Down Expand Up @@ -126,6 +127,7 @@ BaseScreen {
}

QRScanningView {
id: qRScanningView
onQrCodeDetected: {
receiversAddress.text = message
changeBehaviorButton()
Expand All @@ -141,6 +143,7 @@ BaseScreen {

function changeBehaviorButton() {
stackLayout.currentIndex = 0
qRScanningView.stopScanningView()
}

function checkingData() {
Expand Down
Loading

0 comments on commit bdb55f0

Please sign in to comment.