From a5d79c8df85b763ed591a75cd24f02e780a51f97 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 7 Nov 2023 15:33:25 +0100 Subject: [PATCH] android - log warning if permissions are missing (only) --- app/main.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 95fedff4a..f3741c4f4 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -170,6 +170,22 @@ static void write_platform_context_properties(QQmlApplicationEngine& engine){ #endif } +static void android_check_permissions(){ +#if defined(__android__) + qDebug()<<"Android request permissions"; + for(const QString &permission : permissions) { + auto result = QtAndroid::checkPermission(permission); + if (result == QtAndroid::PermissionResult::Denied) { + auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission})); + if (resultHash[permission] == QtAndroid::PermissionResult::Denied) { + LogMessagesModel::instanceGround().add_message_warn("QOpenHD","Android - missing permissions"); + return; + } + } + } +#endif +} + int main(int argc, char *argv[]) { @@ -235,20 +251,8 @@ int main(int argc, char *argv[]) { applePlatform->registerNotifications(); #endif - QOpenHD::instance().keep_screen_on(true); -#if defined(__android__) - qDebug()<<"Android request permissions"; - for(const QString &permission : permissions) { - auto result = QtAndroid::checkPermission(permission); - if (result == QtAndroid::PermissionResult::Denied) { - auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission})); - if (resultHash[permission] == QtAndroid::PermissionResult::Denied) { - return 0; - } - } - } -#endif - + QOpenHD::instance().keep_screen_on(true); + android_check_permissions(); load_fonts(); qmlRegisterType("OpenHD", 1, 0, "SpeedLadder");