@ebarooni/capacitor-calendar 7.1.0 → 8.0.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 +2 -2
- package/Package.swift +4 -4
- package/README.md +238 -162
- package/android/build.gradle +20 -18
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +17 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +2 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +105 -61
- 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/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/ModifyCalendarInput.kt +13 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +2 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +3 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +48 -4
- package/dist/docs.json +792 -330
- package/dist/esm/definitions.d.ts +5 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +47 -45
- package/dist/esm/index.js +16 -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.js.map +1 -1
- package/dist/esm/schemas/enums/event-status.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-event.d.ts +7 -5
- package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-source.d.ts +1 -1
- package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar.d.ts +2 -2
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-options.d.ts +63 -46
- package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +42 -31
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +10 -1
- package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +1 -1
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +1 -1
- 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 +1 -1
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.d.ts +35 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-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/modify-calendar-options.d.ts +21 -0
- package/dist/esm/schemas/interfaces/modify-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/modify-calendar-options.js.map +1 -0
- 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 +1 -1
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +12 -1
- package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +1 -1
- 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 +1 -1
- package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminders-list.d.ts +2 -2
- package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -1
- 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/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/sub-definitions/calendar-access.d.ts +4 -4
- package/dist/esm/sub-definitions/calendar-access.js.map +1 -1
- package/dist/esm/sub-definitions/calendar-operations.d.ts +14 -6
- package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
- package/dist/esm/sub-definitions/event-operations.d.ts +10 -10
- package/dist/esm/sub-definitions/event-operations.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-access.d.ts +1 -1
- package/dist/esm/sub-definitions/reminders-access.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-operations.d.ts +19 -9
- package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
- package/dist/esm/web.d.ts +37 -30
- package/dist/esm/web.js +7 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +7 -24
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +7 -24
- package/dist/plugin.js.map +1 -1
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/CapacitorCalendarPlugin.swift +110 -65
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Implementation/CapacitorCalendar.swift +83 -59
- package/ios/Plugin/Info.plist +24 -0
- 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 +2 -2
- package/ios/Plugin/Models/Inputs/DeleteReminderWithPromptInput.swift +46 -0
- package/ios/Plugin/Models/Inputs/ModifyCalendarInput.swift +32 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventInput.swift +63 -41
- package/ios/Plugin/Models/Structs/RecurrenceInput.swift +31 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginConfig.swift +3 -1
- package/package.json +37 -45
- 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/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/CreateCalendarInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteCalendarInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventWithPromptInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventsByIdInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderInput.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/ModifyReminderInput.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/CreateEventResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventWithPromptResult.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/ListEventsInRangeResult.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
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginError.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/ImplementationHelper.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/UIColorFromHexExtension.swift +0 -0
package/android/build.gradle
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
6
|
coreKtxVersion = project.hasProperty('coreKtxVersion') ? rootProject.ext.coreKtxVersion : '1.15.0'
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
buildscript {
|
|
10
|
-
ext
|
|
11
|
-
kotlin_version = '1.9.25'
|
|
12
|
-
}
|
|
10
|
+
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
|
|
13
11
|
repositories {
|
|
14
12
|
google()
|
|
15
13
|
mavenCentral()
|
|
16
14
|
}
|
|
17
15
|
dependencies {
|
|
18
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
16
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
17
|
+
classpath 'com.google.gms:google-services:4.4.4'
|
|
19
18
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
apply plugin: 'com.android.library'
|
|
24
23
|
apply plugin: 'org.jetbrains.kotlin.android'
|
|
24
|
+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
25
25
|
|
|
26
26
|
android {
|
|
27
|
-
namespace "dev.barooni.capacitor.calendar"
|
|
28
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
27
|
+
namespace = "dev.barooni.capacitor.calendar"
|
|
28
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
29
29
|
defaultConfig {
|
|
30
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
31
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
32
|
-
versionCode 1
|
|
33
|
-
versionName "1.0"
|
|
34
|
-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
30
|
+
minSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
31
|
+
targetSdkVersion = project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
32
|
+
versionCode = 1
|
|
33
|
+
versionName = "1.0"
|
|
34
|
+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
35
35
|
}
|
|
36
36
|
buildTypes {
|
|
37
37
|
release {
|
|
38
|
-
minifyEnabled false
|
|
38
|
+
minifyEnabled = false
|
|
39
39
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
lintOptions {
|
|
43
|
-
abortOnError false
|
|
43
|
+
abortOnError = false
|
|
44
44
|
}
|
|
45
45
|
compileOptions {
|
|
46
46
|
sourceCompatibility JavaVersion.VERSION_21
|
|
47
47
|
targetCompatibility JavaVersion.VERSION_21
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
kotlin {
|
|
50
|
+
compilerOptions {
|
|
51
|
+
jvmTarget = JvmTarget.JVM_21
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -20,6 +20,7 @@ import dev.barooni.capacitor.calendar.models.inputs.DeleteEventInput
|
|
|
20
20
|
import dev.barooni.capacitor.calendar.models.inputs.DeleteEventWithPromptInput
|
|
21
21
|
import dev.barooni.capacitor.calendar.models.inputs.DeleteEventsByIdInput
|
|
22
22
|
import dev.barooni.capacitor.calendar.models.inputs.ListEventsInRangeInput
|
|
23
|
+
import dev.barooni.capacitor.calendar.models.inputs.ModifyCalendarInput
|
|
23
24
|
import dev.barooni.capacitor.calendar.models.inputs.ModifyEvent
|
|
24
25
|
import dev.barooni.capacitor.calendar.models.inputs.ModifyEventWithPromptInput
|
|
25
26
|
import dev.barooni.capacitor.calendar.models.inputs.OpenCalendarInput
|
|
@@ -423,4 +424,20 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
423
424
|
call.reject(error.message)
|
|
424
425
|
}
|
|
425
426
|
}
|
|
427
|
+
|
|
428
|
+
@PluginMethod
|
|
429
|
+
fun modifyCalendar(call: PluginCall) {
|
|
430
|
+
try {
|
|
431
|
+
val input = ModifyCalendarInput(call)
|
|
432
|
+
implementation.modifyCalendar(input)
|
|
433
|
+
call.resolve()
|
|
434
|
+
} catch (error: Exception) {
|
|
435
|
+
call.reject(error.message)
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
@PluginMethod
|
|
440
|
+
fun deleteReminderWithPrompt(call: PluginCall) {
|
|
441
|
+
call.unimplemented(PluginError.Unimplemented(::deleteReminderWithPrompt.name).message)
|
|
442
|
+
}
|
|
426
443
|
}
|
|
@@ -37,6 +37,8 @@ sealed class PluginError(
|
|
|
37
37
|
|
|
38
38
|
data object ToDateMissing : PluginError("To date must be provided.")
|
|
39
39
|
|
|
40
|
+
data object FailedToModify : PluginError("Failed to modify.")
|
|
41
|
+
|
|
40
42
|
data class Unimplemented(
|
|
41
43
|
val methodName: String,
|
|
42
44
|
) : PluginError("$methodName is not implemented on Android.")
|
package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt
CHANGED
|
@@ -21,6 +21,7 @@ import dev.barooni.capacitor.calendar.models.inputs.DeleteEventInput
|
|
|
21
21
|
import dev.barooni.capacitor.calendar.models.inputs.DeleteEventWithPromptInput
|
|
22
22
|
import dev.barooni.capacitor.calendar.models.inputs.DeleteEventsByIdInput
|
|
23
23
|
import dev.barooni.capacitor.calendar.models.inputs.ListEventsInRangeInput
|
|
24
|
+
import dev.barooni.capacitor.calendar.models.inputs.ModifyCalendarInput
|
|
24
25
|
import dev.barooni.capacitor.calendar.models.inputs.ModifyEvent
|
|
25
26
|
import dev.barooni.capacitor.calendar.models.inputs.ModifyEventWithPromptInput
|
|
26
27
|
import dev.barooni.capacitor.calendar.models.inputs.OpenCalendarInput
|
|
@@ -99,6 +100,7 @@ class CapacitorCalendar(
|
|
|
99
100
|
input.organizer?.let { put(CalendarContract.Events.ORGANIZER, it) }
|
|
100
101
|
input.duration?.let { put(CalendarContract.Events.DURATION, it) }
|
|
101
102
|
input.color?.let { put(CalendarContract.Events.EVENT_COLOR, it) }
|
|
103
|
+
input.recurrence?.let { put(CalendarContract.Events.RRULE, it.toRRule()) }
|
|
102
104
|
}
|
|
103
105
|
val uri: Uri? = cr.insert(CalendarContract.Events.CONTENT_URI, values)
|
|
104
106
|
val eventId: Long = uri?.lastPathSegment?.toLong() ?: throw PluginError.FailedToRetrieveEventId
|
|
@@ -122,6 +124,7 @@ class CapacitorCalendar(
|
|
|
122
124
|
input.organizer?.let { put(CalendarContract.Events.ORGANIZER, it) }
|
|
123
125
|
input.color?.let { put(CalendarContract.Events.EVENT_COLOR, it) }
|
|
124
126
|
input.duration?.let { put(CalendarContract.Events.DURATION, it) }
|
|
127
|
+
input.recurrence?.let { put(CalendarContract.Events.RRULE, it.toRRule()) }
|
|
125
128
|
}
|
|
126
129
|
val uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, input.id)
|
|
127
130
|
cr.update(uri, values, null, null)
|
|
@@ -242,82 +245,109 @@ class CapacitorCalendar(
|
|
|
242
245
|
fun listEventsInRange(input: ListEventsInRangeInput): ListEventsInRangeResult {
|
|
243
246
|
val cr = plugin.context.contentResolver
|
|
244
247
|
val events = mutableListOf<CalendarEvent>()
|
|
245
|
-
|
|
248
|
+
|
|
249
|
+
val builder: Uri.Builder = CalendarContract.Instances.CONTENT_URI.buildUpon()
|
|
250
|
+
ContentUris.appendId(builder, input.from)
|
|
251
|
+
ContentUris.appendId(builder, input.to)
|
|
252
|
+
val uri: Uri = builder.build()
|
|
253
|
+
|
|
246
254
|
val projection =
|
|
247
255
|
arrayOf(
|
|
248
|
-
CalendarContract.
|
|
249
|
-
CalendarContract.
|
|
250
|
-
CalendarContract.
|
|
251
|
-
CalendarContract.
|
|
252
|
-
CalendarContract.
|
|
253
|
-
CalendarContract.
|
|
254
|
-
CalendarContract.
|
|
255
|
-
CalendarContract.
|
|
256
|
-
CalendarContract.
|
|
257
|
-
CalendarContract.
|
|
258
|
-
CalendarContract.
|
|
259
|
-
CalendarContract.
|
|
260
|
-
CalendarContract.
|
|
261
|
-
CalendarContract.
|
|
256
|
+
CalendarContract.Instances.EVENT_ID,
|
|
257
|
+
CalendarContract.Instances.TITLE,
|
|
258
|
+
CalendarContract.Instances.CALENDAR_ID,
|
|
259
|
+
CalendarContract.Instances.EVENT_LOCATION,
|
|
260
|
+
CalendarContract.Instances.BEGIN,
|
|
261
|
+
CalendarContract.Instances.END,
|
|
262
|
+
CalendarContract.Instances.ALL_DAY,
|
|
263
|
+
CalendarContract.Instances.DESCRIPTION,
|
|
264
|
+
CalendarContract.Instances.AVAILABILITY,
|
|
265
|
+
CalendarContract.Instances.ORGANIZER,
|
|
266
|
+
CalendarContract.Instances.EVENT_COLOR,
|
|
267
|
+
CalendarContract.Instances.EVENT_TIMEZONE,
|
|
268
|
+
CalendarContract.Instances.STATUS,
|
|
269
|
+
CalendarContract.Instances.DURATION,
|
|
262
270
|
)
|
|
263
|
-
|
|
264
|
-
val
|
|
265
|
-
|
|
271
|
+
|
|
272
|
+
val selection =
|
|
273
|
+
"(${CalendarContract.Instances.BEGIN} < ?) AND " +
|
|
274
|
+
"(${CalendarContract.Instances.END} > ?)"
|
|
275
|
+
val selectionArgs = arrayOf(input.to.toString(), input.from.toString())
|
|
276
|
+
|
|
277
|
+
val sortOrder = "${CalendarContract.Instances.BEGIN} ASC"
|
|
278
|
+
|
|
279
|
+
val cursor = cr.query(uri, projection, selection, selectionArgs, sortOrder)
|
|
280
|
+
|
|
266
281
|
cursor?.use { cursorInstance ->
|
|
267
282
|
while (cursorInstance.moveToNext()) {
|
|
268
|
-
val
|
|
269
|
-
val title =
|
|
270
|
-
cursorInstance.getColumnIndex(CalendarContract.Events.TITLE).takeIf { it != -1 }?.let {
|
|
271
|
-
cursorInstance.getString(it)
|
|
272
|
-
} ?: ""
|
|
283
|
+
val eventId = cursorInstance.getLong(cursorInstance.getColumnIndexOrThrow(CalendarContract.Instances.EVENT_ID))
|
|
284
|
+
val title = cursorInstance.getString(cursorInstance.getColumnIndexOrThrow(CalendarContract.Instances.TITLE)) ?: ""
|
|
273
285
|
val calendarId =
|
|
274
|
-
cursorInstance
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
cursorInstance
|
|
287
|
+
.getLong(
|
|
288
|
+
cursorInstance.getColumnIndexOrThrow(CalendarContract.Instances.CALENDAR_ID),
|
|
289
|
+
).toString()
|
|
277
290
|
val location =
|
|
278
|
-
cursorInstance
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
val
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
291
|
+
cursorInstance
|
|
292
|
+
.getColumnIndex(CalendarContract.Instances.EVENT_LOCATION)
|
|
293
|
+
.takeIf { it != -1 }
|
|
294
|
+
?.let { cursorInstance.getString(it) }
|
|
295
|
+
|
|
296
|
+
val startDate = cursorInstance.getLong(cursorInstance.getColumnIndexOrThrow(CalendarContract.Instances.BEGIN))
|
|
297
|
+
val endDate = cursorInstance.getLong(cursorInstance.getColumnIndexOrThrow(CalendarContract.Instances.END))
|
|
298
|
+
|
|
299
|
+
val isAllDay = cursorInstance.getInt(cursorInstance.getColumnIndexOrThrow(CalendarContract.Instances.ALL_DAY)) == 1
|
|
300
|
+
|
|
288
301
|
val description =
|
|
289
|
-
cursorInstance
|
|
290
|
-
|
|
291
|
-
|
|
302
|
+
cursorInstance
|
|
303
|
+
.getColumnIndex(CalendarContract.Instances.DESCRIPTION)
|
|
304
|
+
.takeIf { it != -1 }
|
|
305
|
+
?.let { cursorInstance.getString(it) }
|
|
306
|
+
|
|
292
307
|
val availability =
|
|
293
|
-
cursorInstance
|
|
294
|
-
|
|
295
|
-
|
|
308
|
+
cursorInstance
|
|
309
|
+
.getColumnIndex(CalendarContract.Instances.AVAILABILITY)
|
|
310
|
+
.takeIf { it != -1 }
|
|
311
|
+
?.let { cursorInstance.getInt(it) }
|
|
312
|
+
|
|
296
313
|
val organizer =
|
|
297
|
-
cursorInstance
|
|
298
|
-
|
|
299
|
-
|
|
314
|
+
cursorInstance
|
|
315
|
+
.getColumnIndex(CalendarContract.Instances.ORGANIZER)
|
|
316
|
+
.takeIf { it != -1 }
|
|
317
|
+
?.let { cursorInstance.getString(it) }
|
|
318
|
+
|
|
300
319
|
val color =
|
|
301
|
-
cursorInstance
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
cursorInstance.getString(it)
|
|
307
|
-
}
|
|
308
|
-
val status =
|
|
309
|
-
cursorInstance.getColumnIndex(CalendarContract.Events.STATUS).takeIf { it != -1 }?.let {
|
|
310
|
-
ImplementationHelper.mapEventStatus(cursorInstance.getInt(it))
|
|
311
|
-
}
|
|
312
|
-
val attendees = ImplementationHelper.getEventAttendees(cr, id)
|
|
320
|
+
cursorInstance
|
|
321
|
+
.getColumnIndex(CalendarContract.Instances.EVENT_COLOR)
|
|
322
|
+
.takeIf { it != -1 }
|
|
323
|
+
?.let { ImplementationHelper.intToHexColor(cursorInstance.getInt(it)) }
|
|
324
|
+
|
|
313
325
|
val timezone =
|
|
314
|
-
cursorInstance
|
|
315
|
-
|
|
316
|
-
|
|
326
|
+
cursorInstance
|
|
327
|
+
.getColumnIndex(CalendarContract.Instances.EVENT_TIMEZONE)
|
|
328
|
+
.takeIf { it != -1 }
|
|
329
|
+
?.let { cursorInstance.getString(it) }
|
|
330
|
+
|
|
331
|
+
val status =
|
|
332
|
+
cursorInstance
|
|
333
|
+
.getColumnIndex(CalendarContract.Instances.STATUS)
|
|
334
|
+
.takeIf { it != -1 }
|
|
335
|
+
?.let { ImplementationHelper.mapEventStatus(cursorInstance.getInt(it)) }
|
|
336
|
+
|
|
337
|
+
val alerts = ImplementationHelper.getEventAlerts(cr, eventId)
|
|
338
|
+
|
|
339
|
+
val duration =
|
|
340
|
+
cursorInstance
|
|
341
|
+
.getColumnIndex(CalendarContract.Instances.DURATION)
|
|
342
|
+
.takeIf { it != -1 }
|
|
343
|
+
?.let { cursorInstance.getString(it) }
|
|
344
|
+
?: ImplementationHelper.buildDurationFromBeginEnd(startDate, endDate, isAllDay)
|
|
345
|
+
|
|
346
|
+
val attendees = ImplementationHelper.getEventAttendees(cr, eventId)
|
|
317
347
|
|
|
318
348
|
events.add(
|
|
319
349
|
CalendarEvent(
|
|
320
|
-
|
|
350
|
+
eventId.toString(),
|
|
321
351
|
title,
|
|
322
352
|
calendarId,
|
|
323
353
|
location,
|
|
@@ -345,4 +375,18 @@ class CapacitorCalendar(
|
|
|
345
375
|
cursor?.close()
|
|
346
376
|
return ListEventsInRangeResult(events)
|
|
347
377
|
}
|
|
378
|
+
|
|
379
|
+
fun modifyCalendar(input: ModifyCalendarInput) {
|
|
380
|
+
val cr = plugin.context.contentResolver
|
|
381
|
+
val values =
|
|
382
|
+
ContentValues().apply {
|
|
383
|
+
input.title?.let { put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, it) }
|
|
384
|
+
input.color?.let { put(CalendarContract.Calendars.CALENDAR_COLOR, it) }
|
|
385
|
+
}
|
|
386
|
+
val uri: Uri = ContentUris.withAppendedId(CalendarContract.Calendars.CONTENT_URI, input.id)
|
|
387
|
+
val rowsUpdated = cr.update(uri, values, null, null)
|
|
388
|
+
if (rowsUpdated < 1) {
|
|
389
|
+
throw PluginError.FailedToModify
|
|
390
|
+
}
|
|
391
|
+
}
|
|
348
392
|
}
|
package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
package dev.barooni.capacitor.calendar.models.data
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject
|
|
4
|
+
import org.json.JSONArray
|
|
5
|
+
import org.json.JSONException
|
|
6
|
+
import java.util.Calendar
|
|
7
|
+
import java.util.Locale
|
|
8
|
+
import java.util.TimeZone
|
|
9
|
+
|
|
10
|
+
data class EventRecurrenceRule(
|
|
11
|
+
val byMonth: List<Int>? = null,
|
|
12
|
+
val byMonthDay: List<Int>? = null,
|
|
13
|
+
val byWeekDay: List<Int>? = null,
|
|
14
|
+
val count: Int?,
|
|
15
|
+
val end: Long?,
|
|
16
|
+
val frequency: Frequency,
|
|
17
|
+
val interval: Int = 1,
|
|
18
|
+
val weeksOfTheYear: List<Int>? = null,
|
|
19
|
+
val daysOfTheYear: List<Int>? = null,
|
|
20
|
+
) {
|
|
21
|
+
enum class Frequency { Daily, Weekly, Monthly, Yearly }
|
|
22
|
+
|
|
23
|
+
fun toRRule(): String {
|
|
24
|
+
val parts = mutableListOf<String>()
|
|
25
|
+
parts.add("FREQ=${frequency.name.uppercase()}")
|
|
26
|
+
parts.add("INTERVAL=${interval.coerceAtLeast(1)}")
|
|
27
|
+
|
|
28
|
+
if (count != null) {
|
|
29
|
+
parts.add("COUNT=$count")
|
|
30
|
+
} else if (end != null) {
|
|
31
|
+
parts.add("UNTIL=${formatUntilUtc(end)}")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
byWeekDay?.let { days ->
|
|
35
|
+
val mapped = days.mapNotNull { mapWeekday(it) }.distinct()
|
|
36
|
+
if (mapped.isNotEmpty()) parts.add("BYDAY=${mapped.joinToString(",")}")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
byMonthDay?.let { if (it.isNotEmpty()) parts.add("BYMONTHDAY=${it.joinToString(",")}") }
|
|
40
|
+
byMonth?.let { if (it.isNotEmpty()) parts.add("BYMONTH=${it.joinToString(",")}") }
|
|
41
|
+
weeksOfTheYear?.let { if (it.isNotEmpty()) parts.add("BYWEEKNO=${it.joinToString(",")}") }
|
|
42
|
+
daysOfTheYear?.let { if (it.isNotEmpty()) parts.add("BYYEARDAY=${it.joinToString(",")}") }
|
|
43
|
+
|
|
44
|
+
return parts.joinToString(";")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
companion object {
|
|
48
|
+
fun parseRecurrence(obj: JSObject): EventRecurrenceRule? {
|
|
49
|
+
val frequencyString = obj.getString("frequency") ?: return null
|
|
50
|
+
val frequency =
|
|
51
|
+
try {
|
|
52
|
+
Frequency.valueOf(
|
|
53
|
+
frequencyString
|
|
54
|
+
.trim()
|
|
55
|
+
.replaceFirstChar { it.uppercase() },
|
|
56
|
+
)
|
|
57
|
+
} catch (_: IllegalArgumentException) {
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
val interval = (obj.getInteger("interval") ?: 1).coerceAtLeast(1)
|
|
62
|
+
val count = obj.getInteger("count")
|
|
63
|
+
var until: Long?
|
|
64
|
+
try {
|
|
65
|
+
until = if (count != null) null else obj.getDouble("end").toLong()
|
|
66
|
+
} catch (_: JSONException) {
|
|
67
|
+
until = null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return EventRecurrenceRule(
|
|
71
|
+
frequency = frequency,
|
|
72
|
+
interval = interval,
|
|
73
|
+
count = count,
|
|
74
|
+
end = until,
|
|
75
|
+
byWeekDay = readIntList(obj, "byWeekDay"),
|
|
76
|
+
byMonthDay = readIntList(obj, "byMonthDay"),
|
|
77
|
+
byMonth = readIntList(obj, "byMonth"),
|
|
78
|
+
weeksOfTheYear = readIntList(obj, "weeksOfTheYear"),
|
|
79
|
+
daysOfTheYear = readIntList(obj, "daysOfTheYear"),
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private fun formatUntilUtc(untilMs: Long): String {
|
|
84
|
+
val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"))
|
|
85
|
+
calendar.timeInMillis = untilMs
|
|
86
|
+
|
|
87
|
+
val year = calendar.get(Calendar.YEAR)
|
|
88
|
+
val month = calendar.get(Calendar.MONTH) + 1
|
|
89
|
+
val day = calendar.get(Calendar.DAY_OF_MONTH)
|
|
90
|
+
val hour = calendar.get(Calendar.HOUR_OF_DAY)
|
|
91
|
+
val minute = calendar.get(Calendar.MINUTE)
|
|
92
|
+
val second = calendar.get(Calendar.SECOND)
|
|
93
|
+
|
|
94
|
+
return String.format(
|
|
95
|
+
Locale.US,
|
|
96
|
+
"%04d%02d%02dT%02d%02d%02dZ",
|
|
97
|
+
year,
|
|
98
|
+
month,
|
|
99
|
+
day,
|
|
100
|
+
hour,
|
|
101
|
+
minute,
|
|
102
|
+
second,
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private fun mapWeekday(day: Int): String? =
|
|
107
|
+
when (day) {
|
|
108
|
+
1 -> "MO"
|
|
109
|
+
2 -> "TU"
|
|
110
|
+
3 -> "WE"
|
|
111
|
+
4 -> "TH"
|
|
112
|
+
5 -> "FR"
|
|
113
|
+
6 -> "SA"
|
|
114
|
+
7 -> "SU"
|
|
115
|
+
else -> null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private fun readIntList(
|
|
119
|
+
obj: JSObject,
|
|
120
|
+
key: String,
|
|
121
|
+
): List<Int>? {
|
|
122
|
+
var arr: JSONArray
|
|
123
|
+
try {
|
|
124
|
+
arr = obj.getJSONArray(key) ?: return null
|
|
125
|
+
} catch (_: JSONException) {
|
|
126
|
+
return null
|
|
127
|
+
}
|
|
128
|
+
val list = mutableListOf<Int>()
|
|
129
|
+
for (i in 0 until arr.length()) {
|
|
130
|
+
list.add(arr.getInt(i))
|
|
131
|
+
}
|
|
132
|
+
return list
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt
CHANGED
|
@@ -24,4 +24,5 @@ data class CreateEventInput(
|
|
|
24
24
|
val color: Int? = ImplementationHelper.hexToColorInt(call.getString("color"))
|
|
25
25
|
val attendees: List<EventGuest>? = ImplementationHelper.eventGuestsFromCall(call)
|
|
26
26
|
val timezoneId = TimeZone.getDefault().id
|
|
27
|
+
val recurrence = input.recurrence
|
|
27
28
|
}
|
|
@@ -3,6 +3,7 @@ package dev.barooni.capacitor.calendar.models.inputs
|
|
|
3
3
|
import android.content.Intent
|
|
4
4
|
import android.provider.CalendarContract
|
|
5
5
|
import com.getcapacitor.PluginCall
|
|
6
|
+
import dev.barooni.capacitor.calendar.models.data.EventRecurrenceRule
|
|
6
7
|
import dev.barooni.capacitor.calendar.utils.ImplementationHelper
|
|
7
8
|
|
|
8
9
|
data class CreateEventWithPromptInput(
|
|
@@ -10,6 +11,7 @@ data class CreateEventWithPromptInput(
|
|
|
10
11
|
val callbackName: String,
|
|
11
12
|
) {
|
|
12
13
|
private val title: String = call.getString("title", "") ?: ""
|
|
14
|
+
val recurrence: EventRecurrenceRule? = call.getObject("recurrence")?.let { EventRecurrenceRule.parseRecurrence(it) }
|
|
13
15
|
val location: String? = call.getString("location")
|
|
14
16
|
val startDate: Long? = call.getLong("startDate")?.let { ImplementationHelper.getCalendarFromTimestamp(it).timeInMillis }
|
|
15
17
|
val endDate: Long? = call.getLong("endDate")?.let { ImplementationHelper.getCalendarFromTimestamp(it).timeInMillis }
|
|
@@ -32,5 +34,8 @@ data class CreateEventWithPromptInput(
|
|
|
32
34
|
description?.let { intent.putExtra(CalendarContract.Events.DESCRIPTION, it) }
|
|
33
35
|
availability?.let { intent.putExtra(CalendarContract.Events.AVAILABILITY, it) }
|
|
34
36
|
invitees?.let { intent.putExtra(Intent.EXTRA_EMAIL, it) }
|
|
37
|
+
recurrence?.let {
|
|
38
|
+
intent.putExtra(CalendarContract.Events.RRULE, it.toRRule())
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
}
|
package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyCalendarInput.kt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package dev.barooni.capacitor.calendar.models.inputs
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.PluginCall
|
|
4
|
+
import dev.barooni.capacitor.calendar.PluginError
|
|
5
|
+
import dev.barooni.capacitor.calendar.utils.ImplementationHelper
|
|
6
|
+
|
|
7
|
+
data class ModifyCalendarInput(
|
|
8
|
+
private val call: PluginCall,
|
|
9
|
+
) {
|
|
10
|
+
val id = call.getString("id")?.toLong() ?: throw PluginError.MissingId
|
|
11
|
+
val title = call.getString("title")
|
|
12
|
+
val color = call.getString("color")?.let { ImplementationHelper.hexToColorInt(it) }
|
|
13
|
+
}
|
|
@@ -3,6 +3,7 @@ package dev.barooni.capacitor.calendar.models.inputs
|
|
|
3
3
|
import com.getcapacitor.PluginCall
|
|
4
4
|
import dev.barooni.capacitor.calendar.PluginError
|
|
5
5
|
import dev.barooni.capacitor.calendar.models.data.EventGuest
|
|
6
|
+
import dev.barooni.capacitor.calendar.models.data.EventRecurrenceRule
|
|
6
7
|
import dev.barooni.capacitor.calendar.utils.ImplementationHelper
|
|
7
8
|
|
|
8
9
|
data class ModifyEvent(
|
|
@@ -22,4 +23,5 @@ data class ModifyEvent(
|
|
|
22
23
|
val color: Int? = ImplementationHelper.hexToColorInt(call.getString("color"))
|
|
23
24
|
val duration: String? = call.getString("duration")
|
|
24
25
|
val attendees: List<EventGuest>? = ImplementationHelper.eventGuestsFromCall(call)
|
|
26
|
+
val recurrence: EventRecurrenceRule? = call.getObject("recurrence")?.let { EventRecurrenceRule.parseRecurrence(it) }
|
|
25
27
|
}
|
|
@@ -33,5 +33,8 @@ data class ModifyEventWithPromptInput(
|
|
|
33
33
|
input.description?.let { intent.putExtra(CalendarContract.Events.DESCRIPTION, it) }
|
|
34
34
|
input.availability?.let { intent.putExtra(CalendarContract.Events.AVAILABILITY, it) }
|
|
35
35
|
input.invitees?.let { intent.putExtra(Intent.EXTRA_EMAIL, it) }
|
|
36
|
+
input.recurrence?.let {
|
|
37
|
+
intent.putExtra(CalendarContract.Events.RRULE, it.toRRule())
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -96,11 +96,21 @@ class ImplementationHelper {
|
|
|
96
96
|
cr: ContentResolver,
|
|
97
97
|
alerts: List<Int>,
|
|
98
98
|
) {
|
|
99
|
-
alerts.forEach {
|
|
99
|
+
alerts.forEach { userMinutes ->
|
|
100
|
+
val providerMinutes =
|
|
101
|
+
when {
|
|
102
|
+
userMinutes > 0 -> -kotlin.math.abs(userMinutes)
|
|
103
|
+
|
|
104
|
+
// after start -> store negative
|
|
105
|
+
userMinutes < 0 -> kotlin.math.abs(userMinutes)
|
|
106
|
+
|
|
107
|
+
// before start -> store positive
|
|
108
|
+
else -> 0
|
|
109
|
+
}
|
|
100
110
|
val alertValues =
|
|
101
111
|
ContentValues().apply {
|
|
102
112
|
put(CalendarContract.Reminders.EVENT_ID, eventId)
|
|
103
|
-
put(CalendarContract.Reminders.MINUTES,
|
|
113
|
+
put(CalendarContract.Reminders.MINUTES, providerMinutes)
|
|
104
114
|
put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT)
|
|
105
115
|
}
|
|
106
116
|
cr.insert(CalendarContract.Reminders.CONTENT_URI, alertValues)
|
|
@@ -286,8 +296,16 @@ class ImplementationHelper {
|
|
|
286
296
|
|
|
287
297
|
cursor?.use {
|
|
288
298
|
while (it.moveToNext()) {
|
|
289
|
-
val
|
|
290
|
-
|
|
299
|
+
val providerMinutes = it.getInt(it.getColumnIndexOrThrow(CalendarContract.Reminders.MINUTES))
|
|
300
|
+
|
|
301
|
+
val userMinutes =
|
|
302
|
+
if (providerMinutes >= 0) {
|
|
303
|
+
-kotlin.math.abs(providerMinutes)
|
|
304
|
+
} else {
|
|
305
|
+
kotlin.math.abs(providerMinutes)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
alerts.add(userMinutes)
|
|
291
309
|
}
|
|
292
310
|
}
|
|
293
311
|
|
|
@@ -347,6 +365,32 @@ class ImplementationHelper {
|
|
|
347
365
|
return attendees
|
|
348
366
|
}
|
|
349
367
|
|
|
368
|
+
fun buildDurationFromBeginEnd(
|
|
369
|
+
begin: Long,
|
|
370
|
+
end: Long,
|
|
371
|
+
isAllDay: Boolean,
|
|
372
|
+
): String {
|
|
373
|
+
val diffMs = (end - begin).coerceAtLeast(0)
|
|
374
|
+
|
|
375
|
+
return if (isAllDay) {
|
|
376
|
+
val days = (diffMs / (24 * 60 * 60 * 1000)).coerceAtLeast(1)
|
|
377
|
+
"P${days}D"
|
|
378
|
+
} else {
|
|
379
|
+
val totalSeconds = (diffMs / 1000).coerceAtLeast(1)
|
|
380
|
+
val hours = totalSeconds / 3600
|
|
381
|
+
val minutes = (totalSeconds % 3600) / 60
|
|
382
|
+
val seconds = totalSeconds % 60
|
|
383
|
+
|
|
384
|
+
buildString {
|
|
385
|
+
append("PT")
|
|
386
|
+
if (hours > 0) append("${hours}H")
|
|
387
|
+
if (minutes > 0) append("${minutes}M")
|
|
388
|
+
if (seconds > 0) append("${seconds}S")
|
|
389
|
+
if (hours == 0L && minutes == 0L && seconds == 0L) append("1S")
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
350
394
|
fun mapAttendeeRelationship(relationship: Int): String =
|
|
351
395
|
when (relationship) {
|
|
352
396
|
CalendarContract.Attendees.RELATIONSHIP_ATTENDEE -> "attendee"
|