Commit 95173dcd authored by Ricki Hirner's avatar Ricki Hirner

Ask for contacts/calendar permissions as soon there is a known CalDAV/CardDAV service

parent be754d6e
......@@ -419,25 +419,21 @@ class AccountActivity: AppCompatActivity(), Toolbar.OnMenuItemClickListener, Pop
// ask for permissions
val requiredPermissions = mutableSetOf<String>()
info?.carddav?.let { carddav ->
if (carddav.collections.any { it.type == CollectionInfo.Type.ADDRESS_BOOK }) {
requiredPermissions += Manifest.permission.READ_CONTACTS
requiredPermissions += Manifest.permission.WRITE_CONTACTS
}
if (info?.carddav != null) {
// if there is a CardDAV service, ask for contacts permissions
requiredPermissions += Manifest.permission.READ_CONTACTS
requiredPermissions += Manifest.permission.WRITE_CONTACTS
}
info?.caldav?.let { caldav ->
if (caldav.collections.any { it.type == CollectionInfo.Type.CALENDAR }) {
requiredPermissions += Manifest.permission.READ_CALENDAR
requiredPermissions += Manifest.permission.WRITE_CALENDAR
if (info?.caldav != null) {
// if there is a CalDAV service, ask for calendar and tasks permissions
requiredPermissions += Manifest.permission.READ_CALENDAR
requiredPermissions += Manifest.permission.WRITE_CALENDAR
if (LocalTaskList.tasksProviderAvailable(this)) {
requiredPermissions += TaskProvider.PERMISSION_READ_TASKS
requiredPermissions += TaskProvider.PERMISSION_WRITE_TASKS
}
if (LocalTaskList.tasksProviderAvailable(this)) {
requiredPermissions += TaskProvider.PERMISSION_READ_TASKS
requiredPermissions += TaskProvider.PERMISSION_WRITE_TASKS
}
if (caldav.collections.any { it.type == CollectionInfo.Type.WEBCAL })
requiredPermissions += Manifest.permission.READ_CALENDAR
}
val askPermissions = requiredPermissions.filter { ActivityCompat.checkSelfPermission(this, it) != PackageManager.PERMISSION_GRANTED }
......
......@@ -146,13 +146,13 @@ class AccountDetailsFragment: Fragment() {
// insert CardDAV service
val id = insertService(db, accountName, Services.SERVICE_CARDDAV, config.cardDAV)
// initial CardDAV account settings
accountSettings.setGroupMethod(groupMethod)
// start CardDAV service detection (refresh collections)
refreshIntent.putExtra(DavService.EXTRA_DAV_SERVICE_ID, id)
appContext.startService(refreshIntent)
// initial CardDAV account settings
accountSettings.setGroupMethod(groupMethod)
// contact sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_address_books.xml
accountSettings.setSyncInterval(appContext.getString(R.string.address_books_authority), Constants.DEFAULT_SYNC_INTERVAL)
} else
......
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