diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a5faa587..46aadb4a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,9 +8,9 @@ android:protectionLevel="signature" /> - + diff --git a/package.json b/package.json index 74a25dbb..3c56f3c6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "StandardNotes", - "version": "3.6.13", - "user-version": "3.6.13", + "version": "3.6.14", + "user-version": "3.6.14", "private": true, "license": "AGPL-3.0-or-later", "scripts": { @@ -26,7 +26,7 @@ "@react-navigation/native": "^5.9.3", "@react-navigation/stack": "^5.14.3", "@standardnotes/sncrypto-common": "1.2.9", - "@standardnotes/snjs": "2.7.4", + "@standardnotes/snjs": "2.7.5", "js-base64": "^3.5.2", "moment": "^2.29.1", "react": "17.0.1", diff --git a/src/lib/backups_service.ts b/src/lib/backups_service.ts index d7bdac8a..d5c44894 100644 --- a/src/lib/backups_service.ts +++ b/src/lib/backups_service.ts @@ -5,7 +5,7 @@ import { Platform, } from '@standardnotes/snjs'; import { Base64 } from 'js-base64'; -import { Alert, Share } from 'react-native'; +import { Alert, PermissionsAndroid, Share } from 'react-native'; import FileViewer from 'react-native-file-viewer'; import RNFS from 'react-native-fs'; import Mailer from 'react-native-mail'; @@ -44,8 +44,7 @@ export class BackupsService extends ApplicationService { filename ); } else if (result === 'save') { - let filepath = await this._exportAndroid(filename, stringifiedData); - return this._showFileSavePromptAndroid(filepath); + await this._exportAndroid(filename, stringifiedData); } else { return; } @@ -92,10 +91,25 @@ export class BackupsService extends ApplicationService { } private async _exportAndroid(filename: string, data: string) { - const filepath = `${RNFS.ExternalDirectoryPath}/${filename}`; - return RNFS.writeFile(filepath, data).then(() => { - return filepath; - }); + const filepath = `${RNFS.DownloadDirectoryPath}/${filename}`; + try { + const granted = await PermissionsAndroid.request( + PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE + ); + if (granted === PermissionsAndroid.RESULTS.GRANTED) { + await RNFS.writeFile(filepath, data); + this._showFileSavePromptAndroid(filepath); + } else { + this.application.alertService.alert( + 'We need permission to write to the external storage in order to save your backup file.' + ); + } + } catch (err) { + console.log('Error exporting backup', err); + this.application.alertService.alert( + 'There was an issue exporting your backup.' + ); + } } private async _openFileAndroid(filepath: string) { diff --git a/yarn.lock b/yarn.lock index b17ea982..e4fcfab6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1630,10 +1630,10 @@ resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.2.9.tgz#5212a959e4ec563584e42480bfd39ef129c3cbdf" integrity sha512-xJ5IUGOZztjSgNP/6XL+Ut5+q9UgSTv6xMtKkcQC5aJxCOkJy9u6RamPLdF00WQgwibxx2tu0e43bKUjTgzMig== -"@standardnotes/snjs@2.7.4": - version "2.7.4" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.4.tgz#0da670ab2cb76918fb6e75d57e5c00dfe82da196" - integrity sha512-UUNcXEdjX63YU0yBezwVVlvJ5HTic8l/CLqgjWrbsVAfPPJ8WC8FmGcv3yBOc+d56qgp+Tg1LMySYaOs67JRCw== +"@standardnotes/snjs@2.7.5": + version "2.7.5" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.5.tgz#5ac5d071912a974acda73bb0720fa66bc5c14448" + integrity sha512-I15S2pwh+7w7pExnXJAUkLmhTySgMdnpUDEpKceufH9uUVvgdsZdz+Kfapv5/pFGOMBL3iDrY30anUSJWSsO1Q== dependencies: "@standardnotes/auth" "^2.0.0" "@standardnotes/sncrypto-common" "^1.2.9"