expo-calendar 9.1.2 → 10.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/android/build.gradle +30 -19
  3. package/android/src/main/java/expo/modules/calendar/AttendeeBuilder.kt +38 -0
  4. package/android/src/main/java/expo/modules/calendar/CalendarEventBuilder.kt +91 -0
  5. package/android/src/main/java/expo/modules/calendar/CalendarModule.kt +878 -0
  6. package/android/src/main/java/expo/modules/calendar/CalendarPackage.kt +8 -0
  7. package/android/src/main/java/expo/modules/calendar/Constants.kt +91 -0
  8. package/android/src/main/java/expo/modules/calendar/JsValuesMappers.kt +173 -0
  9. package/android/src/main/java/expo/modules/calendar/ModuleDestroyedException.kt +5 -0
  10. package/build/Calendar.d.ts +22 -2
  11. package/build/Calendar.js +33 -6
  12. package/build/Calendar.js.map +1 -1
  13. package/build/ExpoCalendar.d.ts +1 -1
  14. package/build/ExpoCalendar.js +1 -1
  15. package/build/ExpoCalendar.js.map +1 -1
  16. package/build/ExpoCalendar.web.d.ts +1 -1
  17. package/build/ExpoCalendar.web.js +1 -1
  18. package/build/ExpoCalendar.web.js.map +1 -1
  19. package/ios/EXCalendar/EXCalendar.h +3 -3
  20. package/ios/EXCalendar/EXCalendar.m +88 -88
  21. package/ios/EXCalendar/EXCalendarConverter.m +10 -10
  22. package/ios/EXCalendar/EXCalendarPermissionRequester.h +2 -2
  23. package/ios/EXCalendar/EXCalendarPermissionRequester.m +9 -9
  24. package/ios/EXCalendar/EXRemindersPermissionRequester.h +2 -2
  25. package/ios/EXCalendar/EXRemindersPermissionRequester.m +8 -8
  26. package/ios/EXCalendar.podspec +3 -3
  27. package/package.json +7 -7
  28. package/src/Calendar.ts +38 -3
  29. package/src/ExpoCalendar.ts +1 -1
  30. package/src/ExpoCalendar.web.ts +1 -1
  31. package/android/src/main/java/expo/modules/calendar/CalendarModule.java +0 -1407
  32. package/android/src/main/java/expo/modules/calendar/CalendarPackage.java +0 -16
package/CHANGELOG.md CHANGED
@@ -8,6 +8,39 @@
8
8
 
9
9
  ### 🐛 Bug fixes
10
10
 
11
+ ### 💡 Others
12
+
13
+ ## 10.0.0 — 2021-09-28
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
18
+
19
+ ### 🎉 New features
20
+
21
+ - Add useCalendarPermissions and useRemindersPermissions hooks from modules factory. ([#13854](https://github.com/expo/expo/pull/13854) by [@bycedric](https://github.com/bycedric))
22
+
23
+ ### 🐛 Bug fixes
24
+
25
+ - Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
26
+
27
+ ### 💡 Others
28
+
29
+ - Rewrote from Java to Kotlin, migrated from `AsyncTask` to `kotlinx.coroutines`. ([#13527](https://github.com/expo/expo/pull/13527) by [@M1ST4KE](https://github.com/M1ST4KE))
30
+ - Migrated from `@unimodules/core` to `expo-modules-core`. ([#13756](https://github.com/expo/expo/pull/13756) by [@tsapeta](https://github.com/tsapeta))
31
+ - Updated `@expo/config-plugins` ([#14443](https://github.com/expo/expo/pull/14443) by [@EvanBacon](https://github.com/EvanBacon))
32
+
33
+ ## 9.2.0 — 2021-06-16
34
+
35
+ ### 🐛 Bug fixes
36
+
37
+ - Fixed `ExpoCalendar.getCalendarsAsync()` crashing on Android when device has unsupported calendars. ([#12724](https://github.com/expo/expo/pull/12724) by [@ibraude](https://github.com/ibraude))
38
+ - Enable kotlin in all modules. ([#12716](https://github.com/expo/expo/pull/12716) by [@wschurman](https://github.com/wschurman))
39
+
40
+ ### 💡 Others
41
+
42
+ - Migrated from `unimodules-permissions-interface` to `expo-modules-core`. ([#12961](https://github.com/expo/expo/pull/12961) by [@tsapeta](https://github.com/tsapeta))
43
+
11
44
  ## 9.1.2 — 2021-04-13
12
45
 
13
46
  _This version does not introduce any user-facing changes._
@@ -1,12 +1,23 @@
1
1
  apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
2
3
  apply plugin: 'maven'
3
4
 
4
5
  group = 'host.exp.exponent'
5
- version = '9.1.2'
6
+ version = '10.0.0'
6
7
 
7
- // Simple helper that allows the root project to override versions declared by this library.
8
- def safeExtGet(prop, fallback) {
9
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
8
+ buildscript {
9
+ // Simple helper that allows the root project to override versions declared by this library.
10
+ ext.safeExtGet = { prop, fallback ->
11
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
12
+ }
13
+
14
+ repositories {
15
+ mavenCentral()
16
+ }
17
+
18
+ dependencies {
19
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
20
+ }
10
21
  }
11
22
 
12
23
  // Upload android library to maven with javadoc and android sources
@@ -37,30 +48,30 @@ uploadArchives {
37
48
  android {
38
49
  compileSdkVersion safeExtGet("compileSdkVersion", 30)
39
50
 
51
+ compileOptions {
52
+ sourceCompatibility JavaVersion.VERSION_1_8
53
+ targetCompatibility JavaVersion.VERSION_1_8
54
+ }
55
+
56
+ kotlinOptions {
57
+ jvmTarget = JavaVersion.VERSION_1_8
58
+ }
59
+
40
60
  defaultConfig {
41
61
  minSdkVersion safeExtGet("minSdkVersion", 21)
42
62
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
43
63
  versionCode 17
44
- versionName '9.1.2'
64
+ versionName '10.0.0'
45
65
  }
46
66
  lintOptions {
47
67
  abortOnError false
48
68
  }
49
- compileOptions {
50
- sourceCompatibility = '1.8'
51
- targetCompatibility = '1.8'
52
- }
53
- }
54
-
55
- if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
56
- apply from: project(':unimodules-core').file('../unimodules-core.gradle')
57
- } else {
58
- throw new GradleException(
59
- '\'unimodules-core.gradle\' was not found in the usual React Native dependency location. ' +
60
- 'This package can only be used in such projects. Are you sure you\'ve installed the dependencies properly?')
61
69
  }
62
70
 
63
71
  dependencies {
64
- unimodule 'unimodules-core'
65
- unimodule 'unimodules-permissions-interface'
72
+ implementation project(':expo-modules-core')
73
+
74
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
75
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3")
76
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1")
66
77
  }
@@ -0,0 +1,38 @@
1
+ package expo.modules.calendar
2
+
3
+ import android.content.ContentValues
4
+ import expo.modules.core.arguments.ReadableArguments
5
+
6
+ class AttendeeBuilder(
7
+ private val attendeeDetails: ReadableArguments
8
+ ) {
9
+ private val attendeeValues = ContentValues()
10
+
11
+ fun put(key: String, value: Int?) = apply {
12
+ attendeeValues.put(key, value)
13
+ }
14
+
15
+ fun putString(detailsKey: String, detailsString: String) = apply {
16
+ if (attendeeDetails.containsKey(detailsKey)) {
17
+ attendeeValues.put(detailsString, attendeeDetails.getString(detailsKey))
18
+ }
19
+ }
20
+
21
+ fun putString(detailsKey: String, detailsString: String, isRequired: Boolean) = apply {
22
+ if (attendeeDetails.containsKey(detailsKey)) {
23
+ attendeeValues.put(detailsString, attendeeDetails.getString(detailsKey))
24
+ } else if (isRequired) {
25
+ throw Exception("new attendees require `$detailsKey`")
26
+ }
27
+ }
28
+
29
+ fun putString(detailsKey: String, detailsString: String, isRequired: Boolean?, mapper: (String) -> Int) = apply {
30
+ if (attendeeDetails.containsKey(detailsKey)) {
31
+ attendeeValues.put(detailsString, mapper(attendeeDetails.getString(detailsKey)))
32
+ } else if (isRequired == true) {
33
+ throw Exception("new attendees require `$detailsKey`")
34
+ }
35
+ }
36
+
37
+ fun build() = attendeeValues
38
+ }
@@ -0,0 +1,91 @@
1
+ package expo.modules.calendar
2
+
3
+ import android.content.ContentValues
4
+ import android.text.TextUtils
5
+ import expo.modules.core.arguments.ReadableArguments
6
+ import java.util.*
7
+
8
+ class CalendarEventBuilder(
9
+ private val eventDetails: ReadableArguments
10
+ ) {
11
+ private val eventValues = ContentValues()
12
+
13
+ fun getAsLong(key: String): Long = eventValues.getAsLong(key)
14
+
15
+ fun put(key: String, value: String) = apply {
16
+ eventValues.put(key, value)
17
+ }
18
+
19
+ fun put(key: String, value: Int) = apply {
20
+ eventValues.put(key, value)
21
+ }
22
+
23
+ fun put(key: String, value: Long) = apply {
24
+ eventValues.put(key, value)
25
+ }
26
+
27
+ fun put(key: String, value: Boolean) = apply {
28
+ eventValues.put(key, value)
29
+ }
30
+
31
+ fun putNull(key: String) = apply {
32
+ eventValues.putNull(key)
33
+ }
34
+
35
+ fun checkIfContainsRequiredKeys(vararg keys: String) = apply {
36
+ keys.forEach { checkDetailsContainsRequiredKey(it) }
37
+ }
38
+
39
+ fun putEventString(eventKey: String, detailsKey: String) = apply {
40
+ if (eventDetails.containsKey(detailsKey)) {
41
+ eventValues.put(eventKey, eventDetails.getString(detailsKey))
42
+ }
43
+ }
44
+
45
+ fun putEventString(eventKey: String, detailsKey: String, mapper: (String) -> Int) = apply {
46
+ if (eventDetails.containsKey(detailsKey)) {
47
+ eventValues.put(eventKey, mapper(eventDetails.getString(detailsKey)))
48
+ }
49
+ }
50
+
51
+ fun putEventBoolean(eventKey: String, detailsKey: String) = apply {
52
+ if (eventDetails.containsKey(detailsKey)) {
53
+ eventValues.put(eventKey, if (eventDetails.getBoolean(detailsKey)) 1 else 0)
54
+ }
55
+ }
56
+
57
+ fun putEventBoolean(eventKey: String, detailsKey: String, value: Boolean) = apply {
58
+ if (eventDetails.containsKey(detailsKey)) {
59
+ eventValues.put(eventKey, value)
60
+ }
61
+ }
62
+
63
+ fun putEventTimeZone(eventKey: String, detailsKey: String) = apply {
64
+ eventValues.put(
65
+ eventKey,
66
+ if (eventDetails.containsKey(detailsKey)) {
67
+ eventDetails.getString(detailsKey)
68
+ } else {
69
+ TimeZone.getDefault().id
70
+ }
71
+ )
72
+ }
73
+
74
+ fun <OutputListItemType> putEventDetailsList(eventKey: String, detailsKey: String, mappingMethod: (Any?) -> OutputListItemType) = apply {
75
+ if (eventDetails.containsKey(eventKey)) {
76
+ val array = eventDetails.getList(eventKey)
77
+ val values = array.map {
78
+ mappingMethod(it)
79
+ }
80
+ eventValues.put(detailsKey, TextUtils.join(",", values))
81
+ }
82
+ }
83
+
84
+ private fun checkDetailsContainsRequiredKey(key: String) = apply {
85
+ if (!eventDetails.containsKey(key)) {
86
+ throw Exception("new calendars require $key")
87
+ }
88
+ }
89
+
90
+ fun build() = eventValues
91
+ }