diff --git a/examples/QZXingLive/QZXingLive.pro b/examples/QZXingLive/QZXingLive.pro index 3e1f790..77534b2 100644 --- a/examples/QZXingLive/QZXingLive.pro +++ b/examples/QZXingLive/QZXingLive.pro @@ -15,12 +15,10 @@ CONFIG(debug, debug|release) { } HEADERS += \ - application.h \ - native.h + application.h SOURCES += main.cpp \ - application.cpp \ - native.cpp + application.cpp RESOURCES += qml.qrc @@ -33,28 +31,35 @@ include(../../src/QZXing-components.pri) include(deployment.pri) android { - QT += androidextras + lessThan(QT_VERSION, 6.2) { + HEADERS += \ + native.h - DISTFILES += \ - android/AndroidManifest.xml \ - android/gradle/wrapper/gradle-wrapper.jar \ - android/gradlew \ - android/res/values/libs.xml \ - android/build.gradle \ - android/gradle/wrapper/gradle-wrapper.properties \ - android/gradlew.bat \ - android/AndroidManifest.xml \ - android/gradle/wrapper/gradle-wrapper.jar \ - android/gradlew \ - android/res/values/libs.xml \ - android/build.gradle \ - android/gradle/wrapper/gradle-wrapper.properties \ - android/gradlew.bat + SOURCES += \ + native.cpp - ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android + QT += androidextras + + DISTFILES += \ + android/AndroidManifest.xml \ + android/gradle/wrapper/gradle-wrapper.jar \ + android/gradlew \ + android/res/values/libs.xml \ + android/build.gradle \ + android/gradle/wrapper/gradle-wrapper.properties \ + android/gradlew.bat \ + android/AndroidManifest.xml \ + android/gradle/wrapper/gradle-wrapper.jar \ + android/gradlew \ + android/res/values/libs.xml \ + android/build.gradle \ + android/gradle/wrapper/gradle-wrapper.properties \ + android/gradlew.bat + + ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android + } } else:ios { QMAKE_INFO_PLIST=Info.plist } - diff --git a/examples/QZXingLive/application.cpp b/examples/QZXingLive/application.cpp index 3a5d9d9..899b520 100644 --- a/examples/QZXingLive/application.cpp +++ b/examples/QZXingLive/application.cpp @@ -1,10 +1,20 @@ #include "application.h" #include + +#if QT_VERSION < 0x060000 #include "native.h" +#endif + #if defined(Q_OS_ANDROID) + +#if QT_VERSION < 0x060100 #include #include +#else + #include +#endif + #endif // Q_OS_ANDROID Application::Application() @@ -18,7 +28,9 @@ Application::Application() connect(this, &Application::onPermissionsDenied, this, &Application::initializeQML); - NativeHelpers::registerApplicationInstance(this); +#if QT_VERSION < 0x060000 + NativeHelpers::registerApplicationInstance(this); +#endif } void Application::initializeQML() @@ -36,10 +48,14 @@ void Application::checkPermissions() //intentionally called in the C++ thread since it is blocking and will continue after the check qDebug() << "About to request permissions"; + #if QT_VERSION < 0x060000 QAndroidJniObject::callStaticMethod("org/ftylitak/qzxing/Utilities", "requestQZXingPermissions", "(Landroid/app/Activity;)V", QtAndroid::androidActivity().object()); + #else + emit onPermissionsGranted(); + #endif qDebug() << "Permissions granted"; #else emit onPermissionsGranted();