Skip to content

Commit

Permalink
#165 Add URL - now for Android as well
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Apr 16, 2015
1 parent a2b4e66 commit f787db5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<name>Calendar</name>

Expand Down
3 changes: 2 additions & 1 deletion src/android/nl/xservices/plugins/Calendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
1 change: 1 addition & 0 deletions www/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Calendar.prototype.getCalendarOptions = function () {
recurrenceEndDate: null,
calendarName: null,
calendarId: null,
url: null
};
};

Expand Down

0 comments on commit f787db5

Please sign in to comment.