From 0a92384346ecace4892a7361bc2247e7588fcf7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Gon=C3=A7alves=20Marchi?= Date: Wed, 18 Dec 2024 15:01:43 -0300 Subject: [PATCH 1/6] fix(Mobile): Fix download files from storage (#944) --- ios/App/App/Info.plist | 2 ++ ios/App/PrivacyInfo.xcprivacy | 18 +++++++++++++++ src/lib/lang/en.json | 1 + src/lib/wasm/ConstellationStore.ts | 5 ++-- src/routes/files/+page.svelte | 37 +++++++++++++++++++++++++++++- 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 ios/App/PrivacyInfo.xcprivacy diff --git a/ios/App/App/Info.plist b/ios/App/App/Info.plist index f71c543b3..1d468b3cb 100644 --- a/ios/App/App/Info.plist +++ b/ios/App/App/Info.plist @@ -24,6 +24,8 @@ UIFileSharingEnabled + LSSupportsOpeningDocumentsInPlace + UISupportsDocumentBrowser NSMicrophoneUsageDescription diff --git a/ios/App/PrivacyInfo.xcprivacy b/ios/App/PrivacyInfo.xcprivacy new file mode 100644 index 000000000..c8f5d51fa --- /dev/null +++ b/ios/App/PrivacyInfo.xcprivacy @@ -0,0 +1,18 @@ + + + + + NSPrivacyAccessedAPITypes + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + + \ No newline at end of file diff --git a/src/lib/lang/en.json b/src/lib/lang/en.json index 923d5e7c8..b88559fb7 100644 --- a/src/lib/lang/en.json +++ b/src/lib/lang/en.json @@ -189,6 +189,7 @@ "dragging_files": "Dragging {count} files for upload", "unknown": "UNKNOWN", "download": "Download", + "shareFileCanceled": "File sharing canceled", "rename": "Rename", "share": "Share", "share.selectChats": "Select Chats", diff --git a/src/lib/wasm/ConstellationStore.ts b/src/lib/wasm/ConstellationStore.ts index d3bbd3516..205d9fb2a 100644 --- a/src/lib/wasm/ConstellationStore.ts +++ b/src/lib/wasm/ConstellationStore.ts @@ -288,7 +288,7 @@ class ConstellationStore { return regex.test(path) } - async downloadFile(fileName: string): Promise> { + async downloadFile(fileName: string): Promise> { const constellation = get(this.constellationWritable) if (constellation) { try { @@ -308,8 +308,7 @@ class ConstellationStore { } } finally { const combinedArray = Buffer.concat(chunks) - const blob = new Blob([new Uint8Array(combinedArray)], { type: "application/octet-stream" }) - return success(blob) + return success(combinedArray) } } catch (error) { return failure(handleErrors(error)) diff --git a/src/routes/files/+page.svelte b/src/routes/files/+page.svelte index 3c47caa10..ecfac7813 100644 --- a/src/routes/files/+page.svelte +++ b/src/routes/files/+page.svelte @@ -25,6 +25,10 @@ import { Store } from "$lib/state/Store" import path from "path" import { MultipassStoreInstance } from "$lib/wasm/MultipassStore" + import { Share } from "@capacitor/share" + import { isAndroidOriOS } from "$lib/utils/Mobile" + import { Filesystem, Directory, Encoding } from "@capacitor/filesystem" + import { log } from "$lib/utils/Logger" export let browseFilesForChatMode: boolean = false @@ -456,7 +460,12 @@ err => { Store.addToastNotification(new ToastMessage("", err, 2)) }, - blob => { + async combinedArray => { + if (isAndroidOriOS()) { + await shareFile(fileName, combinedArray) + return + } + const blob = new Blob([new Uint8Array(combinedArray)], { type: "application/octet-stream" }) const url = URL.createObjectURL(blob) const a = document.createElement("a") a.href = url @@ -469,6 +478,32 @@ ) } + async function shareFile(fileName: string, combinedArray: Buffer) { + try { + const base64Data = combinedArray.toString("base64") + + const filePath = await Filesystem.writeFile({ + path: fileName, + data: base64Data!, + directory: Directory.Cache, + }) + + await Share.share({ + text: fileName, + url: filePath.uri, + }) + + log.info(`File shared: ${fileName} successfully`) + } catch (error) { + let errorMessage = `${error}` + log.error("Error when to share file:", fileName, "Error:", errorMessage) + if (errorMessage.includes("Share canceled")) { + Store.addToastNotification(new ToastMessage("", $_("files.shareFileCanceled"), 2)) + return + } + } + } + $: chats = UIStore.state.chats $: activeChat = Store.state.activeChat From 4347185dd8ff960be582912d9139e4cfffd084fc Mon Sep 17 00:00:00 2001 From: Luis E <35935591+luisecm@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:23:13 -0600 Subject: [PATCH 2/6] update(friends): make add friend input visible on mobile (#956) --- src/lib/lang/en.json | 4 +++- src/routes/friends/+page.svelte | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/lang/en.json b/src/lib/lang/en.json index b88559fb7..65acbd084 100644 --- a/src/lib/lang/en.json +++ b/src/lib/lang/en.json @@ -162,6 +162,7 @@ "request_sent": "You sent a request for {amount}" }, "friends": { + "copy": "Copy", "copy_did": "Copy ID", "block": "Block", "blocked": "Blocked", @@ -170,9 +171,10 @@ "all": "All", "active": "Active", "add": "Add", + "add_friend": "Add Friend", "add_someone": "Add Someone", "search_friends_placeholder": "Search friends", - "find_placeholder": "Enter Friend ID", + "find_placeholder": "Enter Friend DID", "incoming_requests": "Incoming Requests", "outgoing_requests": "Outgoing Requests", "noOutgoing": "No outbound requests.", diff --git a/src/routes/friends/+page.svelte b/src/routes/friends/+page.svelte index 4653ebc79..0dc105a7c 100644 --- a/src/routes/friends/+page.svelte +++ b/src/routes/friends/+page.svelte @@ -260,7 +260,9 @@ bind:value={requestString}> - await copy_did(false), }, ]}> - From 09073780c7d5d48116177fd95777e720d8029926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Gon=C3=A7alves=20Marchi?= Date: Wed, 18 Dec 2024 17:26:58 -0300 Subject: [PATCH 3/6] fix(Mobile): Fix camera on calls (#953) --- capacitor.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/capacitor.config.ts b/capacitor.config.ts index 5cb827470..7b42ec953 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -9,6 +9,9 @@ const config: CapacitorConfig = { launchShowDuration: 5000, launchAutoHide: true, }, + Camera: { + permissions: ["camera", "photos"], + }, }, } From 623ba643091014d5a7bbcbc2987ba83c696ed273 Mon Sep 17 00:00:00 2001 From: Flemmli97 <34157027+Flemmli97@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:29:06 +0100 Subject: [PATCH 4/6] feat(wasm): Import/export account (#893) --- .../components/settings/OrderedPhrase.svelte | 21 +- src/lib/elements/Input/FileInput.svelte | 4 +- src/lib/elements/Input/Input.svelte | 6 +- src/lib/lang/en.json | 18 ++ src/lib/layouts/login/Entrypoint.svelte | 8 +- src/lib/layouts/login/ImportAccount.svelte | 201 ++++++++++++++++++ src/lib/layouts/login/Unlock.svelte | 6 + src/lib/wasm/HandleWarpErrors.ts | 3 + src/lib/wasm/MultipassStore.ts | 24 +++ src/lib/wasm/TesseractStore.ts | 4 + src/lib/wasm/WarpStore.ts | 13 +- src/routes/auth/+page.svelte | 6 +- src/routes/settings/developer/+page.svelte | 2 +- src/routes/settings/profile/+page.svelte | 43 +++- 14 files changed, 344 insertions(+), 15 deletions(-) create mode 100644 src/lib/layouts/login/ImportAccount.svelte diff --git a/src/lib/components/settings/OrderedPhrase.svelte b/src/lib/components/settings/OrderedPhrase.svelte index 9b5dd7064..a782fbd19 100644 --- a/src/lib/components/settings/OrderedPhrase.svelte +++ b/src/lib/components/settings/OrderedPhrase.svelte @@ -2,10 +2,13 @@ import { fade } from "svelte/transition" import { animationDelay, animationDuration } from "$lib/globals/animations" import { Text, Loader } from "$lib/elements" + import Input from "$lib/elements/Input/Input.svelte" + import type { Writable } from "svelte/store" export let number: number = 0 export let word: string = "UNKNOWN" export let loading: boolean = false + export let editable: boolean = false
@@ -18,12 +21,16 @@
{/if} - + {#if loading} {:else}
- {word} + {#if editable} + + {:else} + {word} + {/if}
{/if}
@@ -64,6 +71,16 @@ display: inline-block; flex: 1; padding: var(--padding-minimal) var(--padding); + &.editable { + padding: 0; + } + } + + :global(.input-group > .input-container) { + border: none; + } + :global(.input-group > .input-container::selection) { + border: none; } } diff --git a/src/lib/elements/Input/FileInput.svelte b/src/lib/elements/Input/FileInput.svelte index 483e2f501..86446f0d1 100644 --- a/src/lib/elements/Input/FileInput.svelte +++ b/src/lib/elements/Input/FileInput.svelte @@ -3,6 +3,8 @@ export let hidden: boolean = false export let clss: string = "" + export let allowed: string | undefined = undefined + export let multiple: boolean = true const dispatch: EventDispatcher> = createEventDispatcher() @@ -24,4 +26,4 @@ } - + diff --git a/src/lib/elements/Input/Input.svelte b/src/lib/elements/Input/Input.svelte index 19f85d411..839a342e5 100644 --- a/src/lib/elements/Input/Input.svelte +++ b/src/lib/elements/Input/Input.svelte @@ -25,6 +25,7 @@ export let rich: boolean = false export let autoFocus: boolean = false export let rules: InputRules = new InputRules() + export let noCapitalize: boolean = false let errorMessage: string = "" @@ -179,6 +180,8 @@ + autofocus={isAndroidOriOS() ? isKeyboardOpened : autoFocus} + on:paste /> {#if errorMessage} diff --git a/src/lib/lang/en.json b/src/lib/lang/en.json index 65acbd084..6492f6148 100644 --- a/src/lib/lang/en.json +++ b/src/lib/lang/en.json @@ -276,6 +276,16 @@ "new": "Create New Account", "import": "Import Account", "profile": "Create new profile" + }, + "import": { + "title": "Import Account", + "description": "Import your account from remote or a backup file", + "passphrase": "Add passphrase", + "remote": "Import from remote", + "file": "Import from file", + "warning": "By continuing your old account will be overwritten!", + "fail": "Failed to import account", + "fail.null": "Failed to create identity during account import" } } }, @@ -370,6 +380,14 @@ "remove": "Your recovery phrase will not be stored anymore and will be removed. Make sure to save the phrase! This change is irreversible!", "remove.yes": "I understand", "remove.no": "Cancel" + }, + "export": { + "label": "Export", + "description": "Export your account manually to remote or a file", + "remote": "Remote", + "file": "File", + "fail": "Failed to export account", + "success": "Successfully exported account to remote" } }, "calling": { diff --git a/src/lib/layouts/login/Entrypoint.svelte b/src/lib/layouts/login/Entrypoint.svelte index 51bb5b7e7..3326a3de6 100644 --- a/src/lib/layouts/login/Entrypoint.svelte +++ b/src/lib/layouts/login/Entrypoint.svelte @@ -63,11 +63,9 @@ - {#if get(SettingsStore.state).devmode} - - {/if} + diff --git a/src/lib/layouts/login/ImportAccount.svelte b/src/lib/layouts/login/ImportAccount.svelte new file mode 100644 index 000000000..977d8b60d --- /dev/null +++ b/src/lib/layouts/login/ImportAccount.svelte @@ -0,0 +1,201 @@ + + +{#if pin.length == 0} + { + await setupTesseract(e.detail.pin) + e.detail.done() + }} /> +{:else} + +{/if} + + diff --git a/src/lib/layouts/login/Unlock.svelte b/src/lib/layouts/login/Unlock.svelte index 73c91bfc2..86ccc9fc1 100644 --- a/src/lib/layouts/login/Unlock.svelte +++ b/src/lib/layouts/login/Unlock.svelte @@ -18,6 +18,8 @@ import { ToastMessage } from "$lib/state/ui/toast" import { TesseractStoreInstance } from "$lib/wasm/TesseractStore" export let create: boolean = false + export let importing: boolean = false + const dispatch = createEventDispatcher() let loading = false @@ -119,6 +121,10 @@ {/if} + {#if importing} + {$_("pages.auth.import.warning")} + {/if} + {#if loading}