ReviewOS

also looking at this

craft-native/craft

feat(android): downloadFile and saveFile in Zig — ratchet 69 → 67

#176
Merged glennmichael123 wants to merge feat/android-files into main
6 files +477 -3
packages/android/templates/CraftBridge.kt.templatemodified+8-0
Changes to packages/android/templates/CraftBridge.kt.template
@@ -2663,6 +2663,10 @@ class CraftBridge(
26632663
26642664 @JavascriptInterface
26652665 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
26662670 try {
26672671 val request = DownloadManager.Request(Uri.parse(url)).apply {
26682672 setTitle(filename)
@@ -2692,6 +2696,10 @@ class CraftBridge(
26922696
26932697 @JavascriptInterface
26942698 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
26952703 try {
26962704 val documentsDir = activity.getExternalFilesDir(android.os.Environment.DIRECTORY_DOCUMENTS)
26972705 val file = File(documentsDir, filename)