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

Unverified Commit 73058b1c authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Support calendar colors

parent fac1c9cf
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ open class ICalendar {

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

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

                calendar.getProperty<Property>(Color.PROPERTY_NAME)?.let { calColor ->
                    properties[Color.PROPERTY_NAME] = calColor.value
                }
                calendar.getProperty<Property>(CALENDAR_COLOR)?.let { calColor ->
                    properties[CALENDAR_COLOR] = calColor.value
                }
+8 −4
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ 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
import net.fortuna.ical4j.model.property.Color
import net.fortuna.ical4j.model.property.DtEnd
import net.fortuna.ical4j.model.property.DtStart
import net.fortuna.ical4j.model.property.Due
@@ -50,17 +51,20 @@ class ICalendarTest {
	}

	@Test
	fun testFromReader_calendarColor() {
	fun testFromReader_calendarProperties() {
		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" +
				"X-WR-CALNAME:Some Calendar\n" +
				"COLOR:darkred\n" +
				"X-APPLE-CALENDAR-COLOR:#123456\n" +
				"END:VCALENDAR"
		))
		assertEquals(calendar.getProperty<Property?>("COLOR").value, "#000000")
		assertEquals("Some Calendar", calendar.getProperty<Property>(ICalendar.CALENDAR_NAME).value)
		assertEquals("darkred", calendar.getProperty<Property>(Color.PROPERTY_NAME).value)
		assertEquals("#123456", calendar.getProperty<Property>(ICalendar.CALENDAR_COLOR).value)
	}

	@Test