ReviewOS

also looking at this

craft-native/craft

fix(android): resolve share() with whether the person picked an app

#210
Merged glennmichael123 wants to merge fix/android-share-outcome into main
12 files +399 -56
packages/android/templates/CraftNative.kt.templatemodified+9-4
Changes to packages/android/templates/CraftNative.kt.template
@@ -1,6 +1,7 @@
11package com.craft.runtime
22
33import android.app.Activity
4import android.content.IntentSender
45import com.google.android.gms.location.Priority
56import com.google.android.gms.location.LocationServices
67import com.google.android.gms.location.LocationResult
@@ -227,7 +228,7 @@ object CraftNative {
227228 private external fun nativeClipboardRead(activity: Activity): String?
228229 private external fun nativeClipboardWrite(activity: Activity, text: String): Boolean
229230 private external fun nativeOpenUrl(activity: Activity, url: String): Boolean
230 private external fun nativeShare(activity: Activity, text: String, title: String): Boolean
231 private external fun nativeShare(activity: Activity, text: String, title: String, chosen: IntentSender, requestCode: Int): Boolean
231232 private external fun nativeOpenCamera(activity: Activity): Boolean
232233 private external fun nativePickImage(activity: Activity): Boolean
233234 private external fun nativePickFile(activity: Activity): Boolean
@@ -425,11 +426,15 @@ object CraftNative {
425426 }
426427 }
427428
428 /** Returns whether Zig launched the share sheet; false falls through. */
429 fun share(activity: Activity, text: String, title: String): Boolean {
429 /**
430 * Returns whether Zig launched the share menu for a result; false falls
431 * through. `chosen` fires on a pick and `requestCode` routes the result
432 * back to CraftBridge, which settles the page's promise from the two.
433 */
434 fun share(activity: Activity, text: String, title: String, chosen: IntentSender, requestCode: Int): Boolean {
430435 if (!isAvailable) return false
431436 return try {
432 nativeShare(activity, text, title)
437 nativeShare(activity, text, title, chosen, requestCode)
433438 } catch (e: UnsatisfiedLinkError) {
434439 false
435440 }