diff --git a/README.md b/README.md index 1670a239..ceb6a044 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,10 @@ Basic operations, you'll want to copy-paste this for testing purposes: calOptions.recurrenceEndDate = new Date(2015,10,1,0,0,0,0,0); // leave null to add events into infinity and beyond calOptions.calendarName = "MyCreatedCalendar"; // iOS only calOptions.calendarId = 1; // Android only, use id obtained from listCalendars() call which is described below. This will be ignored on iOS in favor of calendarName and vice versa. Default: 1. + + // And the URL can be passed since 4.3.2 (will be appended to the notes on Android as there doesn't seem to be a sep field) + calOptions.url = "https://www.google.com"; + window.plugins.calendar.createEventWithOptions(title,eventLocation,notes,startDate,endDate,calOptions,success,error); // create an event interactively diff --git a/plugin.xml b/plugin.xml index 6e36341a..f1f27da4 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="nl.x-services.plugins.calendar" - version="4.3.1"> + version="4.3.2"> Calendar diff --git a/src/android/nl/xservices/plugins/Calendar.java b/src/android/nl/xservices/plugins/Calendar.java index 10c7be91..da1853da 100644 --- a/src/android/nl/xservices/plugins/Calendar.java +++ b/src/android/nl/xservices/plugins/Calendar.java @@ -228,7 +228,8 @@ private boolean createEvent(JSONArray args) { argOptionsObject.isNull("secondReminderMinutes") ? null : argOptionsObject.getLong("secondReminderMinutes"), argOptionsObject.isNull("recurrence") ? null : argOptionsObject.getString("recurrence"), argOptionsObject.isNull("recurrenceEndTime") ? null : argOptionsObject.getLong("recurrenceEndTime"), - argOptionsObject.isNull("calendarId") ? 1 : argOptionsObject.getInt("calendarId")); + argOptionsObject.isNull("calendarId") ? 1 : argOptionsObject.getInt("calendarId"), + argOptionsObject.isNull("url") ? null : argOptionsObject.getString("url")); callback.success(); return true; diff --git a/src/android/nl/xservices/plugins/accessor/AbstractCalendarAccessor.java b/src/android/nl/xservices/plugins/accessor/AbstractCalendarAccessor.java index 9193223b..f230a716 100644 --- a/src/android/nl/xservices/plugins/accessor/AbstractCalendarAccessor.java +++ b/src/android/nl/xservices/plugins/accessor/AbstractCalendarAccessor.java @@ -425,7 +425,8 @@ public boolean deleteEvent(Uri eventsUri, long startFrom, long startTo, String t public void createEvent(Uri eventsUri, String title, long startTime, long endTime, String description, String location, Long firstReminderMinutes, Long secondReminderMinutes, - String recurrence, Long recurrenceEndTime, Integer calendarId) { + String recurrence, Long recurrenceEndTime, Integer calendarId, + String url) { ContentResolver cr = this.cordova.getActivity().getContentResolver(); ContentValues values = new ContentValues(); final boolean allDayEvent = isAllDayEvent(new Date(startTime), new Date(endTime)); @@ -434,6 +435,14 @@ public void createEvent(Uri eventsUri, String title, long startTime, long endTim values.put(Events.DTSTART, allDayEvent ? startTime+(1000*60*60*24) : startTime); values.put(Events.DTEND, endTime); values.put(Events.TITLE, title); + // there's no separate url field, so adding it to the notes + if (url != null) { + if (description == null) { + description = url; + } else { + description += " " + url; + } + } values.put(Events.DESCRIPTION, description); values.put(Events.HAS_ALARM, 1); values.put(Events.CALENDAR_ID, calendarId); diff --git a/src/android/nl/xservices/plugins/accessor/CalendarProviderAccessor.java b/src/android/nl/xservices/plugins/accessor/CalendarProviderAccessor.java index 39b09c60..b65bad95 100644 --- a/src/android/nl/xservices/plugins/accessor/CalendarProviderAccessor.java +++ b/src/android/nl/xservices/plugins/accessor/CalendarProviderAccessor.java @@ -122,10 +122,11 @@ public boolean deleteEvent(Uri eventsUri, long startFrom, long startTo, String t @Override public void createEvent(Uri eventsUri, String title, long startTime, long endTime, - String description, String location, Long firstReminderMinutes, Long secondReminderMinutes, - String recurrence, Long recurrenceEndTime, Integer calendarId) { + String description, String location, Long firstReminderMinutes, Long secondReminderMinutes, + String recurrence, Long recurrenceEndTime, Integer calendarId, + String url) { eventsUri = eventsUri == null ? Uri.parse(CONTENT_PROVIDER + CONTENT_PROVIDER_PATH_EVENTS) : eventsUri; super.createEvent(eventsUri, title, startTime, endTime, description, location, - firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId); + firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId, url); } } diff --git a/src/android/nl/xservices/plugins/accessor/LegacyCalendarAccessor.java b/src/android/nl/xservices/plugins/accessor/LegacyCalendarAccessor.java index 6a5b5654..16465fe7 100644 --- a/src/android/nl/xservices/plugins/accessor/LegacyCalendarAccessor.java +++ b/src/android/nl/xservices/plugins/accessor/LegacyCalendarAccessor.java @@ -122,11 +122,12 @@ public boolean deleteEvent(Uri eventsUri, long startFrom, long startTo, String t @Override public void createEvent(Uri eventsUri, String title, long startTime, long endTime, - String description, String location, Long firstReminderMinutes, Long secondReminderMinutes, - String recurrence, Long recurrenceEndTime, Integer calendarId) { + String description, String location, Long firstReminderMinutes, Long secondReminderMinutes, + String recurrence, Long recurrenceEndTime, Integer calendarId, + String url) { eventsUri = eventsUri == null ? Uri.parse(CONTENT_PROVIDER_PRE_FROYO + CONTENT_PROVIDER_PATH_EVENTS) : eventsUri; super.createEvent(eventsUri, title, startTime, endTime, description, location, - firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId); + firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId, url); } } diff --git a/www/Calendar.js b/www/Calendar.js index 5427a4f9..1a4f0289 100644 --- a/www/Calendar.js +++ b/www/Calendar.js @@ -52,6 +52,7 @@ Calendar.prototype.getCalendarOptions = function () { recurrenceEndDate: null, calendarName: null, calendarId: null, + url: null }; };