A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: use FileViewer for image sharing on Android (#10018)
Kashaf Ansari7a7f0db941c3
diff --git a/apps/mobile/app/components/image-preview/index.tsx b/apps/mobile/app/components/image-preview/index.tsxindex 07b1e2023..6bc808a5e 100644--- a/apps/mobile/app/components/image-preview/index.tsx+++ b/apps/mobile/app/components/image-preview/index.tsx@@ -39,6 +39,7 @@ import Share from "react-native-share";import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";import { useSettingStore } from "../../stores/use-setting-store";import { DefaultAppStyles } from "../../utils/styles";+import FileViewer from "react-native-file-viewer";const ImagePreview = () => {const { colors } = useThemeColors("dialog");@@ -87,9 +88,8 @@ const ImagePreview = () => {return;}const attachment = await db.attachments.attachment(hash);- const path = `${cacheDir}/${- "NN_" + (await getFileNameWithExtension(hash, attachment?.mimeType))- }`;+ const path = `${cacheDir}/${"NN_" + (await getFileNameWithExtension(hash, attachment?.mimeType))+ }`;await RNFetchBlob.fs.mv(`${cacheDir}/${uri}`, path).catch(() => {/* empty */});@@ -136,17 +136,23 @@ const ImagePreview = () => {borderWidth: 0}}onPress={async () => {- useSettingStore- .getState()- .setAppDidEnterBackgroundForAction(true);- await Share.open({- url: image- }).catch(() => {- /* empty */- });- useSettingStore- .getState()- .setAppDidEnterBackgroundForAction(false);+ if (!image) return;++ try {+ if (Platform.OS === "android") {+ await FileViewer.open(image.replace("file://", ""), {+ showOpenWithDialog: true,+ showAppsSuggestions: true,+ shareFile: true+ } as any);+ } else {+ await Share.open({+ url: image+ });+ }+ } catch (error) {+ console.error(error);+ }}}/><IconButton