Loading src/main/java/at/bitfire/ical4android/ICalendar.kt +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 } Loading src/test/java/at/bitfire/ical4android/ICalendarTest.kt +8 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading
src/main/java/at/bitfire/ical4android/ICalendar.kt +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 } Loading
src/test/java/at/bitfire/ical4android/ICalendarTest.kt +8 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading