Commit 10bdd9e9 authored by Karel Slaný's avatar Karel Slaný

Merge branch 'android-permissions' into 'develop'

Check and ask user for android storage permissions

Closes #145

See merge request !150
parents 33bc854e 3dba8144
......@@ -716,6 +716,12 @@ int main(int argc, char *argv[])
IntentNotification intentNotification(interactionZfoFile);
QObject::connect(&app, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
&intentNotification, SLOT(scanIntentsForFiles(Qt::ApplicationState)));
/* Check and ask user for android storage permissions. */
if (!IntentNotification::checkAndAskStoragePermissions()) {
logWarningNL("%s", "Android storage permissions denied!");
}
#endif /* defined(Q_OS_ANDROID) */
QmlInputDialogue::searchPersistentDialogues(&engine);
......
......@@ -107,3 +107,18 @@ void IntentNotification::scanIntentsForFiles(Qt::ApplicationState newState)
m_inter.openZfoFile(filePath);
}
}
bool IntentNotification::checkAndAskStoragePermissions(void)
{
auto result = QtAndroid::checkPermission(
QString("android.permission.WRITE_EXTERNAL_STORAGE"));
if (result == QtAndroid::PermissionResult::Denied) {
QtAndroid::PermissionResultMap resultHash =
QtAndroid::requestPermissionsSync(
QStringList({"android.permission.WRITE_EXTERNAL_STORAGE"}));
return !(resultHash["android.permission.WRITE_EXTERNAL_STORAGE"]
== QtAndroid::PermissionResult::Denied);
}
return true;
}
......@@ -58,6 +58,14 @@ public:
static
QStringList getIntentArguments(void);
/*!
* @brief Check and ask android storage permissions.
*
* @return True if storage permissions are granted.
*/
static
bool checkAndAskStoragePermissions(void);
public slots:
/*!
* @brief Scans intent and process the obtained files.
......
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