also looking at this
feat(android): downloadFile and saveFile in Zig — ratchet 69 → 67
#176
6 files
+477
-3
| @@ -2663,6 +2663,10 @@ class CraftBridge( | ||
| 2663 | 2663 | |
| 2664 | 2664 | @JavascriptInterface |
| 2665 | 2665 | fun downloadFile(url: String, filename: String) { |
| 2666 | // Zig answers through the reply channel, so returning here is what | |
| 2667 | // stops the promise being settled twice. | |
| 2668 | if (CraftNative.downloadFile(activity, url, filename)) return | |
| 2669 | ||
| 2666 | 2670 | try { |
| 2667 | 2671 | val request = DownloadManager.Request(Uri.parse(url)).apply { |
| 2668 | 2672 | setTitle(filename) |
| @@ -2692,6 +2696,10 @@ class CraftBridge( | ||
| 2692 | 2696 | |
| 2693 | 2697 | @JavascriptInterface |
| 2694 | 2698 | fun saveFile(data: String, filename: String) { |
| 2699 | // Zig answers through the reply channel, so returning here is what | |
| 2700 | // stops the promise being settled twice. | |
| 2701 | if (CraftNative.saveFile(activity, data, filename)) return | |
| 2702 | ||
| 2695 | 2703 | try { |
| 2696 | 2704 | val documentsDir = activity.getExternalFilesDir(android.os.Environment.DIRECTORY_DOCUMENTS) |
| 2697 | 2705 | val file = File(documentsDir, filename) |