diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 737a665c5..6e7c95311 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -389,7 +389,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_caldav_calendar_holder.beVisible() event_caldav_calendar_divider.beVisible() event_caldav_calendar_holder.setOnClickListener { - + val calendars = CalDAVEventsHandler(applicationContext).getCalDAVCalendars().filter { it.canWrite() } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVEventsHandler.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVEventsHandler.kt index 4873ed10c..576673c6c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVEventsHandler.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVEventsHandler.kt @@ -28,9 +28,10 @@ class CalDAVEventsHandler(val context: Context) { CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, 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 + CalendarContract.Calendars.CALENDAR_COLOR, + CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL) + val selection = if (ids.trim().isNotEmpty()) "${CalendarContract.Calendars._ID} IN ($ids)" else null var cursor: Cursor? = null try { cursor = context.contentResolver.query(uri, projection, selection, null, null) @@ -41,7 +42,8 @@ class CalDAVEventsHandler(val context: Context) { val accountName = cursor.getStringValue(CalendarContract.Calendars.ACCOUNT_NAME) val ownerName = cursor.getStringValue(CalendarContract.Calendars.OWNER_ACCOUNT) val color = cursor.getIntValue(CalendarContract.Calendars.CALENDAR_COLOR) - val calendar = CalDAVCalendar(id, displayName, accountName, ownerName, color) + val accessLevel = cursor.getIntValue(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL) + val calendar = CalDAVCalendar(id, displayName, accountName, ownerName, color, accessLevel) calendars.add(calendar) } while (cursor.moveToNext()) } @@ -68,8 +70,8 @@ class CalDAVEventsHandler(val context: Context) { CalendarContract.Events.DURATION, CalendarContract.Events.ALL_DAY, CalendarContract.Events.RRULE) - val selection = "${CalendarContract.Events.CALENDAR_ID} = $calendarId" + val selection = "${CalendarContract.Events.CALENDAR_ID} = $calendarId" var cursor: Cursor? = null try { cursor = context.contentResolver.query(uri, projection, selection, null, null) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt index 0703960fd..dda0ec26a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt @@ -1,3 +1,5 @@ package com.simplemobiletools.calendar.models -data class CalDAVCalendar(val id: Long, val displayName: String, val accountName: String, val ownerName: String, val color: Int) +data class CalDAVCalendar(val id: Long, val displayName: String, val accountName: String, val ownerName: String, val color: Int, val accessLevel: Int) { + fun canWrite() = accessLevel >= 500 +}