fixing uri scheme for sharing images

This commit is contained in:
Roland Osborne 2023-04-22 17:40:04 -07:00
parent e3bf231b32
commit 1e232d5259
4 changed files with 15 additions and 12 deletions

View File

@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name=".MainApplication"

View File

@ -19,7 +19,6 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
useEffect(() => {
if (shareIntent) {
Alert.alert('SHARING', JSON.stringify(shareIntent));
shareIntent.forEach(share => {
if (share.text) {
actions.setMessage(share.text);
@ -27,14 +26,14 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
if (share.weblink) {
actions.setMessage(share.weblink);
}
const mimeType = share.mimeType?.toLowerCase();
if (mimeType === '.jpg' || mimeType === '.png') {
const mime = share.mimeType?.toLowerCase();
if (mime === '.jpg' || mime === '.png' || mime === 'image/jpeg' || mime == 'image/png' ) {
actions.addImage(share.filePath)
}
if (mimeType === '.mp4') {
if (mime === '.mp4' || mime === 'video/mp4' || mime == 'video/mpeg') {
actions.addVideo(share.filePath)
}
if (mimeType === '.mp3') {
if (mime === '.mp3') {
actions.addAudio(share.filePath)
}
});

View File

@ -85,20 +85,24 @@ export function useAddTopic(contentKey) {
updateState({ message });
},
addImage: (data) => {
const url = data.startsWith('file:') ? data : 'file://' + data;
assetId.current++;
Image.getSize(data, (width, height) => {
const asset = { key: assetId.current, type: 'image', data: data, ratio: width/height };
Image.getSize(url, (width, height) => {
const asset = { key: assetId.current, type: 'image', data: url, ratio: width/height };
updateState({ assets: [ ...state.assets, asset ] });
});
})
},
addVideo: (data) => {
const url = data.startsWith('file:') ? data : 'file://' + data
assetId.current++;
const asset = { key: assetId.current, type: 'video', data: data, ratio: 1, duration: 0, position: 0 };
const asset = { key: assetId.current, type: 'video', data: url, ratio: 1, duration: 0, position: 0 };
updateState({ assets: [ ...state.assets, asset ] });
},
addAudio: (data, label) => {
const url = data.startsWith('file:') ? data : 'file://' + data
assetId.current++;
const asset = { key: assetId.current, type: 'audio', data: data, label };
const asset = { key: assetId.current, type: 'audio', data: url, label };
updateState({ assets: [ ...state.assets, asset ] });
},
setVideoPosition: (key, position) => {

View File

@ -1,5 +1,4 @@
import { Text, View } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { TouchableOpacity, Alert, Text, View } from 'react-native';
import { Logo } from 'utils/Logo';
import { styles } from './SharingItem.styled';
import Colors from 'constants/Colors';