From 8ffa05b301c7e175be33b9bea0ff61c5fc2aa2a7 Mon Sep 17 00:00:00 2001 From: Davide Garberi Date: Fri, 17 Jan 2025 16:57:50 +0100 Subject: [PATCH] app: Add support for local sync provider on Android --- app/src/config/repos.ts | 37 +++++++++++++++++++++++++-- app/src/protyle/util/compatibility.ts | 8 ++++++ app/src/types/index.d.ts | 1 + 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/src/config/repos.ts b/app/src/config/repos.ts index 9a8dc117627..7f63fdbeee3 100644 --- a/app/src/config/repos.ts +++ b/app/src/config/repos.ts @@ -4,7 +4,7 @@ import {showMessage} from "../dialog/message"; import {bindSyncCloudListEvent, getSyncCloudList} from "../sync/syncGuide"; import {processSync} from "../dialog/processSystem"; import {getCloudURL} from "./util/about"; -import {openByMobile} from "../protyle/util/compatibility"; +import {externalFolderPickerMobile, isInAndroid, openByMobile} from "../protyle/util/compatibility"; import {confirmDialog} from "../dialog/confirmDialog"; import {isKernelInMobile} from "../util/functions"; @@ -180,13 +180,38 @@ const renderProvider = (provider: number) => { `; } else if (provider === 4) { - if (isKernelInMobile()) { + if (isKernelInMobile() && !isInAndroid()) { return `
${window.siyuan.languages.syncThirdPartyProviderLocalIntro}
${window.siyuan.languages.proFeature}
${window.siyuan.languages.deviceNotSupport} +
`; + } + else if (isInAndroid()) { + return `
+ ${window.siyuan.languages.syncThirdPartyProviderLocalIntro} +
+ ${window.siyuan.languages.proFeature} +
+
+
Endpoint
+
+
+ + +
+
+
+
Timeout (s)
+
+ +
+
+
Concurrent Reqs
+
+
`; } return `
@@ -623,6 +648,14 @@ export const repos = { fetchPost("/api/repo/purgeCloudRepo"); }); break; + } else if (action === "folderSelectionDialog") { + const selectedPath = externalFolderPickerMobile(); + const endpointInput = target.parentElement.querySelector("#endpoint") as HTMLInputElement; + if (endpointInput && selectedPath) { + endpointInput.value = selectedPath; + endpointInput.dispatchEvent(new Event('blur')); + } + break; } target = target.parentElement; } diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index ecacc1bfca3..70cf82974e4 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -30,6 +30,14 @@ export const openByMobile = (uri: string) => { } }; +export const externalFolderPickerMobile = () => { + if (isInAndroid()) { + return window.JSAndroid.getLocalFileSystemPath(); + } + + return null +}; + export const readText = () => { if (isInAndroid()) { return window.JSAndroid.readClipboard(); diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 9d1b73096dd..c1a6075c018 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -192,6 +192,7 @@ interface Window { writeImageClipboard(uri: string): void readClipboard(): string getBlockURL(): string + getLocalFileSystemPath(): string } JSHarmony: { openExternal(url: string): void