File tree 1 file changed +18
-2
lines changed
app/src/main/kotlin/at/bitfire/davdroid/resource
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import android.annotation.SuppressLint
9
9
import android.content.ContentValues
10
10
import android.content.Context
11
11
import android.net.Uri
12
+ import android.provider.CalendarContract
13
+ import androidx.core.database.getIntOrNull
12
14
import at.bitfire.davdroid.Constants
13
15
import at.bitfire.davdroid.db.Collection
14
16
import at.bitfire.davdroid.db.SyncState
@@ -69,8 +71,22 @@ class LocalTaskList private constructor(
69
71
}
70
72
71
73
override var readOnly: Boolean
72
- get() = TODO (" Not yet implemented" )
73
- set(value) {}
74
+ get() = provider.client.query(
75
+ taskListSyncUri(), arrayOf(TaskListColumns .ACCESS_LEVEL ),
76
+ null , null , null
77
+ )?.use { cursor ->
78
+ if (cursor.moveToNext())
79
+ return cursor.getIntOrNull(0 ) == TaskListColumns .ACCESS_LEVEL_READ
80
+ else
81
+ false
82
+ } == true
83
+ set(readOnly) {
84
+ val values = ContentValues ().apply { put(
85
+ CalendarContract .Calendars .CALENDAR_ACCESS_LEVEL ,
86
+ if (readOnly) CalendarContract .Calendars .CAL_ACCESS_READ else CalendarContract .Calendars .CAL_ACCESS_OWNER
87
+ )}
88
+ provider.client.update(taskListSyncUri(), values, null , null )
89
+ }
74
90
75
91
override val tag: String
76
92
get() = " tasks-${account.name} -$id "
You can’t perform that action at this time.
0 commit comments