mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Merge branch 'dev_share_fix' into dev_group_chat
This commit is contained in:
commit
22f691c948
2 changed files with 16 additions and 22 deletions
|
|
@ -209,12 +209,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[self shareFile];
|
||||
}
|
||||
|
||||
- (void)sendContentText:(NSString *)text {
|
||||
if(![text isEqualToString:@""]) {
|
||||
[self sendMessage:text withExterlBodyUrl:nil withInternalURL:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)shareFile {
|
||||
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:groupName];
|
||||
|
||||
|
|
@ -227,30 +221,27 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
NSData *data = dict[@"nsData"];
|
||||
UIImage *image = [[UIImage alloc] initWithData:data];
|
||||
[self chooseImageQuality:image url:nil];
|
||||
[self sendContentText:dict[@"name"]];
|
||||
[defaults removeObjectForKey:@"img"];
|
||||
} else if(dictWeb) {
|
||||
} else if (dictWeb) {
|
||||
//share url, if local file, then upload file
|
||||
NSString *url = dictWeb[@"url"];
|
||||
NSURL *fileUrl = [NSURL fileURLWithPath:url];
|
||||
if([[fileUrl scheme]isEqualToString:@"file"]) {
|
||||
if ([url hasPrefix:@"file"]) {
|
||||
//local file
|
||||
NSData *data = dictWeb[@"nsData"];
|
||||
[self confirmShare:data url:fileUrl];
|
||||
[self confirmShare:data url:fileUrl text:nil];
|
||||
} else {
|
||||
[self sendMessage:url withExterlBodyUrl:nil withInternalURL:nil];
|
||||
[self confirmShare:nil url:nil text:url];
|
||||
}
|
||||
[self sendContentText:dictWeb[@"name"]];
|
||||
[defaults removeObjectForKey:@"web"];
|
||||
}else if(dictFile) {
|
||||
}else if (dictFile) {
|
||||
//share file
|
||||
NSData *data = dictFile[@"nsData"];
|
||||
[self confirmShare:data url:[NSURL fileURLWithPath:dictFile[@"url"]]];
|
||||
[self sendContentText:dictFile[@"name"]];
|
||||
[self confirmShare:data url:[NSURL fileURLWithPath:dictFile[@"url"]] text:nil];
|
||||
[defaults removeObjectForKey:@"mov"];
|
||||
}else if(dictText) {
|
||||
}else if (dictText) {
|
||||
//share text
|
||||
[self sendContentText:dictText[@"name"]];
|
||||
[self confirmShare:nil url:nil text:dictText[@"name"]];
|
||||
[defaults removeObjectForKey:@"text"];
|
||||
}
|
||||
}
|
||||
|
|
@ -366,13 +357,17 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
});
|
||||
}
|
||||
|
||||
- (void)confirmShare:(NSData *)data url:(NSURL *)url {
|
||||
- (void)confirmShare:(NSData *)data url:(NSURL *)url text:(NSString *)text {
|
||||
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"", nil)];
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
|
||||
[sheet addButtonWithTitle:@"send to this friend"
|
||||
block:^() {
|
||||
[self startFileUpload:data withUrl:url];
|
||||
if(data && url)
|
||||
[self startFileUpload:data withUrl:url];
|
||||
else
|
||||
[self sendMessage:text withExterlBodyUrl:nil withInternalURL:nil];
|
||||
|
||||
}];
|
||||
|
||||
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel", nil) block:nil];
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static NSString* groupName = @"group.belledonne-communications.linphone";
|
|||
} else if ([provider hasItemConformingToTypeIdentifier:@"public.plain-text"]) {
|
||||
[self loadItem:provider typeIdentifier:@"public.plain-text" defaults:defaults key:@"text"];
|
||||
} else if ([provider hasItemConformingToTypeIdentifier:@"com.adobe.pdf"]) {
|
||||
[self loadItem:provider typeIdentifier:@"com.adobe.pdf" defaults:defaults key:@"file"];
|
||||
[self loadItem:provider typeIdentifier:@"com.adobe.pdf" defaults:defaults key:@"web"];
|
||||
} else{
|
||||
NSLog(@"Unkown itemprovider = %@", provider);
|
||||
typeIdentifier = nil;
|
||||
|
|
@ -56,8 +56,7 @@ static NSString* groupName = @"group.belledonne-communications.linphone";
|
|||
NSData *nsData = [NSData dataWithContentsOfURL:(NSURL*)item];
|
||||
if (nsData) {
|
||||
NSDictionary *dict = @{@"nsData" : nsData,
|
||||
@"url" : [(NSURL*)item absoluteString],
|
||||
@"name" : self.contentText};
|
||||
@"url" : [(NSURL*)item absoluteString]};
|
||||
[defaults setObject:dict forKey:key];
|
||||
} else {
|
||||
NSLog(@"NSExtensionItem Error, provider = %@", provider);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue