Do not save photos and videos taken from Linphone if auto save to gallery is off

This commit is contained in:
Christophe Deschamps 2022-02-24 15:57:21 +01:00
parent 8a86ce82f8
commit 9740a18219
2 changed files with 9 additions and 5 deletions

View file

@ -988,9 +988,11 @@ static UICompositeViewDescription *compositeDescription = nil;
});
}];
if (![info valueForKey:UIImagePickerControllerReferenceURL]) {
BOOL saveToGallery = [ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"];
if (![info valueForKey:UIImagePickerControllerReferenceURL] && saveToGallery) {
[self writeVideoToGallery:mediaURL];
}
}
}
+ (void)writeMediaToGallery:(NSString *)name fileType:(NSString *)fileType {
@ -1077,6 +1079,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
-(void) writeVideoToGallery:(NSURL *)url {
NSString *localIdentifier;
PHFetchResult<PHAssetCollection *> *assetCollections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
for (PHAssetCollection *assetCollection in assetCollections) {

View file

@ -183,13 +183,13 @@ static UICompositeViewDescription *compositeDescription = nil;
PHFetchResult<PHAsset *> *phFetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[alassetURL] options:nil];
phasset = [phFetchResult firstObject];
}
BOOL saveToGallery = [ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"];
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage] ? [info objectForKey:UIImagePickerControllerEditedImage] : [info objectForKey:UIImagePickerControllerOriginalImage];
if (!phasset) {
if (!phasset && saveToGallery) {
[self writeImageToGallery:image];
return;
}
[self passImageToDelegate:image PHAssetId:[phasset localIdentifier]];
[self passImageToDelegate:image PHAssetId:saveToGallery ? [phasset localIdentifier] : nil];
}
});
@ -197,6 +197,7 @@ static UICompositeViewDescription *compositeDescription = nil;
-(void) writeImageToGallery:(UIImage *)image {
NSString *localIdentifier;
[SVProgressHUD show];