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
use file viewer to share file
ammarahm-ed6eaac23e8d03
diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.jsindex 35d636520..7eb72db65 100644--- a/apps/mobile/src/components/ExportDialog/index.js+++ b/apps/mobile/src/components/ExportDialog/index.js@@ -1,19 +1,19 @@-import React, { Fragment, useEffect, useRef, useState } from 'react';-import { Platform, StyleSheet, View } from 'react-native';+import React, {Fragment, useEffect, useRef, useState} from 'react';+import {Platform, StyleSheet, View} from 'react-native';import FileViewer from 'react-native-file-viewer';import Share from 'react-native-share';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';-import { useTracked } from '../../provider';-import { ToastEvent } from '../../services/EventManager';+import {notesnook} from '../../../e2e/test.ids';+import {useTracked} from '../../provider';+import {ToastEvent} from '../../services/EventManager';import Exporter from '../../services/Exporter';-import { getElevation } from '../../utils';-import { ph, pv, SIZE } from '../../utils/SizeUtils';-import { sleep } from '../../utils/TimeUtils';+import {getElevation} from '../../utils';+import {ph, pv, SIZE} from '../../utils/SizeUtils';+import {sleep} from '../../utils/TimeUtils';import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';-import { Button } from '../Button';+import {Button} from '../Button';import DialogHeader from '../Dialog/dialog-header';-import { PressableButton } from '../PressableButton';+import {PressableButton} from '../PressableButton';import Seperator from '../Seperator';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';@@ -237,9 +237,17 @@ const ExportDialog = () => {marginTop: 10}}onPress={async () => {- Share.open({- url:Platform.OS === "ios" ? 'file:/' + result.filePath : result.filePath- }).catch(console.log);+ if (Platform.OS === 'ios') {+ Share.open({+ url: 'file:/' + result.filePath+ }).catch(console.log);+ } else {+ FileViewer.open(result.filePath, {+ showOpenWithDialog: true,+ showAppsSuggestions: true,+ shareFile: true+ }).catch(console.log);+ }}}height={50}/>diff --git a/apps/mobile/src/components/ExportDialog/share.js b/apps/mobile/src/components/ExportDialog/share.jsindex 406ecba13..496977809 100644--- a/apps/mobile/src/components/ExportDialog/share.js+++ b/apps/mobile/src/components/ExportDialog/share.js@@ -41,8 +41,10 @@ export const ShareComponent = ({uri, name, padding}) => {marginTop: 10}}onPress={async () => {- Share.open({- url: uri+ FileViewer.open(uri, {+ showOpenWithDialog: true,+ showAppsSuggestions: true,+ shareFile: true}).catch(console.log);}}height={50}diff --git a/apps/mobile/src/components/RecoveryKeyDialog/index.js b/apps/mobile/src/components/RecoveryKeyDialog/index.jsindex 341059724..ac150eb37 100644--- a/apps/mobile/src/components/RecoveryKeyDialog/index.js+++ b/apps/mobile/src/components/RecoveryKeyDialog/index.js@@ -21,6 +21,7 @@ import {Button} from '../Button';import DialogHeader from '../Dialog/dialog-header';import Seperator from '../Seperator';import Paragraph from '../Typography/Paragraph';+import FileViewer from 'react-native-file-viewer';import * as ScopedStorage from 'react-native-scoped-storage';@@ -86,7 +87,6 @@ class RecoveryKeyDialog extends React.Component {}};async componentDidMount() {-eSubscribeEvent(eOpenRecoveryKeyDialog, this.open);}@@ -133,23 +133,26 @@ class RecoveryKeyDialog extends React.Component {RNFetchBlob = require('rn-fetch-blob').default;if (Platform.OS === 'android') {- await ScopedStorage.createDocument(+ let file = await ScopedStorage.createDocument(fileName,'text/plain',this.state.key,'utf8');+ if (!file) return;+ path = file.uri;} else {await RNFetchBlob.fs.writeFile(path + fileName, this.state.key, 'utf8');+ path = path + fileName;}ToastEvent.show({heading: 'Recovery key text file saved',- message: 'Recovery key saved in text file at ' + path + fileName,+ message: 'Recovery key saved in text file.',type: 'success',context: 'local'});- return path + fileName;+ return path;} catch (e) {alert(e.message);}@@ -169,11 +172,18 @@ class RecoveryKeyDialog extends React.Component {let path = await this.saveToTextFile();if (!path) return;try {- await Share.open({- url: Platform.OS === 'ios' ? path : 'file:/' + path,- title: 'Save recovery key to cloud',- failOnCancel: false- });+ if (Platform.OS === 'ios') {+ Share.open({+ url: 'file:/' + result.filePath,+ failOnCancel: false+ }).catch(console.log);+ } else {+ FileViewer.open(path, {+ showOpenWithDialog: true,+ showAppsSuggestions: true,+ shareFile: true+ }).catch(console.log);+ }} catch (e) {}};diff --git a/apps/mobile/src/services/Backup.js b/apps/mobile/src/services/Backup.jsindex 53ed00d51..3ae5d2a95 100644--- a/apps/mobile/src/services/Backup.js+++ b/apps/mobile/src/services/Backup.js@@ -9,6 +9,7 @@ import {Platform} from 'react-native';import {sanitizeFilename} from '../utils/filename';import * as ScopedStorage from 'react-native-scoped-storage';import {presentDialog} from '../components/Dialog/functions';+import FileViewer from 'react-native-file-viewer';const MS_DAY = 86400000;const MS_WEEK = MS_DAY * 7;@@ -126,9 +127,18 @@ async function run() {actionsArray: [{action: () => {- Share.open({- url: backupFilePath- }).catch(e => console.log);+ if (Platform.OS === 'ios') {+ Share.open({+ url: 'file:/' + backupFilePath,+ failOnCancel: false+ }).catch(console.log);+ } else {+ FileViewer.open(backupFilePath, {+ showOpenWithDialog: true,+ showAppsSuggestions: true,+ shareFile: true+ }).catch(console.log);+ }},actionText: 'Share'}diff --git a/apps/mobile/src/utils/filesystem.js b/apps/mobile/src/utils/filesystem.jsindex b6115a29f..7d38f3042 100644--- a/apps/mobile/src/utils/filesystem.js+++ b/apps/mobile/src/utils/filesystem.js@@ -37,7 +37,7 @@ async function readEncrypted(filename, key, cipherData) {}async function writeEncrypted(filename, {data, type, key}) {- console.log('file input: ', {data, type, key});+ console.log('file input: ', {type, key});let output = await Sodium.encryptFile(key, {data,@@ -46,7 +46,7 @@ async function writeEncrypted(filename, {data, type, key}) {console.log('encrypted file output: ', output);return {...output,- alg: `xcha-argon2i13`+ alg: `xcha-stream`};}