Skip to content

Commit 448846b

Browse files
feat(fs): resolve content URIs on Android (#1658)
* Implemented writeTextFile on Android. * Added license headers. * fix fmt checks. * implement more file APIs * change file * cleanup * refactor dialog plugin to leverage new FS APIs * implement metadata functions * fix build * expose FS rust API * resolve resources on android * update pnpm * update docs --------- Co-authored-by: Lucas Nogueira <[email protected]>
1 parent 3c52f30 commit 448846b

File tree

38 files changed

+1950
-819
lines changed

38 files changed

+1950
-819
lines changed

.changes/dialog-return-path.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"dialog": patch
3+
"dialog-js": patch
4+
---
5+
6+
The `open` function now returns a string representing either the file path or URI instead of an object.
7+
To read the file data, use the `fs` APIs.

.changes/resolve-content-uris.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fs": patch:feat
3+
---
4+
5+
Resolve `content://` path URIs on Android.

Cargo.lock

Lines changed: 17 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ resolver = "2"
1111
[workspace.dependencies]
1212
serde = { version = "1", features = ["derive"] }
1313
log = "0.4"
14-
tauri = { version = "2.0.0-rc.3", default-features = false }
15-
tauri-build = "2.0.0-rc.3"
16-
tauri-plugin = "2.0.0-rc.3"
17-
tauri-utils = "2.0.0-rc.3"
14+
tauri = { version = "2.0.0-rc.5", default-features = false }
15+
tauri-build = "2.0.0-rc.5"
16+
tauri-plugin = "2.0.0-rc.5"
17+
tauri-utils = "2.0.0-rc.5"
1818
serde_json = "1"
1919
thiserror = "1"
2020
url = "2"

examples/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@iconify-json/codicon": "^1.1.37",
3131
"@iconify-json/ph": "^1.1.8",
3232
"@sveltejs/vite-plugin-svelte": "^3.0.1",
33-
"@tauri-apps/cli": "2.0.0-rc.4",
33+
"@tauri-apps/cli": "2.0.0-rc.6",
3434
"@unocss/extractor-svelte": "^0.62.0",
3535
"svelte": "^4.2.8",
3636
"unocss": "^0.62.0",

examples/api/src-tauri/capabilities/base.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
"clipboard-manager:allow-write-text",
6262
"clipboard-manager:allow-read-image",
6363
"clipboard-manager:allow-write-image",
64+
"fs:allow-open",
65+
"fs:allow-write",
66+
"fs:allow-read",
6467
"fs:allow-rename",
6568
"fs:allow-mkdir",
6669
"fs:allow-remove",

examples/api/src-tauri/gen/android/.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/src/views/Dialog.svelte

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
2424
async function prompt() {
2525
confirm("Do you want to do something?")
26-
.then((res) =>
27-
onMessage(
28-
res ? "Yes" : "No"
29-
)
30-
)
26+
.then((res) => onMessage(res ? "Yes" : "No"))
3127
.catch(onMessage);
3228
}
3329
@@ -67,14 +63,15 @@
6763
if (Array.isArray(res)) {
6864
onMessage(res);
6965
} else {
70-
var pathToRead = typeof res === "string" ? res : res.path;
66+
var pathToRead = res;
7167
var isFile = pathToRead.match(/\S+\.\S+$/g);
7268
readFile(pathToRead)
7369
.then(function (response) {
7470
if (isFile) {
7571
if (
7672
pathToRead.includes(".png") ||
77-
pathToRead.includes(".jpg")
73+
pathToRead.includes(".jpg") ||
74+
pathToRead.includes(".jpeg")
7875
) {
7976
arrayBufferToBase64(
8077
new Uint8Array(response),
@@ -144,5 +141,7 @@
144141
>Open save dialog</button
145142
>
146143
<button class="btn" id="prompt-dialog" on:click={prompt}>Prompt</button>
147-
<button class="btn" id="custom-prompt-dialog" on:click={promptCustom}>Prompt (custom)</button>
144+
<button class="btn" id="custom-prompt-dialog" on:click={promptCustom}
145+
>Prompt (custom)</button
146+
>
148147
<button class="btn" id="message-dialog" on:click={msg}>Message</button>

plugins/deep-link/examples/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@tauri-apps/plugin-deep-link": "2.0.0-rc.0"
1515
},
1616
"devDependencies": {
17-
"@tauri-apps/cli": "2.0.0-rc.4",
17+
"@tauri-apps/cli": "2.0.0-rc.6",
1818
"typescript": "^5.2.2",
1919
"vite": "^5.0.13"
2020
}

plugins/dialog/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"]
1717
[build-dependencies]
1818
tauri-plugin = { workspace = true, features = [ "build" ] }
1919

20+
[dev-dependencies]
21+
tauri = { workspace = true, features = [ "wry" ] }
22+
2023
[dependencies]
2124
serde = { workspace = true }
2225
serde_json = { workspace = true }
2326
tauri = { workspace = true }
2427
log = { workspace = true }
2528
thiserror = { workspace = true }
2629
dunce = { workspace = true }
30+
url = { workspace = true }
2731
tauri-plugin-fs = { path = "../fs", version = "2.0.0-rc.0" }
2832

2933
[target.'cfg(target_os = "ios")'.dependencies]

0 commit comments

Comments
 (0)