also looking at this
feat(android): deleteCalendarEvent — the first action to answer through the channel
#155
7 files
+288
-3
| @@ -107,6 +107,7 @@ object CraftNative { | ||
| 107 | 107 | private external fun nativeVibrate(activity: Activity, patternJson: String): Boolean |
| 108 | 108 | private external fun nativeCancelNotification(activity: Activity, id: String): Boolean |
| 109 | 109 | private external fun nativeCancelAllNotifications(activity: Activity): Boolean |
| 110 | private external fun nativeDeleteCalendarEvent(activity: Activity, eventId: String): Boolean | |
| 110 | 111 | |
| 111 | 112 | /** |
| 112 | 113 | * `getDeviceInfo`, or null to use the Kotlin implementation. |
| @@ -333,4 +334,20 @@ object CraftNative { | ||
| 333 | 334 | false |
| 334 | 335 | } |
| 335 | 336 | } |
| 337 | ||
| 338 | /** | |
| 339 | * Returns whether Zig *took* the action, not whether the delete worked. | |
| 340 | * | |
| 341 | * The first native here that answers asynchronously: the outcome reaches | |
| 342 | * the page through the reply channel, so true means "do not also run the | |
| 343 | * Kotlin" and nothing more. Running both would settle the promise twice. | |
| 344 | */ | |
| 345 | fun deleteCalendarEvent(activity: Activity, eventId: String): Boolean { | |
| 346 | if (!isAvailable) return false | |
| 347 | return try { | |
| 348 | nativeDeleteCalendarEvent(activity, eventId) | |
| 349 | } catch (e: UnsatisfiedLinkError) { | |
| 350 | false | |
| 351 | } | |
| 352 | } | |
| 336 | 353 | } |