Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Calendars Read-Only API #1010

Merged

Conversation

builttoroamteam
Copy link

@builttoroamteam builttoroamteam commented Dec 5, 2019

Calendars Read-Only API

Calendars API for reading calendar/event information seamlessly across uwp, iOS and Android
(Issue #996)

API

Calendars

Methods

API Description
Task<IEnumerable<Calendar>> GetCalendarsAsync() Retrieve all calendars for device
Task<IEnumerable<CalendarEvent>> GetEventsAsync( string calendarId = null, DateTimeOffset? startDate = null, DateTimeOffset? endDate = null) Retrieve all events for a specified range/calendar. Null values for parameters will result in default values being used: null calendarId will return events from all calendares, startDate will default to the Now, endDate will default to startDate+14 days
Task<CalendarEvent> GetEventByIdAsync(string eventId) Gets more detailed information about a specific event by the event id

Classes

public class Calendar
{
    string Id { get; set; }

    string Name { get; set; }
}

public class CalendarEvent
{
    string Id { get; set; }

    string CalendarId { get; set; }

    string Title { get; set; }

    string Description { get; set; }

    string Location { get; set; }

    bool AllDay { get; set; }

    DateTimeOffset Start { get; set; }

    DateTimeOffset? End { get; set; }

    TimeSpan? Duration { get; set; }

    IEnumerable<DeviceEventAttendee> Attendees { get; set; }
}

public class CalendarEventAttendee
{
    string Name { get; set; }

    string Email { get; set; }
}

Scenarios

  • User wants to see upcoming events.
  • User wants to see who is attending an upcoming event.
  • User wants to know when they will be free.

Platform Compatibility

  • Target Frameworks:
    • iOS: Support on iOS for the API
    • Android: Support on Android for the API
    • UWP: Support on UWP for the API

Backward Compatibility

Contributors

@ScottBTR
@mkieres
@nickrandolph

@msftclas
Copy link

msftclas commented Dec 5, 2019

CLA assistant check
All CLA requirements met.

@VSC-Service-Account

This comment has been minimized.

@nickrandolph
Copy link

@mattleibow / @jamesmontemagno any suggestions on how to fix the failing build - afaik the test cases should be passing but fails during the build. Any assistance and/or feedback would be greatly appreciated.

@jamesmontemagno
Copy link
Collaborator

I am happy with this overall. I think we should pull in @Redth's permissions and merge with some changes that were needed here for calendar and then would be good to go.

@VSC-Service-Account
Copy link

Docs Build status updates of commit a820831:

✅ Validation status: passed

File Status Preview URL Details
DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml ✅Succeeded
DeviceTests/DeviceTests.Shared/Calendar_Tests.cs ✅Succeeded
DeviceTests/DeviceTests.UWP/Package.appxmanifest ✅Succeeded
DeviceTests/DeviceTests.iOS/Info.plist ✅Succeeded
Samples/Samples.Android/Properties/AndroidManifest.xml ✅Succeeded
Samples/Samples.UWP/Package.appxmanifest ✅Succeeded
Samples/Samples.iOS/Info.plist ✅Succeeded
Samples/Samples.iOS/Samples.iOS.csproj ✅Succeeded
Samples/Samples/App.xaml ✅Succeeded
Samples/Samples/Behaviors/BehaviorBase.cs ✅Succeeded
Samples/Samples/Behaviors/EventToCommandBehaviour.cs ✅Succeeded
Samples/Samples/Converters/CheckBoxEventArgsConverter.cs ✅Succeeded
Samples/Samples/Converters/DateSelectedEventArgsConverter.cs ✅Succeeded
Samples/Samples/Converters/TimeSelectedEventArgsConverter.cs ✅Succeeded
Samples/Samples/Samples.csproj ✅Succeeded
Samples/Samples/View/AppInfoPage.xaml ✅Succeeded
Samples/Samples/View/CalendarEventPage.xaml ✅Succeeded
Samples/Samples/View/CalendarEventPage.xaml.cs ✅Succeeded
Samples/Samples/View/CalendarPage.xaml ✅Succeeded
Samples/Samples/View/CalendarPage.xaml.cs ✅Succeeded
Samples/Samples/ViewModel/CalendarViewModel.cs ✅Succeeded
Samples/Samples/ViewModel/HomeViewModel.cs ✅Succeeded
Tests/Calendar_Tests.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.android.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.ios.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.netstandard.tvos.watchos.tizen.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.shared.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.uwp.cs ✅Succeeded
Xamarin.Essentials/Calendar/CalendarRequest.ios.cs ✅Succeeded
Xamarin.Essentials/Calendar/CalendarRequest.uwp.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.android.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.ios.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.shared.enums.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.uwp.cs ✅Succeeded
Xamarin.Essentials/Types/AttendeeDetails.android.cs ✅Succeeded
Xamarin.Essentials/Types/AttendeeDetails.ios.cs ✅Succeeded
Xamarin.Essentials/Types/DeviceCalendar.shared.cs ✅Succeeded
Xamarin.Essentials/Types/PlatformExtensions/CalendarExtensions.ios.cs ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@jamesmontemagno
Copy link
Collaborator

My main thoughts are on naming...

  • DeviceEvent -> I would choose DeviceCalendarEvent or just CalendarEvent
    *DeviceEventAttendee -> Same... DeviceCalendarEventAttendee or just CalendarEventAttendee

I understand not using just "Calendar" as that is the class name to access things, however you could make it "Calendars" for the class? lol and have "Calendar" :)

@jamesmontemagno
Copy link
Collaborator

I wouldn't worry about the android test failing it is something with the build server.

@VSC-Service-Account
Copy link

Docs Build status updates of commit a4958d9:

✅ Validation status: passed

File Status Preview URL Details
DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml ✅Succeeded
DeviceTests/DeviceTests.Shared/Calendar_Tests.cs ✅Succeeded
DeviceTests/DeviceTests.UWP/Package.appxmanifest ✅Succeeded
DeviceTests/DeviceTests.iOS/Info.plist ✅Succeeded
Samples/Samples.Android/Properties/AndroidManifest.xml ✅Succeeded
Samples/Samples.UWP/Package.appxmanifest ✅Succeeded
Samples/Samples.iOS/Info.plist ✅Succeeded
Samples/Samples.iOS/Samples.iOS.csproj ✅Succeeded
Samples/Samples/App.xaml ✅Succeeded
Samples/Samples/Behaviors/BehaviorBase.cs ✅Succeeded
Samples/Samples/Behaviors/EventToCommandBehaviour.cs ✅Succeeded
Samples/Samples/Converters/CheckBoxEventArgsConverter.cs ✅Succeeded
Samples/Samples/Converters/DateSelectedEventArgsConverter.cs ✅Succeeded
Samples/Samples/Converters/TimeSelectedEventArgsConverter.cs ✅Succeeded
Samples/Samples/Samples.csproj ✅Succeeded
Samples/Samples/View/AppInfoPage.xaml ✅Succeeded
Samples/Samples/View/CalendarEventPage.xaml ✅Succeeded
Samples/Samples/View/CalendarEventPage.xaml.cs ✅Succeeded
Samples/Samples/View/CalendarPage.xaml ✅Succeeded
Samples/Samples/View/CalendarPage.xaml.cs ✅Succeeded
Samples/Samples/ViewModel/CalendarViewModel.cs ✅Succeeded
Samples/Samples/ViewModel/HomeViewModel.cs ✅Succeeded
Tests/Calendar_Tests.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.android.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.ios.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.netstandard.tvos.watchos.tizen.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.shared.cs ✅Succeeded
Xamarin.Essentials/Calendar/Calendar.uwp.cs ✅Succeeded
Xamarin.Essentials/Calendar/CalendarRequest.ios.cs ✅Succeeded
Xamarin.Essentials/Calendar/CalendarRequest.uwp.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.android.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.ios.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.shared.enums.cs ✅Succeeded
Xamarin.Essentials/Permissions/Permissions.uwp.cs ✅Succeeded
Xamarin.Essentials/Types/AttendeeDetails.android.cs ✅Succeeded
Xamarin.Essentials/Types/AttendeeDetails.ios.cs ✅Succeeded
Xamarin.Essentials/Types/DeviceCalendar.shared.cs ✅Succeeded
Xamarin.Essentials/Types/PlatformExtensions/CalendarExtensions.ios.cs ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@nickrandolph
Copy link

@jamesmontemagno we've updated the class names based on your suggestions.
You mentioned pulling in some permissions - do we just need to rebase again off master, or are we waiting on another PR to be completed first?

@Redth Redth changed the base branch from master to dev/calendar December 19, 2019 21:09
@jamesmontemagno
Copy link
Collaborator

@nickrandolph the new permissions are in there. If you want to integrate with the new permissions that would be great!

ScottBTR and others added 2 commits December 25, 2019 08:46
* Calendar Read-Only API

* Return exceptions that match test case System.NotImplementedException --> Xamarin.Essentials.NotImplementedInReferenceAssemblyException (#45)
@nickrandolph
Copy link

@jamesmontemagno / @Redth I've rebased onto the dev/calendar branch and have fixed up the usage for permissions. Let me know what else we need to adjust/work on.
Support for writing calendar events and dealing with recurring events is being worked on and will be submitted early in the new year, so it'd be good to get this PR merged so we only have a single PR related to calendars at a time.

@jamesmontemagno
Copy link
Collaborator

Awesome, that sounds great! Thanks for doing that. It is on the teams list to review and get in :) I am thinking we are doing 1.4.0 pretty soon so may get this in under a feature flag or put in right after to get into an early beta.

@nickrandolph
Copy link

I'd suggest going with the later option of early beta. Not sure how feature flagging would work since the calendar is pretty self contained, so feature flag wouldn't have much effect and just adds work to add/remove the flag.
If we can get it into beta, then we can integrate any feedback as part of adding support for recurring events (which will probably come before write support)

@nickrandolph
Copy link

@jamesmontemagno do you need anything more from us on this PR?

@builttoroamteam builttoroamteam changed the title Calendar Read-Only API Calendars Read-Only API Jan 22, 2020
@ScottBTR
Copy link

ScottBTR commented Jan 23, 2020

Hi @jamesmontemagno,

I've brought some naming convention changes across as listed below:
API - Calendar --> Calendars
Properties - Calendars --> CalendarList
Models:

DeviceCalendar --> Calendar
DeviceEvent --> CalendarEvent
DeviceEventAttendee --> CalendarEventAttendee

Which shouldn't cause any issues.

But I noticed that since the permissions update that uwp was no longer working for the calendars API, this was due to UWP appointments. Not using x:Capability/x:DeviceCapability but instead uap:Capability.

(See: Appointments
https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations?redirectedfrom=MSDN)

Because of this please note the changes I've made to Permissions.uwp.cs, let me know if this poses any problems or requires any changes.

Thanks!

@nickrandolph
Copy link

@jamesmontemagno @Redth this PR is currently targetting the dev/calendar branch which is from back in December. Any chance you can either update that branch or switch this PR to target a more recent branch. We're keen to rebase and test our read-only work before we start pushing the write functionality
We have the write functionality around 90% ready, just want to work out what the road to a merge is!

@nickrandolph
Copy link

@Redth is the plan still to get this merged for the 1.5 release? If so, can you instruct what you need us to do.

@Redth
Copy link
Member

Redth commented Feb 20, 2020

@nickrandolph no it will likely go into a 1.6.0. We had to rush 1.5 preview out to align with Forms’ AndroidX strategy.

@nickrandolph
Copy link

@Redth no probs. We're pretty close to pushing the write functionality. Would you be able to update the target branch for this PR so that we can rebase it? I would actually suggest keeping the target branch as master until you're close to being able to merge it. That way we can rebase and update it as necessary.

@Redth Redth changed the base branch from dev/calendar to develop February 20, 2020 22:15
@Redth
Copy link
Member

Redth commented Feb 20, 2020

@nickrandolph sure, just updated it to target develop (which is as good as master right now).

@jamesmontemagno jamesmontemagno added this to the 1.6.0 milestone Mar 30, 2020
@jamesmontemagno jamesmontemagno added the awaiting-review This PR needs to have a set of eyes on it label Mar 30, 2020
@jamesmontemagno jamesmontemagno changed the base branch from develop to 1.6.0 March 31, 2020 21:11
@jamesmontemagno jamesmontemagno marked this pull request as ready for review March 31, 2020 21:11
@Redth Redth modified the milestones: 1.6.0, 1.7.0 Sep 15, 2020
@mattleibow mattleibow changed the base branch from 1.6.0 to develop September 17, 2020 13:58
@mattleibow mattleibow changed the base branch from develop to dev/calendar September 17, 2020 13:58
@mattleibow mattleibow merged commit c77ae06 into xamarin:dev/calendar Sep 17, 2020
@mattleibow
Copy link
Contributor

Merging this into a local branch for better CI and so we can start the merge on this in #1384 . Looking pretty good so far.

@jamesmontemagno jamesmontemagno removed this from the 1.7.0 milestone Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting-review This PR needs to have a set of eyes on it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants