Loading core/java/android/pim/RecurrenceSet.java +59 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ public class RecurrenceSet { return true; } // This can be removed when the old CalendarSyncAdapter is removed. public static boolean populateComponent(Cursor cursor, ICalendar.Component component) { Loading Loading @@ -292,6 +293,64 @@ public class RecurrenceSet { return true; } public static boolean populateComponent(ContentValues values, ICalendar.Component component) { long dtstart = -1; if (values.containsKey(Calendar.Events.DTSTART)) { dtstart = values.getAsLong(Calendar.Events.DTSTART); } String duration = values.getAsString(Calendar.Events.DURATION); String tzid = values.getAsString(Calendar.Events.EVENT_TIMEZONE); String rruleStr = values.getAsString(Calendar.Events.RRULE); String rdateStr = values.getAsString(Calendar.Events.RDATE); String exruleStr = values.getAsString(Calendar.Events.EXRULE); String exdateStr = values.getAsString(Calendar.Events.EXDATE); boolean allDay = values.getAsInteger(Calendar.Events.ALL_DAY) == 1; if ((dtstart == -1) || (TextUtils.isEmpty(duration))|| ((TextUtils.isEmpty(rruleStr))&& (TextUtils.isEmpty(rdateStr)))) { // no recurrence. return false; } ICalendar.Property dtstartProp = new ICalendar.Property("DTSTART"); Time dtstartTime = null; if (!TextUtils.isEmpty(tzid)) { if (!allDay) { dtstartProp.addParameter(new ICalendar.Parameter("TZID", tzid)); } dtstartTime = new Time(tzid); } else { // use the "floating" timezone dtstartTime = new Time(Time.TIMEZONE_UTC); } dtstartTime.set(dtstart); // make sure the time is printed just as a date, if all day. // TODO: android.pim.Time really should take care of this for us. if (allDay) { dtstartProp.addParameter(new ICalendar.Parameter("VALUE", "DATE")); dtstartTime.allDay = true; dtstartTime.hour = 0; dtstartTime.minute = 0; dtstartTime.second = 0; } dtstartProp.setValue(dtstartTime.format2445()); component.addProperty(dtstartProp); ICalendar.Property durationProp = new ICalendar.Property("DURATION"); durationProp.setValue(duration); component.addProperty(durationProp); addPropertiesForRuleStr(component, "RRULE", rruleStr); addPropertyForDateStr(component, "RDATE", rdateStr); addPropertiesForRuleStr(component, "EXRULE", exruleStr); addPropertyForDateStr(component, "EXDATE", exdateStr); return true; } private static void addPropertiesForRuleStr(ICalendar.Component component, String propertyName, String ruleStr) { Loading test-runner/android/test/IsolatedContext.java +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import android.os.Handler; import android.os.Looper; import java.util.List; import java.io.File; /** * A mock context which prevents its users from talking to the rest of the device while Loading Loading @@ -101,4 +102,8 @@ public class IsolatedContext extends ContextWrapper { // do nothing } } @Override public File getFilesDir() { return new File("/dev/null"); } } Loading
core/java/android/pim/RecurrenceSet.java +59 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ public class RecurrenceSet { return true; } // This can be removed when the old CalendarSyncAdapter is removed. public static boolean populateComponent(Cursor cursor, ICalendar.Component component) { Loading Loading @@ -292,6 +293,64 @@ public class RecurrenceSet { return true; } public static boolean populateComponent(ContentValues values, ICalendar.Component component) { long dtstart = -1; if (values.containsKey(Calendar.Events.DTSTART)) { dtstart = values.getAsLong(Calendar.Events.DTSTART); } String duration = values.getAsString(Calendar.Events.DURATION); String tzid = values.getAsString(Calendar.Events.EVENT_TIMEZONE); String rruleStr = values.getAsString(Calendar.Events.RRULE); String rdateStr = values.getAsString(Calendar.Events.RDATE); String exruleStr = values.getAsString(Calendar.Events.EXRULE); String exdateStr = values.getAsString(Calendar.Events.EXDATE); boolean allDay = values.getAsInteger(Calendar.Events.ALL_DAY) == 1; if ((dtstart == -1) || (TextUtils.isEmpty(duration))|| ((TextUtils.isEmpty(rruleStr))&& (TextUtils.isEmpty(rdateStr)))) { // no recurrence. return false; } ICalendar.Property dtstartProp = new ICalendar.Property("DTSTART"); Time dtstartTime = null; if (!TextUtils.isEmpty(tzid)) { if (!allDay) { dtstartProp.addParameter(new ICalendar.Parameter("TZID", tzid)); } dtstartTime = new Time(tzid); } else { // use the "floating" timezone dtstartTime = new Time(Time.TIMEZONE_UTC); } dtstartTime.set(dtstart); // make sure the time is printed just as a date, if all day. // TODO: android.pim.Time really should take care of this for us. if (allDay) { dtstartProp.addParameter(new ICalendar.Parameter("VALUE", "DATE")); dtstartTime.allDay = true; dtstartTime.hour = 0; dtstartTime.minute = 0; dtstartTime.second = 0; } dtstartProp.setValue(dtstartTime.format2445()); component.addProperty(dtstartProp); ICalendar.Property durationProp = new ICalendar.Property("DURATION"); durationProp.setValue(duration); component.addProperty(durationProp); addPropertiesForRuleStr(component, "RRULE", rruleStr); addPropertyForDateStr(component, "RDATE", rdateStr); addPropertiesForRuleStr(component, "EXRULE", exruleStr); addPropertyForDateStr(component, "EXDATE", exdateStr); return true; } private static void addPropertiesForRuleStr(ICalendar.Component component, String propertyName, String ruleStr) { Loading
test-runner/android/test/IsolatedContext.java +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import android.os.Handler; import android.os.Looper; import java.util.List; import java.io.File; /** * A mock context which prevents its users from talking to the rest of the device while Loading Loading @@ -101,4 +102,8 @@ public class IsolatedContext extends ContextWrapper { // do nothing } } @Override public File getFilesDir() { return new File("/dev/null"); } }