Skip to content

Commit 2724e33

Browse files
committed
Imports; AndroidEvent2: add attendees/extended properties
1 parent 017b112 commit 2724e33

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Then make the changes in your own repository and send a pull request.
2121

2222
# Packages
2323

24-
- `at.bitfire.ical4android`: legacy [ical4android](https://github.com/bitfireAT/ical4android)
2524
- `at.bitfire.synctools`: new package where everything shall be refactored into
2625
- `.icalendar`: high-level operations on iCalendar objects
2726
- `.mapping`: mappers between low-level (database rows) and high-level (iCalendar/vCard) objects
2827
- `.storage`: low-level operations on content-provider storage (`ContentValues` / `Entity` to store data)
28+
- `at.bitfire.ical4android`: legacy [ical4android](https://github.com/bitfireAT/ical4android)
2929
- `at.bitfire.vcard4android`: legacy [vcard4android](https://github.com/bitfireAT/vcard4android)
3030

3131

lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendar.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class AndroidCalendar(
9494
for (row in entity.subValues)
9595
batch += CpoBuilder.newInsert(row.uri)
9696
.withValues(row.values)
97-
.withValueBackReference(DATA_ROW_EVENT_ID, /* result of first operation with index = */ 0)
97+
.withValueBackReference(AndroidEvent2.DATA_ROW_EVENT_ID, /* result of first operation with index = */ 0)
9898

9999
batch.commit()
100100

@@ -269,7 +269,7 @@ class AndroidCalendar(
269269
for (row in entity.subValues)
270270
batch += CpoBuilder.newInsert(row.uri)
271271
.withValues(ContentValues(row.values).apply {
272-
put(DATA_ROW_EVENT_ID, id) // never update reference to main row ID
272+
put(AndroidEvent2.DATA_ROW_EVENT_ID, id) // never update reference to main row ID
273273
})
274274

275275
batch.commit()
@@ -449,16 +449,4 @@ class AndroidCalendar(
449449
return Pair(protectedWhere, protectedWhereArgs)
450450
}
451451

452-
453-
companion object {
454-
455-
/**
456-
* Name of the data row field that references the main row ID.
457-
*
458-
* Equals to [Attendees.EVENT_ID], [Reminders.EVENT_ID] etc.
459-
*/
460-
const val DATA_ROW_EVENT_ID = "event_id"
461-
462-
}
463-
464452
}

lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidEvent2.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ package at.bitfire.synctools.storage.calendar
99
import android.content.ContentResolver
1010
import android.content.ContentValues
1111
import android.content.Entity
12+
import android.provider.CalendarContract.Attendees
1213
import android.provider.CalendarContract.Events
14+
import android.provider.CalendarContract.ExtendedProperties
1315
import android.provider.CalendarContract.Reminders
1416
import at.bitfire.synctools.storage.calendar.AndroidEvent2.Companion.CATEGORIES_SEPARATOR
1517

@@ -77,6 +79,16 @@ class AndroidEvent2(
7779

7880
// data rows
7981

82+
val attendees: List<ContentValues>
83+
get() = values.subValues.mapNotNull { dataRow ->
84+
dataRow.values.takeIf { dataRow.uri == Attendees.CONTENT_URI }
85+
}
86+
87+
val extendedProperties: List<ContentValues>
88+
get() = values.subValues.mapNotNull { dataRow ->
89+
dataRow.values.takeIf { dataRow.uri == ExtendedProperties.CONTENT_URI }
90+
}
91+
8092
val reminders: List<ContentValues>
8193
get() = values.subValues.mapNotNull { dataRow ->
8294
dataRow.values.takeIf { dataRow.uri == Reminders.CONTENT_URI }
@@ -145,6 +157,13 @@ class AndroidEvent2(
145157
*/
146158
const val EXTNAME_URL = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/vnd.ical4android.url"
147159

160+
/**
161+
* Name of the data row field that references the main row ID.
162+
*
163+
* Equals to [Attendees.EVENT_ID], [Reminders.EVENT_ID] etc.
164+
*/
165+
const val DATA_ROW_EVENT_ID = "event_id"
166+
148167
}
149168

150169
}

0 commit comments

Comments
 (0)