Skip to content

Commit 9d8a17d

Browse files
authored
Update ical4j to 4.x and make everything compile again (#197)
* Update ical4j dependency * Make at.bitfire.ical4android package compile again * Make package at.bitfire.synctools.icalendar compile again * Make at.bitfire.synctools compile again (add TODOs) * Make at.bitfire.ical4android unit tests run again * Make event builder tests run again * Make remaining unit tests compile again
1 parent ccd8bd5 commit 9d8a17d

104 files changed

Lines changed: 641 additions & 533 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gradle/libs.versions.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ androidx-test-runner = "1.7.0"
88
dokka = "2.1.0"
99
ezvcard = "0.12.2"
1010
guava = "33.5.0-android"
11-
# noinspection NewerVersionAvailable
12-
ical4j = "3.2.19" # final version; update to 4.x will require much work
11+
ical4j = "4.2.3"
1312
junit = "4.13.2"
1413
kotlin = "2.3.10"
1514
mockk = "1.14.9"

lib/src/androidTest/kotlin/at/bitfire/ical4android/AndroidCompatTimeZoneRegistryTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ class AndroidCompatTimeZoneRegistryTest {
4848

4949
@Test
5050
fun getTimeZone_Existing_ButNotInIcal4j() {
51-
val reg = AndroidCompatTimeZoneRegistry(object: TimeZoneRegistry {
51+
TODO("ical4j 4.x")
52+
/*val reg = AndroidCompatTimeZoneRegistry(object: TimeZoneRegistry {
5253
override fun register(timezone: TimeZone?) = throw NotImplementedError()
5354
override fun register(timezone: TimeZone?, update: Boolean) = throw NotImplementedError()
5455
override fun clear() = throw NotImplementedError()
5556
override fun getTimeZone(id: String?) = null
5657
5758
})
58-
assertNull(reg.getTimeZone("Europe/Berlin"))
59+
assertNull(reg.getTimeZone("Europe/Berlin"))*/
5960
}
6061

6162
@Test

lib/src/androidTest/kotlin/at/bitfire/ical4android/DmfsTaskTest.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class DmfsTaskTest(
8282
@Test
8383
fun testAddTask() {
8484
// build and write event to calendar provider
85-
val task = Task()
85+
TODO("ical4j 4.x")
86+
/*val task = Task()
8687
task.uid = "sample1@testAddEvent"
8788
task.summary = "Sample event"
8889
task.description = "Sample event with date/time"
@@ -125,26 +126,28 @@ class DmfsTaskTest(
125126
assertEquals(task.unknownProperties, task2.unknownProperties)
126127
} finally {
127128
testTask.delete()
128-
}
129+
}*/
129130
}
130131

131132
@Test(expected = LocalStorageException::class)
132133
fun testAddTaskWithInvalidDue() {
133134
val task = Task()
134-
task.uid = "invalidDUE@ical4android.tests"
135+
TODO("ical4j 4.x")
136+
/*task.uid = "invalidDUE@ical4android.tests"
135137
task.summary = "Task with invalid DUE"
136138
task.dtStart = DtStart(Date("20150102"))
137139
138140
task.due = Due(Date("20150101"))
139-
DmfsTask(taskList!!, task, "9468a4cf-0d5b-4379-a704-12f1f84100ba", null, 0).add()
141+
DmfsTask(taskList!!, task, "9468a4cf-0d5b-4379-a704-12f1f84100ba", null, 0).add()*/
140142
}
141143

142144
@Test
143145
fun testAddTaskWithManyAlarms() {
144146
val task = Task()
145147
task.uid = "TaskWithManyAlarms"
146148
task.summary = "Task with many alarms"
147-
task.dtStart = DtStart(Date("20150102"))
149+
TODO("ical4j 4.x")
150+
//task.dtStart = DtStart(Date("20150102"))
148151

149152
for (i in 1..1050)
150153
task.alarms += VAlarm(java.time.Duration.ofMinutes(i.toLong()))
@@ -162,7 +165,8 @@ class DmfsTaskTest(
162165
task.summary = "Sample event"
163166
task.description = "Sample event with date/time"
164167
task.location = "Sample location"
165-
task.dtStart = DtStart("20150501T120000", tzVienna)
168+
TODO("ical4j 4.x")
169+
//task.dtStart = DtStart("20150501T120000", tzVienna)
166170
assertFalse(task.isAllDay())
167171
val uri = DmfsTask(taskList!!, task, "9468a4cf-0d5b-4379-a704-12f1f84100ba", null, 0).add()
168172
assertNotNull(uri)

lib/src/androidTest/kotlin/at/bitfire/ical4android/JtxICalObjectTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,8 @@ class JtxICalObjectTest {
837837
//assertEquals(iCalIn.components[0].getProperty(Component.VTODO), iCalOut.components[0].getProperty(Component.VTODO))
838838

839839
// there should only be one component for VJOURNAL and VTODO!
840-
for(i in 0 until iCalIn.components.size) {
840+
TODO("ical4j 4.x")
841+
/*for(i in 0 until iCalIn.components.size) {
841842
842843
iCalIn.components[i].properties.forEach { inProp ->
843844
@@ -846,7 +847,7 @@ class JtxICalObjectTest {
846847
val outProp = iCalOut.components[i].properties.getProperty<Property>(inProp.name)
847848
assertEquals(inProp, outProp)
848849
}
849-
}
850+
}*/
850851
}
851852

852853

lib/src/androidTest/kotlin/at/bitfire/synctools/mapping/tasks/DmfsTaskBuilderTest.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ class DmfsTaskBuilderTest (
8282

8383
// builder tests
8484

85-
@Test
85+
init {
86+
TODO("ical4j 4.x")
87+
}
88+
89+
/*@Test
8690
fun testBuildTask_Sequence() {
8791
buildTask {
8892
ICalendar.apply { sequence = 12345 }
@@ -263,7 +267,7 @@ class DmfsTaskBuilderTest (
263267
buildTask {
264268
}.let { result ->
265269
assertEquals(
266-
TaskContract.Tasks.CLASSIFICATION_DEFAULT /* null */,
270+
TaskContract.Tasks.CLASSIFICATION_DEFAULT *//* null *//*,
267271
result.getAsInteger(TaskContract.Tasks.CLASSIFICATION)
268272
)
269273
}
@@ -771,7 +775,7 @@ class DmfsTaskBuilderTest (
771775
val dmfsTask = DmfsTask(taskList!!, task, "9dc64544-1816-4f04-b952-e894164467f6", null, 0)
772776
dmfsTask.task!!.dtStart = DtStart("20150101", tzVienna)
773777
assertEquals(tzVienna, builder.getTimeZone())
774-
}
778+
}*/
775779

776780

777781
// helpers

lib/src/main/kotlin/at/bitfire/ical4android/AndroidCompatTimeZoneRegistry.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66

77
package at.bitfire.ical4android
88

9-
import java.time.ZoneId
10-
import java.util.logging.Logger
119
import net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory
12-
import net.fortuna.ical4j.model.Property
13-
import net.fortuna.ical4j.model.PropertyList
1410
import net.fortuna.ical4j.model.TimeZone
1511
import net.fortuna.ical4j.model.TimeZoneRegistry
1612
import net.fortuna.ical4j.model.TimeZoneRegistryFactory
1713
import net.fortuna.ical4j.model.TimeZoneRegistryImpl
18-
import net.fortuna.ical4j.model.component.VTimeZone
19-
import net.fortuna.ical4j.model.property.TzId
14+
import java.time.ZoneId
15+
import java.util.logging.Logger
2016

2117
/**
2218
* Wrapper around default [TimeZoneRegistry] that uses the Android name if a time zone has a
@@ -78,12 +74,13 @@ class AndroidCompatTimeZoneRegistry(
7874

7975
// create a copy of the VTIMEZONE so that we don't modify the original registry values (which are not immutable)
8076
val vTimeZone = tz.vTimeZone
81-
val newVTimeZoneProperties = PropertyList<Property>()
77+
TODO("ical4j 4.x")
78+
/*val newVTimeZoneProperties = PropertyList<Property>()
8279
newVTimeZoneProperties += TzId(androidTzId)
8380
return TimeZone(VTimeZone(
8481
newVTimeZoneProperties,
8582
vTimeZone.observances
86-
))
83+
))*/
8784
} else
8885
return tz
8986
}

lib/src/main/kotlin/at/bitfire/ical4android/ICalendar.kt

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,17 @@ import at.bitfire.synctools.BuildConfig
1111
import at.bitfire.synctools.exception.InvalidICalendarException
1212
import at.bitfire.synctools.icalendar.ICalendarParser
1313
import at.bitfire.synctools.icalendar.validation.ICalPreprocessor
14-
import net.fortuna.ical4j.data.CalendarBuilder
15-
import net.fortuna.ical4j.data.ParserException
1614
import net.fortuna.ical4j.model.Calendar
17-
import net.fortuna.ical4j.model.ComponentList
1815
import net.fortuna.ical4j.model.Date
19-
import net.fortuna.ical4j.model.Parameter
20-
import net.fortuna.ical4j.model.Property
21-
import net.fortuna.ical4j.model.PropertyList
22-
import net.fortuna.ical4j.model.component.Daylight
2316
import net.fortuna.ical4j.model.component.Observance
24-
import net.fortuna.ical4j.model.component.Standard
2517
import net.fortuna.ical4j.model.component.VAlarm
2618
import net.fortuna.ical4j.model.component.VTimeZone
2719
import net.fortuna.ical4j.model.parameter.Related
28-
import net.fortuna.ical4j.model.property.Color
2920
import net.fortuna.ical4j.model.property.DateProperty
3021
import net.fortuna.ical4j.model.property.DtStart
3122
import net.fortuna.ical4j.model.property.ProdId
32-
import net.fortuna.ical4j.model.property.RDate
33-
import net.fortuna.ical4j.model.property.RRule
3423
import net.fortuna.ical4j.validate.ValidationException
3524
import java.io.Reader
36-
import java.io.StringReader
37-
import java.time.Duration
38-
import java.time.Period
3925
import java.util.LinkedList
4026
import java.util.UUID
4127
import java.util.logging.Level
@@ -102,7 +88,8 @@ open class ICalendar {
10288

10389
// fill calendar properties
10490
properties?.let {
105-
calendar.getProperty<Property>(CALENDAR_NAME)?.let { calName ->
91+
TODO("ical4j 4.x")
92+
/*calendar.getProperty<Property>(CALENDAR_NAME)?.let { calName ->
10693
properties[CALENDAR_NAME] = calName.value
10794
}
10895
@@ -111,7 +98,7 @@ open class ICalendar {
11198
}
11299
calendar.getProperty<Property>(CALENDAR_COLOR)?.let { calColor ->
113100
properties[CALENDAR_COLOR] = calColor.value
114-
}
101+
}*/
115102
}
116103

117104
return calendar
@@ -137,6 +124,10 @@ open class ICalendar {
137124
var newTz: VTimeZone? = null
138125
val keep = mutableSetOf<Observance>()
139126

127+
TODO("ical4j 4.x")
128+
// Note: big method – maybe split?
129+
130+
/*
140131
if (start != null) {
141132
// find latest matching STANDARD/DAYLIGHT observances
142133
var latestDaylight: Pair<Date, Observance>? = null
@@ -210,7 +201,7 @@ open class ICalendar {
210201
logger.log(Level.WARNING, "Minified timezone is invalid, using original one", e)
211202
newTz = null
212203
}
213-
}
204+
}*/
214205

215206
// use original time zone if we couldn't calculate a minified one
216207
return newTz ?: originalTz
@@ -222,14 +213,15 @@ open class ICalendar {
222213
* @return time zone id (TZID) if VTIMEZONE contains a TZID, null otherwise
223214
*/
224215
fun timezoneDefToTzId(timezoneDef: String): String? {
225-
try {
216+
TODO("ical4j 4.x")
217+
/*try {
226218
val builder = CalendarBuilder()
227219
val cal = builder.build(StringReader(timezoneDef))
228220
val timezone = cal.getComponent(VTimeZone.VTIMEZONE) as VTimeZone?
229221
timezone?.timeZoneId?.let { return it.value }
230222
} catch (e: ParserException) {
231223
logger.log(Level.SEVERE, "Can't understand time zone definition", e)
232-
}
224+
}*/
233225
return null
234226
}
235227

@@ -279,14 +271,17 @@ open class ICalendar {
279271
*/
280272
fun vAlarmToMin(
281273
alarm: VAlarm,
282-
refStart: DtStart?,
283-
refEnd: DateProperty?,
274+
refStart: DtStart<*>?,
275+
refEnd: DateProperty<*>?,
284276
refDuration: net.fortuna.ical4j.model.property.Duration?,
285277
allowRelEnd: Boolean
286278
): Pair<Related, Int>? {
287279
val trigger = alarm.trigger ?: return null
288280

289-
val minutes: Int // minutes before/after the event
281+
TODO("ical4j 4.x")
282+
// Note: big method – maybe split?
283+
284+
/*val minutes: Int // minutes before/after the event
290285
var related = trigger.getParameter(Parameter.RELATED) ?: Related.START
291286
292287
// event/task start time
@@ -345,7 +340,7 @@ open class ICalendar {
345340
return null
346341
}
347342
348-
return Pair(related, minutes)
343+
return Pair(related, minutes)*/
349344
}
350345

351346
}

lib/src/main/kotlin/at/bitfire/ical4android/JtxCollection.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import at.bitfire.synctools.storage.toContentValues
1717
import at.techbee.jtx.JtxContract
1818
import at.techbee.jtx.JtxContract.asSyncAdapter
1919
import net.fortuna.ical4j.model.Calendar
20-
import net.fortuna.ical4j.model.component.VJournal
21-
import net.fortuna.ical4j.model.component.VToDo
2220
import net.fortuna.ical4j.model.property.ProdId
23-
import net.fortuna.ical4j.model.property.Version
2421
import java.util.LinkedList
2522
import java.util.logging.Level
2623
import java.util.logging.Logger
@@ -259,7 +256,8 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
259256
logger.fine("getICSForCollection: found ${cursor?.count} records in ${account.name}")
260257

261258
val ical = Calendar()
262-
ical.properties += Version.VERSION_2_0
259+
TODO("ical4j 4.x")
260+
/*ical.properties += Version.VERSION_2_0
263261
ical.properties += prodId
264262
265263
while (cursor?.moveToNext() == true) {
@@ -270,7 +268,7 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
270268
if(component is VToDo || component is VJournal)
271269
ical.components += component
272270
}
273-
}
271+
}*/
274272
return ical.toString()
275273
}
276274
}

0 commit comments

Comments
 (0)