Document sharing within app + Take video from app + Store shot photo & video inside separate album (name by the app) + fix the choose image quality Action sheet on BG thread with long waiting

This commit is contained in:
Christophe Deschamps 2019-04-01 21:45:24 +02:00 committed by Danmei Chen
parent b8051bdd99
commit b35c949a87
11 changed files with 271 additions and 67 deletions

View file

@ -47,7 +47,7 @@
@interface ChatConversationView
: TPMultiLayoutViewController <HPGrowingTextViewDelegate, UICompositeViewDelegate, ImagePickerDelegate, ChatConversationDelegate,
UIDocumentInteractionControllerDelegate, UISearchBarDelegate, UIImageViewDeletableDelegate,QLPreviewControllerDelegate, UICollectionViewDataSource> {
UIDocumentInteractionControllerDelegate, UISearchBarDelegate, UIImageViewDeletableDelegate,QLPreviewControllerDelegate, UICollectionViewDataSource,UIDocumentMenuDelegate,UIDocumentPickerDelegate> {
OrderedDictionary *imageQualities;
BOOL scrollOnGrowingEnabled;
BOOL composingVisible;

View file

@ -25,6 +25,8 @@
#import "FileTransferDelegate.h"
#import "UIChatBubbleTextCell.h"
#import "DevicesListView.h"
#import "SVProgressHUD.h"
@implementation PreviewItem
- (instancetype)initPreviewURL:(NSURL *)docURL
@ -189,6 +191,8 @@ static UICompositeViewDescription *compositeDescription = nil;
}
completion:nil];
}
[self configureForRoom:self.editing];
}
- (void)viewWillDisappear:(BOOL)animated {
@ -281,6 +285,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)shareFile {
NSString* groupName = [NSString stringWithFormat:@"group.%@.linphoneExtension",[[NSBundle mainBundle] bundleIdentifier]];
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:groupName];
NSDictionary *dict = [defaults valueForKey:@"photoData"];
NSDictionary *dictFile = [defaults valueForKey:@"icloudData"];
@ -391,6 +396,9 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)chooseImageQuality:(UIImage *)image assetId:(NSString *)phAssetId {
[SVProgressHUD show];
NSMutableDictionary *optionsBlock = [[NSMutableDictionary alloc] init];
NSMutableDictionary *optionsText = [[NSMutableDictionary alloc] init];
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Choose the image size", nil)];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for (NSString *key in [imageQualities allKeys]) {
@ -398,13 +406,17 @@ static UICompositeViewDescription *compositeDescription = nil;
NSData *data = UIImageJPEGRepresentation(image, [quality floatValue]);
NSNumber *size = [NSNumber numberWithInteger:[data length]];
NSString *text = [NSString stringWithFormat:@"%@ (%@)", key, [size toHumanReadableSize]];
[sheet addButtonWithTitle:text
block:^() {
[self saveAndSend:image assetId:phAssetId withQuality:[quality floatValue]];
}];
[optionsBlock setObject:^() {
[self saveAndSend:image assetId:phAssetId withQuality:[quality floatValue]];
} forKey:key];
[optionsText setObject:text forKey:key];
}
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel", nil) block:nil];
dispatch_async(dispatch_get_main_queue(), ^{
for (NSString *key in [imageQualities allKeys]) {
[sheet addButtonWithTitle:[optionsText objectForKey:key] block:[optionsBlock objectForKey:key]];
}
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel", nil) block:nil];
[SVProgressHUD dismiss];
[sheet showInView:PhoneMainView.instance.view];
});
});
@ -694,7 +706,8 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onPictureClick:(id)event {
[_messageField resignFirstResponder];
[ImagePickerView SelectImageFromDevice:self atPosition:_pictureButton inView:self.view];
[ImagePickerView SelectImageFromDevice:self atPosition:_pictureButton inView:self.view withDocumentMenuDelegate:self];
}
- (IBAction)onInfoClick:(id)sender {
@ -775,6 +788,83 @@ static UICompositeViewDescription *compositeDescription = nil;
[self chooseImageQuality:image assetId:phAssetId];
}
- (void)imagePickerDelegateVideo:(NSURL*)url info:(NSDictionary *)info {
NSURL * mediaURL = [info objectForKey:UIImagePickerControllerMediaURL];
[SVProgressHUD show];
AVAsset *video = [AVAsset assetWithURL:mediaURL];
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:video presetName:AVAssetExportPresetMediumQuality];
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeMPEG4;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localname = [[[mediaURL absoluteString] md5] stringByAppendingString:@".mp4"];
NSURL *compressedVideoUrl=[[NSURL fileURLWithPath:documentsDirectory] URLByAppendingPathComponent:localname];
exportSession.outputURL = compressedVideoUrl;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
[self startFileUpload:[NSData dataWithContentsOfURL:compressedVideoUrl] withName:localname];
});
}];
if (![info valueForKey:UIImagePickerControllerReferenceURL]) {
[self writeVideoToGallery:mediaURL];
}
}
-(void) writeVideoToGallery:(NSURL *)url {
NSString *localIdentifier;
PHFetchResult<PHAssetCollection *> *assetCollections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
for (PHAssetCollection *assetCollection in assetCollections) {
if([[assetCollection localizedTitle] isEqualToString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]] ){
localIdentifier = assetCollection.localIdentifier;
break;
}
}
if(localIdentifier ){
PHFetchResult *fetchResult = [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[localIdentifier] options:nil];
PHAssetCollection *assetCollection = fetchResult.firstObject;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:url];
PHAssetCollectionChangeRequest *assetCollectionChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:assetCollection];
[assetCollectionChangeRequest addAssets:@[[assetChangeRequest placeholderForCreatedAsset]]];
} completionHandler:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"Error creating asset: %@", error);
}
}];
}else{
__block PHObjectPlaceholder *albumPlaceholder;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCollectionChangeRequest *changeRequest = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]];
albumPlaceholder = changeRequest.placeholderForCreatedAssetCollection;
} completionHandler:^(BOOL success, NSError *error) {
if (success) {
PHFetchResult *fetchResult = [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[albumPlaceholder.localIdentifier] options:nil];
PHAssetCollection *assetCollection = fetchResult.firstObject;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:url];
PHAssetCollectionChangeRequest *assetCollectionChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:assetCollection];
[assetCollectionChangeRequest addAssets:@[[assetChangeRequest placeholderForCreatedAsset]]];
} completionHandler:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"Error creating asset: %@", error);
}
}];
} else {
NSLog(@"Error creating album: %@", error);
}
}];
}
}
- (void)tableViewIsScrolling {
// if user is scrolling in table view, we should hide the keyboard
if ([_messageField isFirstResponder]) {
@ -1336,6 +1426,20 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
}
}
-(void) documentMenu:(UIDocumentMenuViewController *)documentMenu didPickDocumentPicker:(UIDocumentPickerViewController *)documentPicker {
documentPicker.delegate = self;
[PhoneMainView.instance presentViewController:documentPicker animated:YES completion:nil];
}
-(void) documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
[url startAccessingSecurityScopedResource];
NSFileCoordinator *co =[[NSFileCoordinator alloc] init];
NSError *error = nil;
[co coordinateReadingItemAtURL:url options:0 error:&error byAccessor:^(NSURL * _Nonnull newURL) {
[self startFileUpload:[NSData dataWithContentsOfURL:newURL] withName:[newURL lastPathComponent]];
}];
[url stopAccessingSecurityScopedResource];
}
@end

View file

@ -526,7 +526,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onAvatarClick:(id)sender {
[LinphoneUtils findAndResignFirstResponder:self.view];
if (_tableController.isEditing) {
[ImagePickerView SelectImageFromDevice:self atPosition:_avatarImage inView:self.view];
[ImagePickerView SelectImageFromDevice:self atPosition:_avatarImage inView:self.view withDocumentMenuDelegate:nil];
}
}
@ -586,5 +586,8 @@ static UICompositeViewDescription *compositeDescription = nil;
[_avatarImage setImage:[FastAddressBook imageForContact:_contact] bordered:NO withRoundedRadius:YES];
}
- (void)imagePickerDelegateVideo:(NSURL*)url info:(NSDictionary *)info {
return;
}
@end

View file

@ -22,7 +22,7 @@
@protocol ImagePickerDelegate <NSObject>
- (void)imagePickerDelegateImage:(UIImage *)image info:(NSString *)phAssetId;
- (void)imagePickerDelegateVideo:(NSURL*)url info:(NSDictionary *)info;
@end
@interface ImagePickerView : UIViewController <UICompositeViewDelegate, UINavigationControllerDelegate,
@ -38,7 +38,8 @@
@property(nonatomic, readonly) UIPopoverController *popoverController;
+ (void)SelectImageFromDevice:(id<ImagePickerDelegate>)delegate
atPosition:(UIView *)ipadPopoverPosition
inView:(UIView *)view;
atPosition:(UIView *)ipadPopoverView
inView:(UIView *)ipadView
withDocumentMenuDelegate:(id<UIDocumentMenuDelegate>)documentMenuDelegate;
@end

View file

@ -22,6 +22,9 @@
#import <AVFoundation/AVFoundation.h>
#import "ImagePickerView.h"
#import "PhoneMainView.h"
#import "SVProgressHUD.h"
#import "ShareViewController.h"
@implementation ImagePickerView
@ -160,40 +163,112 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark - UIImagePickerControllerDelegate Functions
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismiss];
NSURL *alassetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
PHAsset *phasset = nil;
// when photo from camera, it hasn't be saved
if (alassetURL) {
PHFetchResult<PHAsset *> *phFetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[alassetURL] options:nil];
phasset = [phFetchResult firstObject];
}
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage] ? [info objectForKey:UIImagePickerControllerEditedImage] : [info objectForKey:UIImagePickerControllerOriginalImage];
if (!phasset) {
__block PHObjectPlaceholder *placeHolder;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAssetFromImage:image];
placeHolder = [request placeholderForCreatedAsset];
} completionHandler:^(BOOL success, NSError *error) {
if (success) {
LOGI(@"Image saved to [%@]", [placeHolder localIdentifier]);
[self passImageToDelegate:image PHAssetId:[placeHolder localIdentifier]];
} else {
LOGE(@"Cannot save image data downloaded [%@]", [error localizedDescription]);
}
}
];
return;
}
[self passImageToDelegate:image PHAssetId:[phasset localIdentifier]];
dispatch_async(dispatch_get_main_queue(), ^{
[self dismiss];
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
if ([type isEqualToString:(NSString *)kUTTypeVideo] ||
[type isEqualToString:(NSString *)kUTTypeMovie]) {
NSURL *urlvideo = [info objectForKey:UIImagePickerControllerMediaURL];
if(urlvideo != nil && self.imagePickerDelegate != nil) {
[imagePickerDelegate imagePickerDelegateVideo:urlvideo info:info];
}
} else {
NSURL *alassetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
PHAsset *phasset = nil;
// when photo from camera, it hasn't be saved
if (alassetURL) {
PHFetchResult<PHAsset *> *phFetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[alassetURL] options:nil];
phasset = [phFetchResult firstObject];
}
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage] ? [info objectForKey:UIImagePickerControllerEditedImage] : [info objectForKey:UIImagePickerControllerOriginalImage];
if (!phasset) {
[self writeImageToGallery:image];
return;
}
[self passImageToDelegate:image PHAssetId:[phasset localIdentifier]];
}
});
}
-(void) writeImageToGallery:(UIImage *)image {
NSString *localIdentifier;
[SVProgressHUD show];
PHFetchResult<PHAssetCollection *> *assetCollections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
__block PHObjectPlaceholder *placeHolder;
for (PHAssetCollection *assetCollection in assetCollections) {
if([[assetCollection localizedTitle] isEqualToString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]] ){
localIdentifier = assetCollection.localIdentifier;
break;
}
}
if(localIdentifier ){
PHFetchResult *fetchResult = [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[localIdentifier] options:nil];
PHAssetCollection *assetCollection = fetchResult.firstObject;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
PHAssetCollectionChangeRequest *assetCollectionChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:assetCollection];
[assetCollectionChangeRequest addAssets:@[[assetChangeRequest placeholderForCreatedAsset]]];
placeHolder = [assetChangeRequest placeholderForCreatedAsset];
} completionHandler:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
if (!success) {
NSLog(@"Error creating asset: %@", error);
} else {
[self passImageToDelegate:image PHAssetId:[placeHolder localIdentifier]];
}
});
}];
}else{
__block PHObjectPlaceholder *albumPlaceholder;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCollectionChangeRequest *changeRequest = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]];
albumPlaceholder = changeRequest.placeholderForCreatedAssetCollection;
} completionHandler:^(BOOL success, NSError *error) {
if (success) {
PHFetchResult *fetchResult = [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[albumPlaceholder.localIdentifier] options:nil];
PHAssetCollection *assetCollection = fetchResult.firstObject;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
PHAssetCollectionChangeRequest *assetCollectionChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:assetCollection];
[assetCollectionChangeRequest addAssets:@[[assetChangeRequest placeholderForCreatedAsset]]];
placeHolder = [assetChangeRequest placeholderForCreatedAsset];
} completionHandler:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
if (!success) {
NSLog(@"Error creating asset: %@", error);
} else {
[self passImageToDelegate:image PHAssetId:[placeHolder localIdentifier]];
}
});
}];
} else {
[SVProgressHUD dismiss];
NSLog(@"Error creating album: %@", error);
}
}];
}
}
- (void) passImageToDelegate:(UIImage *)image PHAssetId:(NSString *)assetId {
if (imagePickerDelegate != nil) {
[imagePickerDelegate imagePickerDelegateImage:image info:(NSString *)assetId];
}
if (imagePickerDelegate != nil) {
[imagePickerDelegate imagePickerDelegateImage:image info:(NSString *)assetId];
}
}
/*
if (imagePickerDelegate != nil) {
@ -223,14 +298,15 @@ static UICompositeViewDescription *compositeDescription = nil;
+ (void)SelectImageFromDevice:(id<ImagePickerDelegate>)delegate
atPosition:(UIView *)ipadPopoverView
inView:(UIView *)ipadView {
inView:(UIView *)ipadView
withDocumentMenuDelegate:(id<UIDocumentMenuDelegate>)documentMenuDelegate {
void (^block)(UIImagePickerControllerSourceType) = ^(UIImagePickerControllerSourceType type) {
ImagePickerView *view = VIEW(ImagePickerView);
view.sourceType = type;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
view.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
view.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,(NSString *)kUTTypeImage,nil];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
@ -271,6 +347,12 @@ static UICompositeViewDescription *compositeDescription = nil;
block(UIImagePickerControllerSourceTypePhotoLibrary);
}];
}
if (documentMenuDelegate) {
[sheet addButtonWithTitle:NSLocalizedString(@"Document",nil) block:^(){
[self pickDocumentForDelegate:documentMenuDelegate];
}];
}
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel", nil) block:nil];
[sheet showInView:PhoneMainView.instance.view];
@ -295,6 +377,11 @@ static UICompositeViewDescription *compositeDescription = nil;
block(UIImagePickerControllerSourceTypePhotoLibrary);
}];
}
if (documentMenuDelegate) {
[sheet addButtonWithTitle:NSLocalizedString(@"Document",nil) block:^(){
[self pickDocumentForDelegate:documentMenuDelegate];
}];
}
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel", nil) block:nil];
[sheet showInView:PhoneMainView.instance.view];
@ -306,4 +393,10 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
+(void) pickDocumentForDelegate:(id<UIDocumentMenuDelegate>)documentMenuDelegate {
UIDocumentMenuViewController *documentProviderMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:SUPPORTED_EXTENTIONS inMode:UIDocumentPickerModeImport];
documentProviderMenu.delegate = documentMenuDelegate;
[PhoneMainView.instance presentViewController:documentProviderMenu animated:YES completion:nil];
}
@end

View file

@ -90,7 +90,7 @@
if (!IPAD) {
[PhoneMainView.instance.mainViewController hideSideMenu:YES];
}
[ImagePickerView SelectImageFromDevice:self atPosition:_avatarImage inView:self.view];
[ImagePickerView SelectImageFromDevice:self atPosition:_avatarImage inView:self.view withDocumentMenuDelegate:nil];
}
- (IBAction)onBackgroundClicked:(id)sender {
@ -126,4 +126,8 @@
}
}
- (void)imagePickerDelegateVideo:(NSURL*)url info:(NSDictionary *)info {
return; // Avatar video not supported (yet ;) )
}
@end

View file

@ -176,4 +176,4 @@
}
}
@end
@end

View file

@ -32,9 +32,9 @@ target 'latestChatroomsWidget' do
use_frameworks!
# Pods for latestChatroomsWidget
end
target 'liblinphoneTester' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
@ -55,6 +55,7 @@ target 'linphone' do
# Pods for linphone
basic_pods
pod 'SVProgressHUD'
target 'linphoneTests' do
inherit! :search_paths

View file

@ -4498,6 +4498,7 @@
"${PODS_ROOT}/linphone-sdk/linphone-sdk/apple-darwin/Frameworks/mswebrtc.framework",
"${PODS_ROOT}/linphone-sdk/linphone-sdk/apple-darwin/Frameworks/msx264.framework",
"${PODS_ROOT}/linphone-sdk/linphone-sdk/apple-darwin/Frameworks/ortp.framework",
"${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
@ -4517,6 +4518,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mswebrtc.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/msx264.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ortp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVProgressHUD.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;

View file

@ -8,6 +8,9 @@
#import <UIKit/UIKit.h>
#import <Social/Social.h>
#define SUPPORTED_EXTENTIONS @[@"public.jpeg",@"com.compuserve.gif",@"public.url",@"public.movie",@"com.apple.mapkit.map-item",@"com.adobe.pdf",@"public.png",@"public.image"]
@interface ShareViewController : SLComposeServiceViewController
@end

View file

@ -18,8 +18,10 @@
return YES;
}
- (void)didSelectPost {
NSString* groupName = [NSString stringWithFormat:@"group.%@",[[NSBundle mainBundle] bundleIdentifier]];
NSLog(@"[SHARE EXTENSTION] using group name inside EXTENSION %@",groupName);
// This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
BOOL support = TRUE;
// Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
@ -28,26 +30,17 @@
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:groupName];
// TODO: Use [provider registeredTypeIdentifiersWithFileOptions:0]; to get all type identifiers of the provider instead of this if/else if structure
support = TRUE;
if ([provider hasItemConformingToTypeIdentifier:@"public.jpeg"]) {
[self loadItem:provider typeIdentifier:@"public.jpeg" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"com.compuserve.gif"]) {
[self loadItem:provider typeIdentifier:@"com.compuserve.gif" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"public.url"]) {
[self loadItem:provider typeIdentifier:@"public.url" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"public.movie"]) {
[self loadItem:provider typeIdentifier:@"public.movie" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"com.apple.mapkit.map-item"]) {
[self loadItem:provider typeIdentifier:@"com.apple.mapkit.map-item" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"com.adobe.pdf"]) {
[self loadItem:provider typeIdentifier:@"com.adobe.pdf" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"public.png"]) {
[self loadItem:provider typeIdentifier:@"public.png" defaults:defaults];
} else if ([provider hasItemConformingToTypeIdentifier:@"public.image"]) {
[self loadItem:provider typeIdentifier:@"public.image" defaults:defaults];
}else{
NSLog(@"Unkown itemprovider = %@", provider);
support = false;
}
bool found = false;
for (NSString *ti in SUPPORTED_EXTENTIONS) {
if ([provider hasItemConformingToTypeIdentifier:ti]) {
found=true;
[self loadItem:provider typeIdentifier:ti defaults:defaults];
}
}
if (!found){
NSLog(@"Unkown itemprovider = %@", provider);
support = false;
}
}
}
if (!support)