From 5a056ca74d14b48fc29a10b96190a48a456982b8 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Mon, 8 Jul 2024 18:24:47 +0600 Subject: [PATCH] feat: add recurrence rule support for importing calendar event from .ics file The recurrence rule (RRULE) property has been added to the VEvent class. This property represents a recurrence rule, such as "FREQ=WEEKLY;COUNT=10;BYDAY=MO". The property list in the VEvent also has been updated to include RRULE. The ImportActivity class now includes the RRULE property when creating a calendar intent. This allows the recurrence rule of an event to be imported along with other properties. It creates the correct recurrence rule while importing a recurring calendar event from an .ics file. --- src/com/android/calendar/ImportActivity.java | 2 ++ src/com/android/calendar/icalendar/VEvent.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/calendar/ImportActivity.java b/src/com/android/calendar/ImportActivity.java index e8f6bc098..d305a009f 100644 --- a/src/com/android/calendar/ImportActivity.java +++ b/src/com/android/calendar/ImportActivity.java @@ -158,6 +158,8 @@ public class ImportActivity extends Activity { IcalendarUtils.uncleanseString(firstEvent.getProperty(VEvent.DESCRIPTION))); calIntent.putExtra(CalendarContract.Events.ORGANIZER, IcalendarUtils.uncleanseString(firstEvent.getProperty(VEvent.ORGANIZER))); + calIntent.putExtra(CalendarContract.Events.RRULE, + IcalendarUtils.uncleanseString(firstEvent.getProperty(VEvent.RRULE))); if (firstEvent.mAttendees.size() > 0) { StringBuilder builder = new StringBuilder(); diff --git a/src/com/android/calendar/icalendar/VEvent.java b/src/com/android/calendar/icalendar/VEvent.java index 5098b7717..1bef91cd2 100644 --- a/src/com/android/calendar/icalendar/VEvent.java +++ b/src/com/android/calendar/icalendar/VEvent.java @@ -45,6 +45,7 @@ public class VEvent { public static String DESCRIPTION = "DESCRIPTION"; public static String ATTENDEE = "ATTENDEE"; public static String CATEGORIES = "CATEGORIES"; + public static String RRULE = "RRULE"; // Recurrence rule, example: FREQ=WEEKLY;COUNT=10;BYDAY=MO // Stores the -arity of the attributes that this component can have private static HashMap sPropertyList = new HashMap(); @@ -66,10 +67,10 @@ public class VEvent { sPropertyList.put(DTSTAMP,1); sPropertyList.put(SUMMARY,1); sPropertyList.put(DESCRIPTION,1); - sPropertyList.put(ATTENDEE, Integer.MAX_VALUE); sPropertyList.put(CATEGORIES, Integer.MAX_VALUE); sPropertyList.put(CATEGORIES, Integer.MAX_VALUE); + sPropertyList.put(RRULE, 1); } // Stores attributes and their corresponding values belonging to the Event component -- GitLab