Skip to content

Commit f787db5

Browse files
#165 Add URL - now for Android as well
1 parent a2b4e66 commit f787db5

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ Basic operations, you'll want to copy-paste this for testing purposes:
156156
calOptions.recurrenceEndDate = new Date(2015,10,1,0,0,0,0,0); // leave null to add events into infinity and beyond
157157
calOptions.calendarName = "MyCreatedCalendar"; // iOS only
158158
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.
159+
160+
// 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)
161+
calOptions.url = "https://www.google.com";
162+
159163
window.plugins.calendar.createEventWithOptions(title,eventLocation,notes,startDate,endDate,calOptions,success,error);
160164

161165
// create an event interactively

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns="http://apache.org/cordova/ns/plugins/1.0"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
id="nl.x-services.plugins.calendar"
6-
version="4.3.1">
6+
version="4.3.2">
77

88
<name>Calendar</name>
99

src/android/nl/xservices/plugins/Calendar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ private boolean createEvent(JSONArray args) {
228228
argOptionsObject.isNull("secondReminderMinutes") ? null : argOptionsObject.getLong("secondReminderMinutes"),
229229
argOptionsObject.isNull("recurrence") ? null : argOptionsObject.getString("recurrence"),
230230
argOptionsObject.isNull("recurrenceEndTime") ? null : argOptionsObject.getLong("recurrenceEndTime"),
231-
argOptionsObject.isNull("calendarId") ? 1 : argOptionsObject.getInt("calendarId"));
231+
argOptionsObject.isNull("calendarId") ? 1 : argOptionsObject.getInt("calendarId"),
232+
argOptionsObject.isNull("url") ? null : argOptionsObject.getString("url"));
232233

233234
callback.success();
234235
return true;

src/android/nl/xservices/plugins/accessor/AbstractCalendarAccessor.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ public boolean deleteEvent(Uri eventsUri, long startFrom, long startTo, String t
425425

426426
public void createEvent(Uri eventsUri, String title, long startTime, long endTime, String description,
427427
String location, Long firstReminderMinutes, Long secondReminderMinutes,
428-
String recurrence, Long recurrenceEndTime, Integer calendarId) {
428+
String recurrence, Long recurrenceEndTime, Integer calendarId,
429+
String url) {
429430
ContentResolver cr = this.cordova.getActivity().getContentResolver();
430431
ContentValues values = new ContentValues();
431432
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
434435
values.put(Events.DTSTART, allDayEvent ? startTime+(1000*60*60*24) : startTime);
435436
values.put(Events.DTEND, endTime);
436437
values.put(Events.TITLE, title);
438+
// there's no separate url field, so adding it to the notes
439+
if (url != null) {
440+
if (description == null) {
441+
description = url;
442+
} else {
443+
description += " " + url;
444+
}
445+
}
437446
values.put(Events.DESCRIPTION, description);
438447
values.put(Events.HAS_ALARM, 1);
439448
values.put(Events.CALENDAR_ID, calendarId);

src/android/nl/xservices/plugins/accessor/CalendarProviderAccessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,11 @@ public boolean deleteEvent(Uri eventsUri, long startFrom, long startTo, String t
122122

123123
@Override
124124
public void createEvent(Uri eventsUri, String title, long startTime, long endTime,
125-
String description, String location, Long firstReminderMinutes, Long secondReminderMinutes,
126-
String recurrence, Long recurrenceEndTime, Integer calendarId) {
125+
String description, String location, Long firstReminderMinutes, Long secondReminderMinutes,
126+
String recurrence, Long recurrenceEndTime, Integer calendarId,
127+
String url) {
127128
eventsUri = eventsUri == null ? Uri.parse(CONTENT_PROVIDER + CONTENT_PROVIDER_PATH_EVENTS) : eventsUri;
128129
super.createEvent(eventsUri, title, startTime, endTime, description, location,
129-
firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId);
130+
firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId, url);
130131
}
131132
}

src/android/nl/xservices/plugins/accessor/LegacyCalendarAccessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ public boolean deleteEvent(Uri eventsUri, long startFrom, long startTo, String t
122122

123123
@Override
124124
public void createEvent(Uri eventsUri, String title, long startTime, long endTime,
125-
String description, String location, Long firstReminderMinutes, Long secondReminderMinutes,
126-
String recurrence, Long recurrenceEndTime, Integer calendarId) {
125+
String description, String location, Long firstReminderMinutes, Long secondReminderMinutes,
126+
String recurrence, Long recurrenceEndTime, Integer calendarId,
127+
String url) {
127128
eventsUri = eventsUri == null ? Uri.parse(CONTENT_PROVIDER_PRE_FROYO + CONTENT_PROVIDER_PATH_EVENTS) : eventsUri;
128129
super.createEvent(eventsUri, title, startTime, endTime, description, location,
129-
firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId);
130+
firstReminderMinutes, secondReminderMinutes, recurrence, recurrenceEndTime, calendarId, url);
130131
}
131132

132133
}

www/Calendar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Calendar.prototype.getCalendarOptions = function () {
5252
recurrenceEndDate: null,
5353
calendarName: null,
5454
calendarId: null,
55+
url: null
5556
};
5657
};
5758

0 commit comments

Comments
 (0)