@ebarooni/capacitor-calendar 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EbarooniCapacitorCalendar.podspec +1 -1
- package/Package.swift +2 -2
- package/README.md +901 -466
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +57 -7
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +35 -19
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +312 -85
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/CalendarEvent.kt +4 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventDeleteInfo.kt +8 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt +135 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/enums/EventSpan.kt +13 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CheckPermissionInput.kt +0 -4
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateCalendarInput.kt +3 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventWithPromptInput.kt +5 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteCalendarInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventWithPromptInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventsByIdInput.kt +2 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/GetDefaultCalendarInput.kt +9 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyCalendarInput.kt +10 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +3 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +3 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/RequestPermissionInput.kt +3 -5
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CheckAllPermissionsResult.kt +3 -2
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateEventResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateEventWithPromptResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/GetDefaultCalendarResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListCalendarsResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListEventsInRangeResult.kt +4 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/RequestAllPermissionsResult.kt +1 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/templates/PluginCompletion.kt +8 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +468 -39
- package/dist/docs.json +3046 -1048
- package/dist/esm/definitions.d.ts +5 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +71 -48
- package/dist/esm/index.js +17 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-role.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-status.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-type.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.d.ts +9 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.js +9 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.js.map +1 -1
- package/dist/esm/schemas/enums/event-span.d.ts +4 -0
- package/dist/esm/schemas/enums/event-span.js +4 -0
- package/dist/esm/schemas/enums/event-span.js.map +1 -1
- package/dist/esm/schemas/enums/event-status.js.map +1 -1
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.d.ts +5 -5
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js +5 -5
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-event.d.ts +145 -70
- package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-source.d.ts +4 -1
- package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar.d.ts +22 -4
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/schemas/interfaces/check-permission-options.d.ts +19 -0
- package/dist/esm/schemas/interfaces/check-permission-options.js +2 -0
- package/dist/esm/schemas/interfaces/check-permission-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-calendar-options.d.ts +19 -6
- package/dist/esm/schemas/interfaces/create-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-calendar-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/create-calendar-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-calendar-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-options.d.ts +86 -51
- package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-result.d.ts +22 -0
- package/dist/esm/schemas/interfaces/create-event-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-event-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +73 -36
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-with-prompt-result.d.ts +23 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +42 -12
- package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-reminder-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/create-reminder-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminder-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-options.d.ts +46 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.d.ts +1 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +29 -4
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +39 -14
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +16 -4
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-reminder-options.d.ts +10 -0
- package/dist/esm/schemas/interfaces/delete-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-result.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.d.ts +23 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/event-recurrence-rule.d.ts +96 -0
- package/dist/esm/schemas/interfaces/event-recurrence-rule.js +2 -0
- package/dist/esm/schemas/interfaces/event-recurrence-rule.js.map +1 -0
- package/dist/esm/schemas/interfaces/fetch-all-calendar-sources-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/fetch-all-calendar-sources-result.js +2 -0
- package/dist/esm/schemas/interfaces/fetch-all-calendar-sources-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-default-calendar-options.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-default-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/get-default-calendar-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-default-reminders-list-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-default-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-default-reminders-list-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminders-lists-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-reminders-lists-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminders-lists-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-calendars-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/list-calendars-result.js +2 -0
- package/dist/esm/schemas/interfaces/list-calendars-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.d.ts +7 -2
- package/dist/esm/schemas/interfaces/list-events-in-range-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/list-events-in-range-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-result.js +2 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/modify-calendar-options.d.ts +13 -2
- package/dist/esm/schemas/interfaces/modify-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-options.d.ts +61 -44
- package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +77 -2
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +77 -13
- package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/open-calendar-options.d.ts +5 -1
- package/dist/esm/schemas/interfaces/open-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +8 -2
- package/dist/esm/schemas/interfaces/recurrence-rule.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.d.ts +1 -1
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminder.d.ts +4 -1
- package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminders-list.d.ts +8 -2
- package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -1
- package/dist/esm/schemas/interfaces/request-permission-options.d.ts +16 -0
- package/dist/esm/schemas/interfaces/request-permission-options.js +2 -0
- package/dist/esm/schemas/interfaces/request-permission-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.d.ts +1 -1
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-result.d.ts +14 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-result.js +2 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.d.ts +43 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.js.map +1 -0
- package/dist/esm/schemas/types/event-edit-action.d.ts +1 -1
- package/dist/esm/schemas/types/event-edit-action.js.map +1 -1
- package/dist/esm/schemas/types/recurrence-frequency.d.ts +4 -0
- package/dist/esm/schemas/types/recurrence-frequency.js +2 -0
- package/dist/esm/schemas/types/recurrence-frequency.js.map +1 -0
- package/dist/esm/schemas/types/system-color-name.d.ts +6 -0
- package/dist/esm/schemas/types/system-color-name.js +2 -0
- package/dist/esm/schemas/types/system-color-name.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-access.d.ts +26 -14
- package/dist/esm/sub-definitions/calendar-access.js.map +1 -1
- package/dist/esm/sub-definitions/calendar-operations.d.ts +68 -21
- package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
- package/dist/esm/sub-definitions/event-operations.d.ts +46 -25
- package/dist/esm/sub-definitions/event-operations.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-access.d.ts +6 -2
- package/dist/esm/sub-definitions/reminders-access.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-operations.d.ts +78 -43
- package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
- package/dist/esm/web/download-ics-file.d.ts +18 -0
- package/dist/esm/web/download-ics-file.js +33 -0
- package/dist/esm/web/download-ics-file.js.map +1 -0
- package/dist/esm/web/ics.d.ts +27 -0
- package/dist/esm/web/ics.js +294 -0
- package/dist/esm/web/ics.js.map +1 -0
- package/dist/esm/web.d.ts +70 -82
- package/dist/esm/web.js +121 -6
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +464 -35
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +464 -35
- package/dist/plugin.js.map +1 -1
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/CapacitorCalendarPlugin.swift +148 -81
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Implementation/CapacitorCalendar.swift +203 -110
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Models/Enums/EventSpan.swift +8 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateCalendarInput.swift +6 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateEventInput.swift +25 -21
- package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +171 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateReminderInput.swift +14 -4
- package/ios/Plugin/Models/Inputs/CreateRemindersListInput.swift +43 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteCalendarInput.swift +1 -1
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventInput.swift +9 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventWithPromptInput.swift +9 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventsByIdInput.swift +9 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderInput.swift +7 -1
- package/ios/Plugin/Models/Inputs/DeleteRemindersListInput.swift +22 -0
- package/ios/Plugin/Models/Inputs/GetDefaultCalendarInput.swift +13 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyCalendarInput.swift +6 -3
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventInput.swift +63 -41
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyReminderInput.swift +66 -5
- package/ios/Plugin/Models/Inputs/UpdateRemindersListInput.swift +41 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventResult.swift +1 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventWithPromptResult.swift +1 -0
- package/ios/Plugin/Models/Results/CreateRemindersListResult.swift +15 -0
- package/ios/Plugin/Models/Results/ListEventsInRangeResult.swift +29 -0
- package/ios/Plugin/Models/Results/UpdateRemindersListResult.swift +15 -0
- package/ios/Plugin/Models/Structs/RecurrenceInput.swift +41 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginConfig.swift +30 -27
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginError.swift +74 -56
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/ImplementationHelper.swift +140 -24
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/UIColorFromHexExtension.swift +5 -0
- package/package.json +36 -43
- package/dist/esm/schemas/enums/recurrence-frequency.d.ts +0 -21
- package/dist/esm/schemas/enums/recurrence-frequency.js +0 -23
- package/dist/esm/schemas/enums/recurrence-frequency.js.map +0 -1
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateEventWithPromptInput.swift +0 -89
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/ListEventsInRangeResult.swift +0 -16
- package/ios/Tests/CapacitorCalendarPluginTests/CapacitorCalendarPluginTests.swift +0 -15
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CAPPermissionState.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CalendarPermissionScope.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/EventEditAction.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CheckPermissionInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderWithPromptInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteRemindersByIdInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetReminderByIdInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetRemindersFromListsInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ListEventsInRangeInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventWithPromptInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/OpenCalendarInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/RequestPermissionInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/SelectCalendarsWithPromptInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckAllPermissionsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckPermissionResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateCalendarResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateReminderResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventWithPromptResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventsByIdResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteRemindersByIdResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/FetchAllCalendarSourcesResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetDefaultCalendarResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetReminderByIdResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetRemindersFromListsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ListCalendarsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ModifyEventWithPromptResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestAllPermissionsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestPermissionResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/SelectCalendarsWithPromptResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Templates/JSResult.swift +0 -0
|
@@ -8,17 +8,104 @@ import com.getcapacitor.JSArray
|
|
|
8
8
|
import com.getcapacitor.PluginCall
|
|
9
9
|
import dev.barooni.capacitor.calendar.PluginError
|
|
10
10
|
import dev.barooni.capacitor.calendar.models.data.CalendarInfo
|
|
11
|
+
import dev.barooni.capacitor.calendar.models.data.EventDeleteInfo
|
|
11
12
|
import dev.barooni.capacitor.calendar.models.data.EventGuest
|
|
13
|
+
import dev.barooni.capacitor.calendar.models.enums.EventSpan
|
|
12
14
|
import org.json.JSONObject
|
|
13
15
|
import java.util.Calendar
|
|
16
|
+
import java.util.Locale
|
|
17
|
+
import java.util.TimeZone
|
|
14
18
|
|
|
15
19
|
class ImplementationHelper {
|
|
16
20
|
companion object {
|
|
21
|
+
/** Default `CALENDAR_COLOR` when `color` is omitted: `#007AFF`, fully opaque. */
|
|
22
|
+
val DEFAULT_CALENDAR_COLOR: Int = 0xFF007AFF.toInt()
|
|
23
|
+
|
|
17
24
|
fun getCalendarFromTimestamp(timestamp: Long?): Calendar =
|
|
18
25
|
Calendar.getInstance().apply {
|
|
19
26
|
timeInMillis = timestamp ?: System.currentTimeMillis()
|
|
20
27
|
}
|
|
21
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Maps a timestamp to UTC midnight of its local calendar day.
|
|
31
|
+
* Required for [CalendarContract.Events] all-day rows (`EVENT_TIMEZONE` = UTC).
|
|
32
|
+
*/
|
|
33
|
+
fun utcMidnightForLocalDay(timestamp: Long): Long {
|
|
34
|
+
val local = Calendar.getInstance().apply { timeInMillis = timestamp }
|
|
35
|
+
return Calendar
|
|
36
|
+
.getInstance(TimeZone.getTimeZone("UTC"))
|
|
37
|
+
.apply {
|
|
38
|
+
clear()
|
|
39
|
+
set(
|
|
40
|
+
local.get(Calendar.YEAR),
|
|
41
|
+
local.get(Calendar.MONTH),
|
|
42
|
+
local.get(Calendar.DAY_OF_MONTH),
|
|
43
|
+
)
|
|
44
|
+
}.timeInMillis
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Inclusive local-day end → exclusive UTC midnight `DTEND` for all-day rows.
|
|
49
|
+
*/
|
|
50
|
+
fun exclusiveUtcEndForInclusiveLocalDay(timestamp: Long): Long =
|
|
51
|
+
Calendar
|
|
52
|
+
.getInstance(TimeZone.getTimeZone("UTC"))
|
|
53
|
+
.apply {
|
|
54
|
+
timeInMillis = utcMidnightForLocalDay(timestamp)
|
|
55
|
+
add(Calendar.DAY_OF_MONTH, 1)
|
|
56
|
+
}.timeInMillis
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Plugin all-day dates use local calendar days with an inclusive end (same as iOS).
|
|
60
|
+
* [CalendarContract] needs UTC midnight boundaries and an exclusive `DTEND`.
|
|
61
|
+
* When [endDate] is omitted, uses a one-day span from [startDate].
|
|
62
|
+
*/
|
|
63
|
+
fun normalizeAllDayTimes(
|
|
64
|
+
startDate: Long?,
|
|
65
|
+
endDate: Long?,
|
|
66
|
+
): Pair<Long?, Long?> {
|
|
67
|
+
val start = startDate?.let { utcMidnightForLocalDay(it) }
|
|
68
|
+
val exclusiveEnd =
|
|
69
|
+
when {
|
|
70
|
+
endDate != null -> {
|
|
71
|
+
exclusiveUtcEndForInclusiveLocalDay(endDate)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
start != null -> {
|
|
75
|
+
Calendar
|
|
76
|
+
.getInstance(TimeZone.getTimeZone("UTC"))
|
|
77
|
+
.apply {
|
|
78
|
+
timeInMillis = start
|
|
79
|
+
add(Calendar.DAY_OF_MONTH, 1)
|
|
80
|
+
}.timeInMillis
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
else -> {
|
|
84
|
+
null
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return Pair(start, exclusiveEnd)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Reads [CalendarContract.Events.ALL_DAY] for an existing event.
|
|
92
|
+
* Throws [PluginError.EventNotFound] when the row is missing or unreadable,
|
|
93
|
+
* so callers that need the flag cannot silently skip all-day normalization.
|
|
94
|
+
*/
|
|
95
|
+
fun isEventAllDay(
|
|
96
|
+
cr: ContentResolver,
|
|
97
|
+
eventId: Long,
|
|
98
|
+
): Boolean {
|
|
99
|
+
val uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, eventId)
|
|
100
|
+
val projection = arrayOf(CalendarContract.Events.ALL_DAY)
|
|
101
|
+
cr.query(uri, projection, null, null, null)?.use { cursor ->
|
|
102
|
+
if (cursor.moveToFirst()) {
|
|
103
|
+
return cursor.getInt(0) == 1
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw PluginError.EventNotFound
|
|
107
|
+
}
|
|
108
|
+
|
|
22
109
|
fun jsArrayToComaSeparatedString(array: JSArray?): String? {
|
|
23
110
|
val list = array?.toList<Any>() ?: return null
|
|
24
111
|
|
|
@@ -36,17 +123,59 @@ class ImplementationHelper {
|
|
|
36
123
|
|
|
37
124
|
fun jsArrayToLongArray(array: JSArray): List<Long> {
|
|
38
125
|
val list = array.toList<String>()
|
|
39
|
-
return list.map { it.
|
|
126
|
+
return list.map { it.toLongOrNull() ?: throw PluginError.MissingId }
|
|
40
127
|
}
|
|
41
128
|
|
|
42
|
-
fun hexToColorInt(hex: String?): Int?
|
|
129
|
+
fun hexToColorInt(hex: String?): Int? {
|
|
43
130
|
if (hex == null) {
|
|
44
|
-
null
|
|
45
|
-
} else {
|
|
46
|
-
android.graphics.Color.parseColor(hex)
|
|
131
|
+
return null
|
|
47
132
|
}
|
|
48
133
|
|
|
49
|
-
|
|
134
|
+
if (!hex.startsWith("#")) {
|
|
135
|
+
throw PluginError.InvalidColor
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
val digits = hex.substring(1)
|
|
139
|
+
return when (digits.length) {
|
|
140
|
+
6 -> {
|
|
141
|
+
// RRGGBB with fully opaque alpha — Color.parseColor is correct for 6-digit.
|
|
142
|
+
try {
|
|
143
|
+
android.graphics.Color.parseColor(hex)
|
|
144
|
+
} catch (_: IllegalArgumentException) {
|
|
145
|
+
throw PluginError.InvalidColor
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
8 -> {
|
|
150
|
+
// RRGGBBAA (not AARRGGBB). Do not use Color.parseColor for 8-digit.
|
|
151
|
+
try {
|
|
152
|
+
val r = digits.substring(0, 2).toInt(16)
|
|
153
|
+
val g = digits.substring(2, 4).toInt(16)
|
|
154
|
+
val b = digits.substring(4, 6).toInt(16)
|
|
155
|
+
val a = digits.substring(6, 8).toInt(16)
|
|
156
|
+
android.graphics.Color.argb(a, r, g, b)
|
|
157
|
+
} catch (_: NumberFormatException) {
|
|
158
|
+
throw PluginError.InvalidColor
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
else -> {
|
|
163
|
+
throw PluginError.InvalidColor
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
fun intToHexColor(colorInt: Int): String {
|
|
169
|
+
val alpha = android.graphics.Color.alpha(colorInt)
|
|
170
|
+
val red = android.graphics.Color.red(colorInt)
|
|
171
|
+
val green = android.graphics.Color.green(colorInt)
|
|
172
|
+
val blue = android.graphics.Color.blue(colorInt)
|
|
173
|
+
return if (alpha == 0xFF) {
|
|
174
|
+
String.format(Locale.US, "#%02X%02X%02X", red, green, blue)
|
|
175
|
+
} else {
|
|
176
|
+
String.format(Locale.US, "#%02X%02X%02X%02X", red, green, blue, alpha)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
50
179
|
|
|
51
180
|
fun eventGuestsFromCall(call: PluginCall): List<EventGuest>? {
|
|
52
181
|
val attendeesJson = call.getArray("attendees") ?: return null
|
|
@@ -96,11 +225,21 @@ class ImplementationHelper {
|
|
|
96
225
|
cr: ContentResolver,
|
|
97
226
|
alerts: List<Int>,
|
|
98
227
|
) {
|
|
99
|
-
alerts.forEach {
|
|
228
|
+
alerts.forEach { userMinutes ->
|
|
229
|
+
val providerMinutes =
|
|
230
|
+
when {
|
|
231
|
+
userMinutes > 0 -> -kotlin.math.abs(userMinutes)
|
|
232
|
+
|
|
233
|
+
// after start -> store negative
|
|
234
|
+
userMinutes < 0 -> kotlin.math.abs(userMinutes)
|
|
235
|
+
|
|
236
|
+
// before start -> store positive
|
|
237
|
+
else -> 0
|
|
238
|
+
}
|
|
100
239
|
val alertValues =
|
|
101
240
|
ContentValues().apply {
|
|
102
241
|
put(CalendarContract.Reminders.EVENT_ID, eventId)
|
|
103
|
-
put(CalendarContract.Reminders.MINUTES,
|
|
242
|
+
put(CalendarContract.Reminders.MINUTES, providerMinutes)
|
|
104
243
|
put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT)
|
|
105
244
|
}
|
|
106
245
|
cr.insert(CalendarContract.Reminders.CONTENT_URI, alertValues)
|
|
@@ -118,35 +257,27 @@ class ImplementationHelper {
|
|
|
118
257
|
)
|
|
119
258
|
}
|
|
120
259
|
|
|
121
|
-
fun
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var fallbackCalendarId: Long? = null
|
|
130
|
-
cr.query(uri, projection, null, null, null)?.use { cursor ->
|
|
131
|
-
if (cursor.count == 0) {
|
|
132
|
-
throw PluginError.NoCalendarsAvailable
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
while (cursor.moveToNext()) {
|
|
136
|
-
val id = cursor.getLong(cursor.getColumnIndexOrThrow(CalendarContract.Calendars._ID))
|
|
137
|
-
val isPrimary = cursor.getInt(cursor.getColumnIndexOrThrow(CalendarContract.Calendars.IS_PRIMARY)) == 1
|
|
138
|
-
|
|
139
|
-
if (isPrimary) {
|
|
140
|
-
return id
|
|
141
|
-
}
|
|
260
|
+
fun resolveDefaultCalendar(
|
|
261
|
+
calendars: List<CalendarInfo>,
|
|
262
|
+
useFallbackCalendar: Boolean,
|
|
263
|
+
): CalendarInfo? {
|
|
264
|
+
if (calendars.isEmpty()) {
|
|
265
|
+
return null
|
|
266
|
+
}
|
|
142
267
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
268
|
+
val primary = calendars.find { it.isPrimary == true }
|
|
269
|
+
if (primary != null) {
|
|
270
|
+
return primary
|
|
147
271
|
}
|
|
148
272
|
|
|
149
|
-
return
|
|
273
|
+
return if (useFallbackCalendar) calendars.first() else null
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
fun getDefaultCalendarId(cr: ContentResolver): Long {
|
|
277
|
+
val calendar =
|
|
278
|
+
resolveDefaultCalendar(listCalendars(cr), useFallbackCalendar = true)
|
|
279
|
+
?: throw PluginError.NoCalendarsAvailable
|
|
280
|
+
return calendar.id.toLong()
|
|
150
281
|
}
|
|
151
282
|
|
|
152
283
|
fun listCalendars(cr: ContentResolver): List<CalendarInfo> {
|
|
@@ -262,13 +393,277 @@ class ImplementationHelper {
|
|
|
262
393
|
return calendars
|
|
263
394
|
}
|
|
264
395
|
|
|
396
|
+
fun requiresInstanceDateForDelete(
|
|
397
|
+
cr: ContentResolver,
|
|
398
|
+
eventId: Long,
|
|
399
|
+
span: EventSpan,
|
|
400
|
+
): Boolean = needsInstanceDate(queryEventDeleteInfo(cr, eventId), span)
|
|
401
|
+
|
|
402
|
+
fun ensureInstanceDatePresentIfRequired(
|
|
403
|
+
cr: ContentResolver,
|
|
404
|
+
eventId: Long,
|
|
405
|
+
span: EventSpan,
|
|
406
|
+
instanceDate: Long?,
|
|
407
|
+
) {
|
|
408
|
+
if (requiresInstanceDateForDelete(cr, eventId, span) && instanceDate == null) {
|
|
409
|
+
throw PluginError.InstanceDateMissing
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
265
413
|
fun deleteEvent(
|
|
266
414
|
cr: ContentResolver,
|
|
267
415
|
eventId: Long,
|
|
416
|
+
span: EventSpan,
|
|
417
|
+
instanceDate: Long? = null,
|
|
268
418
|
): Boolean {
|
|
269
|
-
val
|
|
270
|
-
val
|
|
271
|
-
|
|
419
|
+
val info = queryEventDeleteInfo(cr, eventId)
|
|
420
|
+
val masterId = info.originalId ?: eventId
|
|
421
|
+
val isException = info.originalId != null
|
|
422
|
+
val isRecurringMaster = !info.rrule.isNullOrBlank() && !isException
|
|
423
|
+
|
|
424
|
+
return when (span) {
|
|
425
|
+
EventSpan.THIS_EVENT -> {
|
|
426
|
+
when {
|
|
427
|
+
isException -> {
|
|
428
|
+
deleteEventRow(cr, eventId)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
isRecurringMaster -> {
|
|
432
|
+
val date = instanceDate ?: throw PluginError.InstanceDateMissing
|
|
433
|
+
insertCanceledException(cr, masterId, date)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
else -> {
|
|
437
|
+
deleteEventRow(cr, eventId)
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
EventSpan.THIS_AND_FUTURE_EVENTS -> {
|
|
443
|
+
when {
|
|
444
|
+
isRecurringMaster -> {
|
|
445
|
+
// No instanceDate → treat as deleting from series start (whole series).
|
|
446
|
+
if (instanceDate == null) {
|
|
447
|
+
deleteEventRow(cr, masterId)
|
|
448
|
+
} else {
|
|
449
|
+
deleteThisAndFuture(cr, masterId, instanceDate)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
isException -> {
|
|
454
|
+
val date =
|
|
455
|
+
instanceDate
|
|
456
|
+
?: info.originalInstanceTime
|
|
457
|
+
?: throw PluginError.InstanceDateMissing
|
|
458
|
+
deleteThisAndFuture(cr, masterId, date)
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
else -> {
|
|
462
|
+
deleteEventRow(cr, eventId)
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
private fun needsInstanceDate(
|
|
470
|
+
info: EventDeleteInfo,
|
|
471
|
+
span: EventSpan,
|
|
472
|
+
): Boolean {
|
|
473
|
+
val isException = info.originalId != null
|
|
474
|
+
val isRecurringMaster = !info.rrule.isNullOrBlank() && !isException
|
|
475
|
+
return when (span) {
|
|
476
|
+
// Only occurrence cancel on a series master needs an explicit instance time.
|
|
477
|
+
EventSpan.THIS_EVENT -> isRecurringMaster
|
|
478
|
+
|
|
479
|
+
// Masters fall back to whole-series delete; exceptions fall back to ORIGINAL_INSTANCE_TIME.
|
|
480
|
+
EventSpan.THIS_AND_FUTURE_EVENTS -> isException && info.originalInstanceTime == null
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
private fun deleteEventRow(
|
|
485
|
+
cr: ContentResolver,
|
|
486
|
+
eventId: Long,
|
|
487
|
+
): Boolean {
|
|
488
|
+
val uri =
|
|
489
|
+
ContentUris.withAppendedId(
|
|
490
|
+
CalendarContract.Events.CONTENT_URI,
|
|
491
|
+
eventId,
|
|
492
|
+
)
|
|
493
|
+
return cr.delete(uri, null, null) > 0
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
private fun insertCanceledException(
|
|
497
|
+
cr: ContentResolver,
|
|
498
|
+
masterId: Long,
|
|
499
|
+
instanceDate: Long,
|
|
500
|
+
): Boolean {
|
|
501
|
+
val values =
|
|
502
|
+
ContentValues().apply {
|
|
503
|
+
put(CalendarContract.Events.ORIGINAL_INSTANCE_TIME, instanceDate)
|
|
504
|
+
put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CANCELED)
|
|
505
|
+
}
|
|
506
|
+
val uri =
|
|
507
|
+
ContentUris.withAppendedId(
|
|
508
|
+
CalendarContract.Events.CONTENT_EXCEPTION_URI,
|
|
509
|
+
masterId,
|
|
510
|
+
)
|
|
511
|
+
return cr.insert(uri, values) != null
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
private fun deleteThisAndFuture(
|
|
515
|
+
cr: ContentResolver,
|
|
516
|
+
masterId: Long,
|
|
517
|
+
instanceDate: Long,
|
|
518
|
+
): Boolean {
|
|
519
|
+
val info = queryEventDeleteInfo(cr, masterId)
|
|
520
|
+
val rrule = info.rrule
|
|
521
|
+
if (rrule.isNullOrBlank()) {
|
|
522
|
+
return false
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Targeting the first occurrence (or earlier) removes the whole series.
|
|
526
|
+
val seriesStart = info.dtStart
|
|
527
|
+
if (seriesStart != null && instanceDate <= seriesStart) {
|
|
528
|
+
return deleteEventRow(cr, masterId)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
val values =
|
|
532
|
+
ContentValues().apply {
|
|
533
|
+
put(CalendarContract.Events.RRULE, rruleEndingBefore(rrule, instanceDate))
|
|
534
|
+
}
|
|
535
|
+
val uri =
|
|
536
|
+
ContentUris.withAppendedId(
|
|
537
|
+
CalendarContract.Events.CONTENT_URI,
|
|
538
|
+
masterId,
|
|
539
|
+
)
|
|
540
|
+
return cr.update(uri, values, null, null) > 0
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private fun rruleEndingBefore(
|
|
544
|
+
rrule: String,
|
|
545
|
+
instanceDateMs: Long,
|
|
546
|
+
): String {
|
|
547
|
+
// UNTIL is inclusive; end the series one second before this occurrence.
|
|
548
|
+
val untilMs = instanceDateMs - 1000L
|
|
549
|
+
val untilPart = "UNTIL=${formatUntilUtc(untilMs)}"
|
|
550
|
+
val parts =
|
|
551
|
+
rrule
|
|
552
|
+
.split(";")
|
|
553
|
+
.filter { part ->
|
|
554
|
+
val key = part.substringBefore("=").uppercase()
|
|
555
|
+
key.isNotEmpty() && key != "UNTIL" && key != "COUNT"
|
|
556
|
+
}.toMutableList()
|
|
557
|
+
parts.add(untilPart)
|
|
558
|
+
return parts.joinToString(";")
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
private fun formatUntilUtc(untilMs: Long): String {
|
|
562
|
+
val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"))
|
|
563
|
+
calendar.timeInMillis = untilMs
|
|
564
|
+
|
|
565
|
+
val year = calendar.get(Calendar.YEAR)
|
|
566
|
+
val month = calendar.get(Calendar.MONTH) + 1
|
|
567
|
+
val day = calendar.get(Calendar.DAY_OF_MONTH)
|
|
568
|
+
val hour = calendar.get(Calendar.HOUR_OF_DAY)
|
|
569
|
+
val minute = calendar.get(Calendar.MINUTE)
|
|
570
|
+
val second = calendar.get(Calendar.SECOND)
|
|
571
|
+
|
|
572
|
+
return String.format(
|
|
573
|
+
Locale.US,
|
|
574
|
+
"%04d%02d%02dT%02d%02d%02dZ",
|
|
575
|
+
year,
|
|
576
|
+
month,
|
|
577
|
+
day,
|
|
578
|
+
hour,
|
|
579
|
+
minute,
|
|
580
|
+
second,
|
|
581
|
+
)
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
private fun queryEventDeleteInfo(
|
|
585
|
+
cr: ContentResolver,
|
|
586
|
+
eventId: Long,
|
|
587
|
+
): EventDeleteInfo {
|
|
588
|
+
val uri =
|
|
589
|
+
ContentUris.withAppendedId(
|
|
590
|
+
CalendarContract.Events.CONTENT_URI,
|
|
591
|
+
eventId,
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
val projection =
|
|
595
|
+
arrayOf(
|
|
596
|
+
CalendarContract.Events.DTSTART,
|
|
597
|
+
CalendarContract.Events.ORIGINAL_ID,
|
|
598
|
+
CalendarContract.Events.ORIGINAL_INSTANCE_TIME,
|
|
599
|
+
CalendarContract.Events.RRULE,
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
cr
|
|
603
|
+
.query(
|
|
604
|
+
uri,
|
|
605
|
+
projection,
|
|
606
|
+
null,
|
|
607
|
+
null,
|
|
608
|
+
null,
|
|
609
|
+
)?.use { cursor ->
|
|
610
|
+
if (!cursor.moveToFirst()) {
|
|
611
|
+
return EventDeleteInfo(
|
|
612
|
+
dtStart = null,
|
|
613
|
+
originalId = null,
|
|
614
|
+
originalInstanceTime = null,
|
|
615
|
+
rrule = null,
|
|
616
|
+
)
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
val dtStartIndex = cursor.getColumnIndex(CalendarContract.Events.DTSTART)
|
|
620
|
+
val originalIdIndex = cursor.getColumnIndex(CalendarContract.Events.ORIGINAL_ID)
|
|
621
|
+
val originalInstanceTimeIndex =
|
|
622
|
+
cursor.getColumnIndex(CalendarContract.Events.ORIGINAL_INSTANCE_TIME)
|
|
623
|
+
val rruleIndex = cursor.getColumnIndex(CalendarContract.Events.RRULE)
|
|
624
|
+
|
|
625
|
+
val dtStart =
|
|
626
|
+
if (dtStartIndex >= 0 && !cursor.isNull(dtStartIndex)) {
|
|
627
|
+
cursor.getLong(dtStartIndex)
|
|
628
|
+
} else {
|
|
629
|
+
null
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
val originalId =
|
|
633
|
+
if (originalIdIndex >= 0 && !cursor.isNull(originalIdIndex)) {
|
|
634
|
+
cursor.getLong(originalIdIndex)
|
|
635
|
+
} else {
|
|
636
|
+
null
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
val originalInstanceTime =
|
|
640
|
+
if (originalInstanceTimeIndex >= 0 && !cursor.isNull(originalInstanceTimeIndex)) {
|
|
641
|
+
cursor.getLong(originalInstanceTimeIndex)
|
|
642
|
+
} else {
|
|
643
|
+
null
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
val rrule =
|
|
647
|
+
if (rruleIndex >= 0 && !cursor.isNull(rruleIndex)) {
|
|
648
|
+
cursor.getString(rruleIndex)
|
|
649
|
+
} else {
|
|
650
|
+
null
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
return EventDeleteInfo(
|
|
654
|
+
dtStart = dtStart,
|
|
655
|
+
originalId = originalId,
|
|
656
|
+
originalInstanceTime = originalInstanceTime,
|
|
657
|
+
rrule = rrule,
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
return EventDeleteInfo(
|
|
662
|
+
dtStart = null,
|
|
663
|
+
originalId = null,
|
|
664
|
+
originalInstanceTime = null,
|
|
665
|
+
rrule = null,
|
|
666
|
+
)
|
|
272
667
|
}
|
|
273
668
|
|
|
274
669
|
fun getEventAlerts(
|
|
@@ -286,8 +681,16 @@ class ImplementationHelper {
|
|
|
286
681
|
|
|
287
682
|
cursor?.use {
|
|
288
683
|
while (it.moveToNext()) {
|
|
289
|
-
val
|
|
290
|
-
|
|
684
|
+
val providerMinutes = it.getInt(it.getColumnIndexOrThrow(CalendarContract.Reminders.MINUTES))
|
|
685
|
+
|
|
686
|
+
val userMinutes =
|
|
687
|
+
if (providerMinutes >= 0) {
|
|
688
|
+
-kotlin.math.abs(providerMinutes)
|
|
689
|
+
} else {
|
|
690
|
+
kotlin.math.abs(providerMinutes)
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
alerts.add(userMinutes)
|
|
291
694
|
}
|
|
292
695
|
}
|
|
293
696
|
|
|
@@ -347,6 +750,32 @@ class ImplementationHelper {
|
|
|
347
750
|
return attendees
|
|
348
751
|
}
|
|
349
752
|
|
|
753
|
+
fun buildDurationFromBeginEnd(
|
|
754
|
+
begin: Long,
|
|
755
|
+
end: Long,
|
|
756
|
+
isAllDay: Boolean,
|
|
757
|
+
): String {
|
|
758
|
+
val diffMs = (end - begin).coerceAtLeast(0)
|
|
759
|
+
|
|
760
|
+
return if (isAllDay) {
|
|
761
|
+
val days = (diffMs / (24 * 60 * 60 * 1000)).coerceAtLeast(1)
|
|
762
|
+
"P${days}D"
|
|
763
|
+
} else {
|
|
764
|
+
val totalSeconds = (diffMs / 1000).coerceAtLeast(1)
|
|
765
|
+
val hours = totalSeconds / 3600
|
|
766
|
+
val minutes = (totalSeconds % 3600) / 60
|
|
767
|
+
val seconds = totalSeconds % 60
|
|
768
|
+
|
|
769
|
+
buildString {
|
|
770
|
+
append("PT")
|
|
771
|
+
if (hours > 0) append("${hours}H")
|
|
772
|
+
if (minutes > 0) append("${minutes}M")
|
|
773
|
+
if (seconds > 0) append("${seconds}S")
|
|
774
|
+
if (hours == 0L && minutes == 0L && seconds == 0L) append("1S")
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
350
779
|
fun mapAttendeeRelationship(relationship: Int): String =
|
|
351
780
|
when (relationship) {
|
|
352
781
|
CalendarContract.Attendees.RELATIONSHIP_ATTENDEE -> "attendee"
|