Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ androidx-test-runner = "1.7.0"
dokka = "2.1.0"
ezvcard = "0.12.2"
guava = "33.5.0-android"
# noinspection NewerVersionAvailable
ical4j = "3.2.19" # final version; update to 4.x will require much work
ical4j = "4.2.3"
junit = "4.13.2"
kotlin = "2.3.10"
mockk = "1.14.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ class AndroidCompatTimeZoneRegistryTest {

@Test
fun getTimeZone_Existing_ButNotInIcal4j() {
val reg = AndroidCompatTimeZoneRegistry(object: TimeZoneRegistry {
TODO("ical4j 4.x")
/*val reg = AndroidCompatTimeZoneRegistry(object: TimeZoneRegistry {
override fun register(timezone: TimeZone?) = throw NotImplementedError()
override fun register(timezone: TimeZone?, update: Boolean) = throw NotImplementedError()
override fun clear() = throw NotImplementedError()
override fun getTimeZone(id: String?) = null

})
assertNull(reg.getTimeZone("Europe/Berlin"))
assertNull(reg.getTimeZone("Europe/Berlin"))*/
}

@Test
Expand Down
16 changes: 10 additions & 6 deletions lib/src/androidTest/kotlin/at/bitfire/ical4android/DmfsTaskTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class DmfsTaskTest(
@Test
fun testAddTask() {
// build and write event to calendar provider
val task = Task()
TODO("ical4j 4.x")
/*val task = Task()
task.uid = "sample1@testAddEvent"
task.summary = "Sample event"
task.description = "Sample event with date/time"
Expand Down Expand Up @@ -125,26 +126,28 @@ class DmfsTaskTest(
assertEquals(task.unknownProperties, task2.unknownProperties)
} finally {
testTask.delete()
}
}*/
}

@Test(expected = LocalStorageException::class)
fun testAddTaskWithInvalidDue() {
val task = Task()
task.uid = "invalidDUE@ical4android.tests"
TODO("ical4j 4.x")
/*task.uid = "invalidDUE@ical4android.tests"
task.summary = "Task with invalid DUE"
task.dtStart = DtStart(Date("20150102"))

task.due = Due(Date("20150101"))
DmfsTask(taskList!!, task, "9468a4cf-0d5b-4379-a704-12f1f84100ba", null, 0).add()
DmfsTask(taskList!!, task, "9468a4cf-0d5b-4379-a704-12f1f84100ba", null, 0).add()*/
}

@Test
fun testAddTaskWithManyAlarms() {
val task = Task()
task.uid = "TaskWithManyAlarms"
task.summary = "Task with many alarms"
task.dtStart = DtStart(Date("20150102"))
TODO("ical4j 4.x")
//task.dtStart = DtStart(Date("20150102"))

for (i in 1..1050)
task.alarms += VAlarm(java.time.Duration.ofMinutes(i.toLong()))
Expand All @@ -162,7 +165,8 @@ class DmfsTaskTest(
task.summary = "Sample event"
task.description = "Sample event with date/time"
task.location = "Sample location"
task.dtStart = DtStart("20150501T120000", tzVienna)
TODO("ical4j 4.x")
//task.dtStart = DtStart("20150501T120000", tzVienna)
assertFalse(task.isAllDay())
val uri = DmfsTask(taskList!!, task, "9468a4cf-0d5b-4379-a704-12f1f84100ba", null, 0).add()
assertNotNull(uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,8 @@ class JtxICalObjectTest {
//assertEquals(iCalIn.components[0].getProperty(Component.VTODO), iCalOut.components[0].getProperty(Component.VTODO))

// there should only be one component for VJOURNAL and VTODO!
for(i in 0 until iCalIn.components.size) {
TODO("ical4j 4.x")
/*for(i in 0 until iCalIn.components.size) {

iCalIn.components[i].properties.forEach { inProp ->

Expand All @@ -846,7 +847,7 @@ class JtxICalObjectTest {
val outProp = iCalOut.components[i].properties.getProperty<Property>(inProp.name)
assertEquals(inProp, outProp)
}
}
}*/
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ class DmfsTaskBuilderTest (

// builder tests

@Test
init {
TODO("ical4j 4.x")
}

/*@Test
fun testBuildTask_Sequence() {
buildTask {
ICalendar.apply { sequence = 12345 }
Expand Down Expand Up @@ -263,7 +267,7 @@ class DmfsTaskBuilderTest (
buildTask {
}.let { result ->
assertEquals(
TaskContract.Tasks.CLASSIFICATION_DEFAULT /* null */,
TaskContract.Tasks.CLASSIFICATION_DEFAULT *//* null *//*,
result.getAsInteger(TaskContract.Tasks.CLASSIFICATION)
)
}
Expand Down Expand Up @@ -771,7 +775,7 @@ class DmfsTaskBuilderTest (
val dmfsTask = DmfsTask(taskList!!, task, "9dc64544-1816-4f04-b952-e894164467f6", null, 0)
dmfsTask.task!!.dtStart = DtStart("20150101", tzVienna)
assertEquals(tzVienna, builder.getTimeZone())
}
}*/


// helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

package at.bitfire.ical4android

import java.time.ZoneId
import java.util.logging.Logger
import net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory
import net.fortuna.ical4j.model.Property
import net.fortuna.ical4j.model.PropertyList
import net.fortuna.ical4j.model.TimeZone
import net.fortuna.ical4j.model.TimeZoneRegistry
import net.fortuna.ical4j.model.TimeZoneRegistryFactory
import net.fortuna.ical4j.model.TimeZoneRegistryImpl
import net.fortuna.ical4j.model.component.VTimeZone
import net.fortuna.ical4j.model.property.TzId
import java.time.ZoneId
import java.util.logging.Logger

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

// create a copy of the VTIMEZONE so that we don't modify the original registry values (which are not immutable)
val vTimeZone = tz.vTimeZone
val newVTimeZoneProperties = PropertyList<Property>()
TODO("ical4j 4.x")
/*val newVTimeZoneProperties = PropertyList<Property>()
newVTimeZoneProperties += TzId(androidTzId)
return TimeZone(VTimeZone(
newVTimeZoneProperties,
vTimeZone.observances
))
))*/
} else
return tz
}
Expand Down
41 changes: 18 additions & 23 deletions lib/src/main/kotlin/at/bitfire/ical4android/ICalendar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,17 @@ import at.bitfire.synctools.BuildConfig
import at.bitfire.synctools.exception.InvalidICalendarException
import at.bitfire.synctools.icalendar.ICalendarParser
import at.bitfire.synctools.icalendar.validation.ICalPreprocessor
import net.fortuna.ical4j.data.CalendarBuilder
import net.fortuna.ical4j.data.ParserException
import net.fortuna.ical4j.model.Calendar
import net.fortuna.ical4j.model.ComponentList
import net.fortuna.ical4j.model.Date
import net.fortuna.ical4j.model.Parameter
import net.fortuna.ical4j.model.Property
import net.fortuna.ical4j.model.PropertyList
import net.fortuna.ical4j.model.component.Daylight
import net.fortuna.ical4j.model.component.Observance
import net.fortuna.ical4j.model.component.Standard
import net.fortuna.ical4j.model.component.VAlarm
import net.fortuna.ical4j.model.component.VTimeZone
import net.fortuna.ical4j.model.parameter.Related
import net.fortuna.ical4j.model.property.Color
import net.fortuna.ical4j.model.property.DateProperty
import net.fortuna.ical4j.model.property.DtStart
import net.fortuna.ical4j.model.property.ProdId
import net.fortuna.ical4j.model.property.RDate
import net.fortuna.ical4j.model.property.RRule
import net.fortuna.ical4j.validate.ValidationException
import java.io.Reader
import java.io.StringReader
import java.time.Duration
import java.time.Period
import java.util.LinkedList
import java.util.UUID
import java.util.logging.Level
Expand Down Expand Up @@ -102,7 +88,8 @@ open class ICalendar {

// fill calendar properties
properties?.let {
calendar.getProperty<Property>(CALENDAR_NAME)?.let { calName ->
TODO("ical4j 4.x")
/*calendar.getProperty<Property>(CALENDAR_NAME)?.let { calName ->
properties[CALENDAR_NAME] = calName.value
}

Expand All @@ -111,7 +98,7 @@ open class ICalendar {
}
calendar.getProperty<Property>(CALENDAR_COLOR)?.let { calColor ->
properties[CALENDAR_COLOR] = calColor.value
}
}*/
}

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

TODO("ical4j 4.x")
// Note: big method – maybe split?

/*
if (start != null) {
// find latest matching STANDARD/DAYLIGHT observances
var latestDaylight: Pair<Date, Observance>? = null
Expand Down Expand Up @@ -210,7 +201,7 @@ open class ICalendar {
logger.log(Level.WARNING, "Minified timezone is invalid, using original one", e)
newTz = null
}
}
}*/

// use original time zone if we couldn't calculate a minified one
return newTz ?: originalTz
Expand All @@ -222,14 +213,15 @@ open class ICalendar {
* @return time zone id (TZID) if VTIMEZONE contains a TZID, null otherwise
*/
fun timezoneDefToTzId(timezoneDef: String): String? {
try {
TODO("ical4j 4.x")
/*try {
val builder = CalendarBuilder()
val cal = builder.build(StringReader(timezoneDef))
val timezone = cal.getComponent(VTimeZone.VTIMEZONE) as VTimeZone?
timezone?.timeZoneId?.let { return it.value }
} catch (e: ParserException) {
logger.log(Level.SEVERE, "Can't understand time zone definition", e)
}
}*/
return null
}

Expand Down Expand Up @@ -279,14 +271,17 @@ open class ICalendar {
*/
fun vAlarmToMin(
alarm: VAlarm,
refStart: DtStart?,
refEnd: DateProperty?,
refStart: DtStart<*>?,
refEnd: DateProperty<*>?,
refDuration: net.fortuna.ical4j.model.property.Duration?,
allowRelEnd: Boolean
): Pair<Related, Int>? {
val trigger = alarm.trigger ?: return null

val minutes: Int // minutes before/after the event
TODO("ical4j 4.x")
// Note: big method – maybe split?

/*val minutes: Int // minutes before/after the event
var related = trigger.getParameter(Parameter.RELATED) ?: Related.START

// event/task start time
Expand Down Expand Up @@ -345,7 +340,7 @@ open class ICalendar {
return null
}

return Pair(related, minutes)
return Pair(related, minutes)*/
}

}
Expand Down
8 changes: 3 additions & 5 deletions lib/src/main/kotlin/at/bitfire/ical4android/JtxCollection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import at.bitfire.synctools.storage.toContentValues
import at.techbee.jtx.JtxContract
import at.techbee.jtx.JtxContract.asSyncAdapter
import net.fortuna.ical4j.model.Calendar
import net.fortuna.ical4j.model.component.VJournal
import net.fortuna.ical4j.model.component.VToDo
import net.fortuna.ical4j.model.property.ProdId
import net.fortuna.ical4j.model.property.Version
import java.util.LinkedList
import java.util.logging.Level
import java.util.logging.Logger
Expand Down Expand Up @@ -259,7 +256,8 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
logger.fine("getICSForCollection: found ${cursor?.count} records in ${account.name}")

val ical = Calendar()
ical.properties += Version.VERSION_2_0
TODO("ical4j 4.x")
/*ical.properties += Version.VERSION_2_0
ical.properties += prodId

while (cursor?.moveToNext() == true) {
Expand All @@ -270,7 +268,7 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
if(component is VToDo || component is VJournal)
ical.components += component
}
}
}*/
return ical.toString()
}
}
Expand Down
Loading
Loading