Commit d870e4a7 authored by Nicolas Fella's avatar Nicolas Fella Committed by Nicolas Fella

Support runtime permissions

To be able to release Itinerary in Google Play we need to target SDK version 28. This requires us to support the permission system introduced in Marshmallow. Before we access the calendar we need to check and potentially request
the calendar permission.

It seems like we don't actually need the storage permission, we get access rights to files received via intents automatically.

Reviewers: vkrause

Reviewed By: vkrause

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision:
parent 4880e682
......@@ -79,10 +79,9 @@
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_CALENDAR"/>
......@@ -53,6 +53,9 @@
using namespace KItinerary;
#define PERMISSION_CALENDAR QStringLiteral("android.permission.READ_CALENDAR")
static void importReservation(JNIEnv *env, jobject that, jstring data)
......@@ -452,9 +455,18 @@ void ApplicationController::importIataBcbp(const QByteArray &data)
void ApplicationController::checkCalendar()
const auto activity = QtAndroid::androidActivity();
if (activity.isValid()) {
if (QtAndroid::checkPermission(PERMISSION_CALENDAR) == QtAndroid::PermissionResult::Granted) {
const auto activity = QtAndroid::androidActivity();
if (activity.isValid()) {
} else {
QtAndroid::requestPermissions({PERMISSION_CALENDAR}, [this] (const QtAndroid::PermissionResultMap &result){
if (result[PERMISSION_CALENDAR] == QtAndroid::PermissionResult::Granted) {
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