@Override
public void handleButtonPress(int index) {
CalendarParsedResult calendarResult = (CalendarParsedResult) getResult();
- switch (index) {
- case 0:
- addCalendarEvent(calendarResult.getSummary(), calendarResult.getStart(),
- calendarResult.getEnd());
- break;
+ if (index == 0) {
+ addCalendarEvent(calendarResult.getSummary(),
+ calendarResult.getStart(),
+ calendarResult.getEnd(),
+ calendarResult.getLocation());
}
}
* @param summary A description of the event
* @param start The start time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
* @param end The end time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
+ * @param location a text description of the event location
*/
- final void addCalendarEvent(String summary, String start, String end) {
+ final void addCalendarEvent(String summary, String start, String end, String location) {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", calculateMilliseconds(start));
if (start.length() == 8) {
intent.putExtra("allDay", true);
}
+ if (end == null) {
+ end = start;
+ }
intent.putExtra("endTime", calculateMilliseconds(end));
intent.putExtra("title", summary);
+ intent.putExtra("eventLocation", location);
launchIntent(intent);
}
/**
* Partially implements the iCalendar format's "VEVENT" format for specifying a
- * calendar event. See RFC 2445. This supports SUMMARY, DTSTART and DTEND fields.
+ * calendar event. See RFC 2445. This supports SUMMARY, LOCATION, DTSTART and DTEND fields.
*
* @author Sean Owen
*/
String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);
String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);
String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);
+ String location = VCardResultParser.matchSingleVCardPrefixedField("LOCATION", rawText, true);
try {
- return new CalendarParsedResult(summary, start, end, null, null, null);
+ return new CalendarParsedResult(summary, start, end, location, null, null);
} catch (IllegalArgumentException iae) {
return null;
}
public void testVEvent() {
doTest(
- "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nDTEND:20080505T234555Z\r\n" +
+ "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
+ "DTEND:20080505T234555Z\r\nLOCATION:Miami\r\n" +
"END:VEVENT\r\nEND:VCALENDAR",
- null, "foo", null, "20080504T123456Z", "20080505T234555Z", null);
+ null, "foo", "Miami", "20080504T123456Z", "20080505T234555Z", null);
}
private static void doTest(String contents,