compability of photo library with previous linphone version

This commit is contained in:
Danmei Chen 2018-12-07 15:40:56 +01:00
parent db6dccbcd4
commit 52d83cc40e
4 changed files with 15 additions and 3 deletions

View file

@ -157,6 +157,7 @@ typedef struct _LinphoneManagerSounds {
- (void)configureVbrCodecs;
+ (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override;
+ (PHFetchResult *)getPHAssets:(NSString *)key;
+ (NSString*)bundleFile:(NSString*)file;
+ (NSString*)documentFile:(NSString*)file;
+ (NSString*)cacheDirectory;

View file

@ -2844,6 +2844,16 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
}
#pragma mark - Misc Functions
+ (PHFetchResult *)getPHAssets:(NSString *)key {
PHFetchResult<PHAsset *> *assets;
if ([key hasPrefix:@"assets-library"]) {
// compability with previous linphone version
assets = [PHAsset fetchAssetsWithALAssetURLs:@[[NSURL URLWithString:key]] options:nil];
} else {
assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:key] options:nil];
}
return assets;
}
+ (NSString *)bundleFile:(NSString *)file {
return [[NSBundle mainBundle] pathForResource:[file stringByDeletingPathExtension] ofType:[file pathExtension]];

View file

@ -215,7 +215,7 @@
- (void)loadFirstImage:(NSString *)key type:(PHAssetMediaType)type {
[_messageImageView startLoading];
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:key] options:nil];
PHFetchResult<PHAsset *> *assets = [LinphoneManager getPHAssets:key];
UIImage *img = nil;
img = [chatTableView.imagesInChatroom objectForKey:key];

View file

@ -333,7 +333,8 @@
[_chatRoomDelegate startImageUpload:img assetId:localImage withQuality:(uploadQuality ? [uploadQuality floatValue] : 0.9)];
});
} else {
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil];
PHFetchResult<PHAsset *> *assets = [LinphoneManager getPHAssets:localImage];
if (![assets firstObject])
return;
PHAsset *asset = [assets firstObject];
@ -505,7 +506,7 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 44; // 44;
}
PHFetchResult<PHAsset *> *assets;
if(localImage)
assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil];
assets = [LinphoneManager getPHAssets:localImage];
else
assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localVideo] options:nil];
if (![assets firstObject]) {