Commit e901747f authored by camilo higuita's avatar camilo higuita

use mauikit andorid helper to request run time permissions

parent ac365b93
......@@ -9,6 +9,7 @@
#ifdef Q_OS_ANDROID
#include <QGuiApplication>
#include <QIcon>
#include "mauiandroid.h"
#else
#include <QApplication>
#endif
......@@ -21,47 +22,18 @@
#include "3rdparty/mauikit/src/mauikit.h"
#endif
#ifdef Q_OS_ANDROID
#include <QtAndroid>
// Taken from https://bugreports.qt.io/browse/QTBUG-50759
bool check_permission() //STILL NOT MAKING SDCARD WRITABLE
{
qDebug() << "CHECHKIGN PERMISSIONS";
QtAndroid::PermissionResult r = QtAndroid::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
if(r == QtAndroid::PermissionResult::Denied)
{
QtAndroid::requestPermissionsSync( QStringList() << "android.permission.WRITE_EXTERNAL_STORAGE" );
r = QtAndroid::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
if(r == QtAndroid::PermissionResult::Denied)
{
qDebug() << "Permission denied";
return false;
}
}
qDebug() << "Permissions granted!";
return true;
}
#endif
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
if (!MAUIAndroid::checkRunTimePermissions())
return -1;
#else
QApplication app(argc, argv);
#endif
#if defined (Q_OS_ANDROID)
if (!check_permission())
return -1;
#endif
app.setApplicationName(INX::appName);
app.setApplicationVersion(INX::version);
app.setApplicationDisplayName(INX::displayName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment