diff --git a/Calendars.nuspec b/Calendars.nuspec index ebdcdd5..0eac255 100644 --- a/Calendars.nuspec +++ b/Calendars.nuspec @@ -2,7 +2,7 @@ CClarke.Plugin.Calendars - 1.1.0 + 1.2.0-preview11 Calendars API Plugin for Xamarin and Windows Caleb Clarke Caleb Clarke @@ -10,18 +10,22 @@ https://github.com/TheAlmightyBob/Calendars plugin_icon_nuget.png - + false - Perform basic CRUD calendar operations on iOS/Android/UWP through a simple common API. - + Perform basic CRUD calendar operations on iOS/Android/UWP/MAUI through a simple common API. + See project site README for usage notes and limitations. +1.2.0 changes: + +Add .NET MAUI preview 11 support. + 1.1.0 changes: Support for C#8 nullable reference types. - + 1.0.14 changes: Setting Reminders to null in AddOrUpdateEventAsyc now preserves existing/default reminders. @@ -69,5 +73,17 @@ Setting Reminders to null in AddOrUpdateEventAsyc now preserves existing/default + + + + + + + + + + + + diff --git a/Calendars.sln b/Calendars.sln index 4ad3855..5968e23 100644 --- a/Calendars.sln +++ b/Calendars.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2020 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32104.313 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calendars.Plugin.iOSUnified", "Calendars\Calendars.Plugin.iOSUnified\Calendars.Plugin.iOSUnified.csproj", "{2882AEEB-D4CD-4EB9-8A6C-6653B33681F0}" EndProject @@ -26,9 +26,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calendars.Plugin.UWP", "Cal EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calendars.Plugin.UWP.Tests", "Tests\Calendars.Plugin.UWP.Tests\Calendars.Plugin.UWP.Tests.csproj", "{449591A6-F24A-437D-857A-212BEF68E4D2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calendars.Plugin.Abstractions", "Calendars\Calendars.Plugin.Abstractions\Calendars.Plugin.Abstractions.csproj", "{AE8E6FFF-DA18-4ECB-B0B0-ABC527B5DE32}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calendars.Plugin.Abstractions", "Calendars\Calendars.Plugin.Abstractions\Calendars.Plugin.Abstractions.csproj", "{AE8E6FFF-DA18-4ECB-B0B0-ABC527B5DE32}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calendars.Plugin", "Calendars\Calendars.Plugin\Calendars.Plugin.csproj", "{D62199DA-C277-4422-8344-F80886CE3861}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calendars.Plugin", "Calendars\Calendars.Plugin\Calendars.Plugin.csproj", "{D62199DA-C277-4422-8344-F80886CE3861}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calendars.Plugin.MAUI", "Calendars\Calendars.Plugin.MAUI\Calendars.Plugin.MAUI.csproj", "{DE458357-74A5-4BA9-AAFB-828470CECBFF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -564,6 +566,70 @@ Global {D62199DA-C277-4422-8344-F80886CE3861}.Release|x64.Build.0 = Release|Any CPU {D62199DA-C277-4422-8344-F80886CE3861}.Release|x86.ActiveCfg = Release|Any CPU {D62199DA-C277-4422-8344-F80886CE3861}.Release|x86.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|Android.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|Android.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|Mixed Platforms.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|Mixed Platforms.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|Android.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|Android.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|ARM.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|iPhone.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|Mixed Platforms.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|Mixed Platforms.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|x64.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|x64.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|x86.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.AppStore|x86.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|Android.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|Android.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|ARM.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|ARM.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|iPhone.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|x64.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|x64.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|x86.ActiveCfg = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Debug|x86.Build.0 = Debug|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|Android.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|Android.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|Any CPU.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|ARM.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|ARM.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|iPhone.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|iPhone.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|x64.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|x64.Build.0 = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|x86.ActiveCfg = Release|Any CPU + {DE458357-74A5-4BA9-AAFB-828470CECBFF}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Calendars/Calendars.Plugin.Abstractions/CalendarEventReminder.cs b/Calendars/Calendars.Plugin.Abstractions/CalendarEventReminder.cs index 07090fb..7099106 100644 --- a/Calendars/Calendars.Plugin.Abstractions/CalendarEventReminder.cs +++ b/Calendars/Calendars.Plugin.Abstractions/CalendarEventReminder.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Plugin.Calendars.Abstractions { @@ -18,7 +18,7 @@ public class CalendarEventReminder /// public CalendarReminderMethod Method { get; set; } = CalendarReminderMethod.Default; - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) { diff --git a/Calendars/Calendars.Plugin.Android/CalendarsImplementation.cs b/Calendars/Calendars.Plugin.Android/CalendarsImplementation.cs index fab24f0..5aae67a 100644 --- a/Calendars/Calendars.Plugin.Android/CalendarsImplementation.cs +++ b/Calendars/Calendars.Plugin.Android/CalendarsImplementation.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Threading.Tasks; using Calendar = Plugin.Calendars.Abstractions.Calendar; +using Application = Android.App.Application; #nullable enable @@ -34,9 +35,9 @@ public class CalendarsImplementation : ICalendars CalendarContract.Calendars.InterfaceConsts.CalendarAccessLevel, CalendarContract.Calendars.InterfaceConsts.AccountType }; - + #endregion - + #region Properties /// @@ -113,7 +114,7 @@ public Task> GetCalendarsAsync() => Task.Run(() => _calendarsProjection); var calendar = SingleItemFromCursor(cursor, () => GetCalendar(cursor)); - + return calendar; }); } @@ -157,7 +158,7 @@ public async Task> GetEventsAsync(Calendar calendar, DateTi ContentUris.AppendId(eventsUriBuilder, DateConversions.GetDateAsAndroidMS(end)); var eventsUri = eventsUriBuilder?.Build(); - return await Task.Run(() => + return await Task.Run(() => { var cursor = Query(eventsUri, eventsProjection, string.Format("{0} = {1}", CalendarContract.Events.InterfaceConsts.CalendarId, calendar.ExternalID), @@ -416,14 +417,14 @@ public async Task AddEventReminderAsync(CalendarEvent calendarEvent, CalendarEve throw new ArgumentException("Missing calendar event identifier", nameof(calendarEvent)); } - // Verify calendar event exists + // Verify calendar event exists var existingAppt = await GetEventByIdAsync(calendarEvent.ExternalID).ConfigureAwait(false); if (existingAppt == null) { throw new ArgumentException("Specified calendar event not found on device"); } - + await Task.Run(() => { if (IsEventRecurring(calendarEvent.ExternalID)) @@ -456,7 +457,7 @@ public async Task DeleteCalendarAsync(Calendar calendar) throw new ArgumentException("Cannot delete calendar (probably because it's non-local)", nameof(calendar)); } - return await Task.Run(() => Delete(_calendarsUri, long.Parse(calendar.ExternalID))).ConfigureAwait(false); + return await Task.Run(() => Delete(_calendarsUri, long.Parse(calendar.ExternalID ?? String.Empty))).ConfigureAwait(false); } /// @@ -742,7 +743,7 @@ private static Calendar GetCalendar(ICursor cursor) AccountName = cursor.GetString(CalendarContract.Calendars.InterfaceConsts.AccountName) }; } - + private static ICursor Query(Android.Net.Uri? uri, string[] projection, string? selection = null, string[]? selectionArgs = null, string? sortOrder = null) { diff --git a/Calendars/Calendars.Plugin.MAUI/Calendars.Plugin.MAUI.csproj b/Calendars/Calendars.Plugin.MAUI/Calendars.Plugin.MAUI.csproj new file mode 100644 index 0000000..6f70a6a --- /dev/null +++ b/Calendars/Calendars.Plugin.MAUI/Calendars.Plugin.MAUI.csproj @@ -0,0 +1,63 @@ + + + + net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst + $(TargetFrameworks);net6.0-windows10.0.19041 + true + true + enable + False + True + + 14.2 + 14.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Calendars/Calendars.Plugin.iOSUnified/CalendarsImplementation.cs b/Calendars/Calendars.Plugin.iOSUnified/CalendarsImplementation.cs index ee348b5..e2108d2 100644 --- a/Calendars/Calendars.Plugin.iOSUnified/CalendarsImplementation.cs +++ b/Calendars/Calendars.Plugin.iOSUnified/CalendarsImplementation.cs @@ -389,7 +389,7 @@ public async Task DeleteCalendarAsync(Calendar calendar) public async Task DeleteEventAsync(Calendar calendar, CalendarEvent calendarEvent) { // TODO: Remove redundant null check after migrating to .net6 - if (calendar.ExternalID == null || string.IsNullOrEmpty(calendar.ExternalID) + if (calendar.ExternalID == null || string.IsNullOrEmpty(calendar.ExternalID) || calendarEvent.ExternalID == null || string.IsNullOrEmpty(calendarEvent.ExternalID)) { return false; @@ -553,7 +553,7 @@ private async Task RequestCalendarAccess() /// check that there exists at least one calendar for that source. /// d. We do not know if we can save to a calendar source until we actually try to do /// so. Hence the repeated save attempts. - /// + /// /// Full lengthy discussion at https://github.com/TheAlmightyBob/Calendars/issues/10 /// /// The new native calendar. diff --git a/Calendars/Calendars.Plugin/CrossCalendars.cs b/Calendars/Calendars.Plugin/CrossCalendars.cs index a8620f6..af488e8 100644 --- a/Calendars/Calendars.Plugin/CrossCalendars.cs +++ b/Calendars/Calendars.Plugin/CrossCalendars.cs @@ -1,4 +1,4 @@ -using Plugin.Calendars.Abstractions; +using Plugin.Calendars.Abstractions; using System; using System.Threading; @@ -31,7 +31,7 @@ public static ICalendars Current static ICalendars? CreateCalendars() { -#if NETSTANDARD1_0 +#if NETSTANDARD1_0 || (NET && !ANDROID && !IOS && !MACCATALYST && !WINDOWS) return null; #else return new CalendarsImplementation();