From 3efe4b0f164231ce24feae549e16ff88f51d5f5e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 13 Aug 2017 17:23:06 +0200 Subject: [PATCH] allow selecting specific calendars from caldav --- .../com/simplemobiletools/calendar/extensions/Context.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index ad6fa2e1b..2ab0e4113 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -231,7 +231,7 @@ fun Context.launchNewEventIntent(startNewTask: Boolean = false, today: Boolean = } } -fun Context.getCalDAVCalendars(): List { +fun Context.getCalDAVCalendars(ids: String = ""): List { val calendars = ArrayList() if (!hasCalendarPermission()) { return calendars @@ -244,10 +244,11 @@ fun Context.getCalDAVCalendars(): List { CalendarContract.Calendars.ACCOUNT_NAME, CalendarContract.Calendars.OWNER_ACCOUNT, CalendarContract.Calendars.CALENDAR_COLOR) + val selection = if (ids.trim().isNotEmpty()) "${CalendarContract.Calendars._ID} IN ($ids)" else null var cursor: Cursor? = null try { - cursor = contentResolver.query(uri, projection, null, null, null) + cursor = contentResolver.query(uri, projection, selection, null, null) while (cursor.moveToNext()) { val id = cursor.getLongValue(CalendarContract.Calendars._ID) val displayName = cursor.getStringValue(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME)