From c50dc4aacf3a72c28dcd0f80bc850cc4c232aa92 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Tue, 22 Nov 2022 22:16:14 +1300 Subject: [PATCH 1/2] Fix uploading and downloading sets on ios Just need to now use a library for notifications instead of my native DownloadModule --- DrawerMenu.tsx | 13 ++----------- ios/massive/Info.plist | 4 ++++ write.ts | 7 ++++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/DrawerMenu.tsx b/DrawerMenu.tsx index 68dd5c9..0189025 100644 --- a/DrawerMenu.tsx +++ b/DrawerMenu.tsx @@ -1,6 +1,5 @@ import {NavigationProp, useNavigation} from '@react-navigation/native' import {useCallback, useState} from 'react' -import {Platform} from 'react-native' import DocumentPicker from 'react-native-document-picker' import {FileSystem} from 'react-native-file-access' import {Divider, IconButton, Menu} from 'react-native-paper' @@ -154,16 +153,8 @@ export default function DrawerMenu({name}: {name: keyof DrawerParamList}) { icon="more-vert" /> }> - {Platform.OS === 'android' && ( - <> - - - - )} + + armv7 + UIFileSharingEnabled + + LSSupportsOpeningDocumentsInPlace + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/write.ts b/write.ts index 16d9387..42ad240 100644 --- a/write.ts +++ b/write.ts @@ -1,9 +1,10 @@ -import {NativeModules, PermissionsAndroid} from 'react-native' +import {NativeModules, PermissionsAndroid, Platform} from 'react-native' import {Dirs, FileSystem} from 'react-native-file-access' export const write = async (name: string, data: string) => { const filePath = `${Dirs.DocumentDir}/${name}` const permission = async () => { + if (Platform.OS !== 'android') return true const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, ) @@ -12,7 +13,7 @@ export const write = async (name: string, data: string) => { const granted = await permission() if (!granted) return await FileSystem.writeFile(filePath, data) - if (!FileSystem.exists(filePath)) return - await FileSystem.cpExternal(filePath, name, 'downloads') + if (Platform.OS === 'android') + await FileSystem.cpExternal(filePath, name, 'downloads') NativeModules.DownloadModule.show(name) } From 434f29652f849c0a2d2364d75df83852843c3346 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Tue, 22 Nov 2022 22:18:15 +1300 Subject: [PATCH 2/2] Just use a toast for download notifications The minor convenience of having that notification doesn't justify me adding the library. If I find another reason for me to have notifications then i'll do it. --- write.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/write.ts b/write.ts index 42ad240..89bd098 100644 --- a/write.ts +++ b/write.ts @@ -1,5 +1,6 @@ -import {NativeModules, PermissionsAndroid, Platform} from 'react-native' +import {PermissionsAndroid, Platform} from 'react-native' import {Dirs, FileSystem} from 'react-native-file-access' +import {toast} from './toast' export const write = async (name: string, data: string) => { const filePath = `${Dirs.DocumentDir}/${name}` @@ -15,5 +16,5 @@ export const write = async (name: string, data: string) => { await FileSystem.writeFile(filePath, data) if (Platform.OS === 'android') await FileSystem.cpExternal(filePath, name, 'downloads') - NativeModules.DownloadModule.show(name) + toast(`Downloaded ${name}`) }