diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index 89965a457..edc5eeea6 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -112,6 +112,7 @@ @property LinphonePlayer *sharedVoicePlayer; @property BOOL showVoiceRecorderView; @property BOOL preservePendingActions; +@property BOOL *sharingMedia; // Reply @property (weak, nonatomic) IBOutlet UIView *replyView; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 308a453af..11c0a828a 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -622,9 +622,9 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)confirmShare:(NSData *)data url:(NSString *)url fileName:(NSString *)fileName { - DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:@""]; + DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Select or create a conversation to share the file(s)", nil)]; dispatch_async(dispatch_get_main_queue(), ^{ - [sheet addButtonWithTitle:NSLocalizedString(@"send to this conversation", nil) + [sheet addButtonWithTitle:NSLocalizedString(@"Send to this conversation", nil) block:^() { if (![[self.messageField text] isEqualToString:@""]) { [self sendMessageInMessageField:linphone_chat_room_create_empty_message(_chatRoom)]; @@ -812,9 +812,11 @@ static UICompositeViewDescription *compositeDescription = nil; - (IBAction)onBackClick:(id)event { NSString *previousViewName = [PhoneMainView.instance getPreviousViewName]; if ([previousViewName isEqualToString:@"ContactDetailsView"]) { + VIEW(ChatConversationView).sharingMedia = nil; ContactDetailsView *view = VIEW(ContactDetailsView); [PhoneMainView.instance popToView:view.compositeViewDescription]; } else { + VIEW(ChatConversationView).sharingMedia = nil; ChatsListView *view = VIEW(ChatsListView); [PhoneMainView.instance popToView:view.compositeViewDescription]; } diff --git a/Classes/ChatsListView.h b/Classes/ChatsListView.h index c0046957d..143c1cfcb 100644 --- a/Classes/ChatsListView.h +++ b/Classes/ChatsListView.h @@ -43,4 +43,6 @@ - (IBAction)onEditionChangeClick:(id)sender; - (IBAction)onDeleteClick:(id)sender; +-(void) mediaSharing; + @end diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index b6f9316cb..64777a552 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -58,20 +58,40 @@ forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button];*/ - BOOL forwardMode = VIEW(ChatConversationView).pendingForwardMessage != nil; + [self mediaSharing]; +} + +- (void)mediaSharing{ + BOOL forwardMode; + + 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"]; + NSDictionary *dictUrl = [defaults valueForKey:@"url"]; + if(dict||dictFile||dictUrl) VIEW(ChatConversationView).sharingMedia = TRUE; + + if(VIEW(ChatConversationView).sharingMedia == nil){ + forwardMode = VIEW(ChatConversationView).pendingForwardMessage != nil; + }else{ + forwardMode = VIEW(ChatConversationView).sharingMedia != nil; + } _tableController.editButton.hidden = forwardMode; - _forwardTitle.text = NSLocalizedString(@"Select a discussion or create a new one",nil); + if(VIEW(ChatConversationView).sharingMedia == nil){ + _forwardTitle.text = NSLocalizedString(@"Select a discussion or create a new one",nil); + } + else{ + _forwardTitle.text = NSLocalizedString(@"Select or create a conversation to share the file(s)",nil); + } _forwardTitle.hidden = !forwardMode; _cancelForwardButton.hidden = !forwardMode; _tableController.tableView.frame = CGRectMake(0, 66 + (forwardMode ? _forwardTitle.frame.size.height : 0), _tableController.tableView.frame.size.width, self.view.frame.size.height - 66 - ( forwardMode ? _forwardTitle.frame.size.height : 0 )); _addButton.frame = CGRectMake(forwardMode ? 82 : 0 , _addButton.frame.origin.y, _addButton.frame.size.width, _addButton.frame.size.height); _addGroupChatButton.frame = CGRectMake(forwardMode ? 164 : 82 , _addGroupChatButton.frame.origin.y, _addGroupChatButton.frame.size.width, _addGroupChatButton.frame.size.height); - } - - (void)displayModeChanged{ [self.tableController.tableView reloadData]; } @@ -180,8 +200,16 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onCancelForwardClicked:(id)sender { + VIEW(ChatConversationView).sharingMedia = nil; VIEW(ChatConversationView).pendingForwardMessage = nil; + NSString* groupName = [NSString stringWithFormat:@"group.%@.linphoneExtension",[[NSBundle mainBundle] bundleIdentifier]]; + NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:groupName]; + [defaults removeObjectForKey:@"photoData"]; + [defaults removeObjectForKey:@"icloudData"]; + [defaults removeObjectForKey:@"url"]; [PhoneMainView.instance popCurrentView]; } + + @end diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index f594ea452..c4f328b03 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -35,6 +35,8 @@ #import #import "linphoneapp-Swift.h" +#import "SVProgressHUD.h" + #ifdef USE_CRASHLYTICS #include "FIRApp.h" @@ -402,7 +404,15 @@ [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } else if([[url scheme] isEqualToString:@"message-linphone"]) { - [PhoneMainView.instance popToView:ChatsListView.compositeViewDescription]; + if ([[PhoneMainView.instance currentView] equal:ChatsListView.compositeViewDescription]) { + VIEW(ChatConversationView).sharingMedia = TRUE; + ChatsListView *view = VIEW(ChatsListView); + [view mediaSharing]; + }else{ + [SVProgressHUD dismiss]; + VIEW(ChatConversationView).sharingMedia = TRUE; + [PhoneMainView.instance popToView:ChatsListView.compositeViewDescription]; + } } else if ([scheme isEqualToString:@"sip"]||[scheme isEqualToString:@"sips"]) { // remove "sip://" from the URI, and do it correctly by taking resourceSpecifier and removing leading and // trailing "/" diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 854d72c36..df6b3617f 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -453,9 +453,19 @@ static RootViewManager *rootViewManagerInstance = nil; LinphoneManager *lm = LinphoneManager.instance; LOGI(@"%s", linphone_global_state_to_string(linphone_core_get_global_state(LC))); + 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"]; + NSDictionary *dictUrl = [defaults valueForKey:@"url"]; + // If we've been started by a remote push notification, // we'll already be on the corresponding chat conversation view, no need to go anywhere else - if (![[self currentView].name isEqualToString:@"ChatConversationView"]) { + if (dict||dictFile||dictUrl){ + [self changeCurrentView:ChatsListView.compositeViewDescription]; + }else if (![[self currentView].name isEqualToString:@"ChatConversationView"]) { if (linphone_core_get_global_state(LC) != LinphoneGlobalOn) { [self changeCurrentView:DialerView.compositeViewDescription]; @@ -607,7 +617,8 @@ static RootViewManager *rootViewManagerInstance = nil; } [self _changeCurrentView:viewStack.lastObject ?: DialerView.compositeViewDescription transition:[PhoneMainView getBackwardTransition] - animated:ANIMATED]; + animated:ANIMATED + addViewToStack:FALSE]; return [mainViewController getCurrentViewController]; } @@ -621,24 +632,27 @@ static RootViewManager *rootViewManagerInstance = nil; - (void)changeCurrentView:(UICompositeViewDescription *)view { - [self _changeCurrentView:view transition:nil animated:ANIMATED]; + [self _changeCurrentView:view transition:nil animated:ANIMATED addViewToStack:TRUE]; } - (UIViewController *)_changeCurrentView:(UICompositeViewDescription *)view transition:(CATransition *)transition - animated:(BOOL)animated { + animated:(BOOL)animated + addViewToStack:(BOOL)addViewToStack { PhoneMainView *vc = [[RootViewManager instance] setViewControllerForDescription:view]; + LOGI(@"_changeCurrentView : stack size before = %d", [RootViewManager instance].viewDescriptionStack.count); if (![view equal:vc.currentView] || vc != self) { LOGI(@"Change current view to %@", view.name); [self setPreviousViewName:vc.currentView.name]; NSMutableArray *viewStack = [RootViewManager instance].viewDescriptionStack; - [viewStack addObject:view]; + if (addViewToStack) [viewStack addObject:view]; if (animated && transition == nil) transition = [PhoneMainView getTransition:vc.currentView new:view]; [vc.mainViewController setViewTransition:(animated ? transition : nil)]; [vc.mainViewController changeView:view]; vc->currentView = view; } + LOGI(@"_changeCurrentView : stack size after = %d", [RootViewManager instance].viewDescriptionStack.count); //[[RootViewManager instance] setViewControllerForDescription:view]; @@ -653,7 +667,7 @@ static RootViewManager *rootViewManagerInstance = nil; while (viewStack.count > 0 && ![[viewStack lastObject] equal:view]) { [viewStack removeLastObject]; } - return [self _changeCurrentView:view transition:[PhoneMainView getBackwardTransition] animated:ANIMATED]; + return [self _changeCurrentView:view transition:[PhoneMainView getBackwardTransition] animated:ANIMATED addViewToStack:FALSE]; } - (void) setPreviousViewName:(NSString*)previous{ diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings index c03e8242c..da2f63ca4 100644 Binary files a/Resources/fr.lproj/Localizable.strings and b/Resources/fr.lproj/Localizable.strings differ