Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fac1c9cf authored by Sunik Kupfer's avatar Sunik Kupfer
Browse files

add support for COLOR property (closes bitfireAT/icsx5#31)

parent b0ec5b89
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ open class ICalendar {

        // known iCalendar properties
        const val CALENDAR_NAME = "X-WR-CALNAME"
        const val CALENDAR_COLOR = "COLOR"

        /**
         * Default PRODID used when generating iCalendars. If you want another value, set it
@@ -94,6 +95,9 @@ open class ICalendar {
                calendar.getProperty<Property>(CALENDAR_NAME)?.let { calName ->
                    properties[CALENDAR_NAME] = calName.value
                }
                calendar.getProperty<Property>(CALENDAR_COLOR)?.let { calColor ->
                    properties[CALENDAR_COLOR] = calColor.value
                }
            }

            return calendar
+15 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import net.fortuna.ical4j.data.CalendarBuilder
import net.fortuna.ical4j.model.Component
import net.fortuna.ical4j.model.Date
import net.fortuna.ical4j.model.DateTime
import net.fortuna.ical4j.model.Property
import net.fortuna.ical4j.model.component.VAlarm
import net.fortuna.ical4j.model.component.VTimeZone
import net.fortuna.ical4j.model.parameter.Related
@@ -18,6 +19,7 @@ import net.fortuna.ical4j.util.TimeZones
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
import java.io.StringReader
import java.time.Duration
import java.time.Period

@@ -47,6 +49,19 @@ class ICalendarTest {
		}
	}

	@Test
	fun testFromReader_calendarColor() {
		val calendar = ICalendar.fromReader(
			StringReader("BEGIN:VCALENDAR\n" +
				"VERSION:2.0\n" +
				"METHOD:PUBLISH\n" +
				"PRODID:something\n" +
				"COLOR:#000000\n" +
				"X-WR-CALNAME:Some CALNAME\n" +
				"END:VCALENDAR"
		))
		assertEquals(calendar.getProperty<Property?>("COLOR").value, "#000000")
	}

	@Test
	fun testMinifyVTimezone_UTC() {