Skip to content

Commit

Permalink
feat(android): add defaultCalendar to Ti.Calendar (#13219)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Apr 12, 2022
1 parent cffee52 commit 0d20ec0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ public CalendarProxy[] getSelectableCalendars()
return calendars.toArray(new CalendarProxy[0]);
}

@Kroll.getProperty
public CalendarProxy getDefaultCalendar()
{
ArrayList<CalendarProxy> calendars;
calendars = CalendarProxy.queryCalendars("Calendars.isPrimary = ?", new String[] { "1" });
if (calendars.size() > 0) {
return calendars.get(0);
} else {
return null;
}
}

@Kroll.method
public CalendarProxy getCalendarById(int id)
{
Expand Down
6 changes: 5 additions & 1 deletion apidoc/Titanium/Calendar/Calendar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,13 @@ properties:
- name: defaultCalendar
summary: |
Calendar that events are added to by default, as specified by user settings.
description: |
Will return the default calendar of your phone. On Android it will return the first primary
calendar in case you have multiple accounts on your phone.
type: Titanium.Calendar.Calendar
permission: read-only
platforms: [iphone, ipad, macos]
platforms: [android, iphone, ipad, macos]
since: {android: "10.2.0", iphone: "3.1.0", ipad: "3.1.0"}

examples:
- title: All Calendars vs Selectable Calendars
Expand Down

0 comments on commit 0d20ec0

Please sign in to comment.