also looking at this
fix(android): resolve share() with whether the person picked an app
#210
12 files
+399
-56
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | package com.craft.runtime |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity |
| 4 | import android.content.IntentSender | |
| 4 | 5 | import com.google.android.gms.location.Priority |
| 5 | 6 | import com.google.android.gms.location.LocationServices |
| 6 | 7 | import com.google.android.gms.location.LocationResult |
| @@ -227,7 +228,7 @@ object CraftNative { | ||
| 227 | 228 | private external fun nativeClipboardRead(activity: Activity): String? |
| 228 | 229 | private external fun nativeClipboardWrite(activity: Activity, text: String): Boolean |
| 229 | 230 | 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 | |
| 231 | 232 | private external fun nativeOpenCamera(activity: Activity): Boolean |
| 232 | 233 | private external fun nativePickImage(activity: Activity): Boolean |
| 233 | 234 | private external fun nativePickFile(activity: Activity): Boolean |
| @@ -425,11 +426,15 @@ object CraftNative { | ||
| 425 | 426 | } |
| 426 | 427 | } |
| 427 | 428 | |
| 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 { | |
| 430 | 435 | if (!isAvailable) return false |
| 431 | 436 | return try { |
| 432 | nativeShare(activity, text, title) | |
| 437 | nativeShare(activity, text, title, chosen, requestCode) | |
| 433 | 438 | } catch (e: UnsatisfiedLinkError) { |
| 434 | 439 | false |
| 435 | 440 | } |