diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 823bf1742..32fcc854a 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -781,7 +781,14 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Action Functions - (IBAction)onBackClick:(id)event { - [PhoneMainView.instance popCurrentView]; + NSString *previousViewName = [PhoneMainView.instance getPreviousViewName]; + if ([previousViewName isEqualToString:@"ContactDetailsView"]) { + ContactDetailsView *view = VIEW(ContactDetailsView); + [PhoneMainView.instance popToView:view.compositeViewDescription]; + } else { + ChatsListView *view = VIEW(ChatsListView); + [PhoneMainView.instance popToView:view.compositeViewDescription]; + } } - (IBAction)onEditClick:(id)event { @@ -1773,7 +1780,14 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog if (indexPath.row == 0) { if (isOneToOne) { - [self addOrGoToContact:linphone_chat_room_get_peer_address(_chatRoom)]; + if (isEncrypted) { + LinphoneAddress* contactAddress = linphone_address_clone(linphone_participant_get_address(bctbx_list_nth_data(linphone_chat_room_get_participants(_chatRoom), 0))); + linphone_address_clean(contactAddress); + [self addOrGoToContact:contactAddress]; + linphone_address_unref(contactAddress); + } else { + [self addOrGoToContact:linphone_chat_room_get_peer_address(_chatRoom)]; + } } else { [self displayGroupInfo]; } @@ -1831,7 +1845,15 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog if (indexPath.row == 0) { if (isOneToOne) { - Contact *contact = [FastAddressBook getContactWithAddress:linphone_chat_room_get_peer_address(_chatRoom)]; + Contact *contact; + if (isEncrypted) { + LinphoneAddress * contactAddress = linphone_address_clone(linphone_participant_get_address(bctbx_list_nth_data(linphone_chat_room_get_participants(_chatRoom), 0))); + linphone_address_clean(contactAddress); + contact = [FastAddressBook getContactWithAddress:contactAddress]; + linphone_address_unref(contactAddress); + } else { + contact = [FastAddressBook getContactWithAddress:linphone_chat_room_get_peer_address(_chatRoom)]; + } if (contact == nil) { cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"contact_add_default.png"] newSize:CGSizeMake(20, 25)]; cell.textLabel.text = NSLocalizedString(@"Add to contacts",nil); @@ -2186,6 +2208,7 @@ void on_shared_player_eof_reached(LinphonePlayer *p) { _showReplyView = true; [self updateFramesInclRecordingAndReplyView]; [self.tableController scrollToMessage:message]; + [self.messageField becomeFirstResponder]; } -(void) handlePendingTransferIfAny { diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 156bbb30f..487a2bb37 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -851,7 +851,8 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18; _messageActionsTitles = [[NSMutableArray alloc] init]; _messageActionsBlocks = [[NSMutableArray alloc] init]; _messageActionsIcons = [[NSMutableArray alloc] init]; - + + [VIEW(ChatConversationView).messageField resignFirstResponder]; UIChatBubbleTextCell *thiz = self; LinphoneChatMessageState state = linphone_chat_message_get_state(self.message); @@ -896,7 +897,9 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18; [VIEW(ChatConversationView) initiateReplyViewForMessage:message]; }]; - if (linphone_chat_message_is_outgoing(self.message) || linphone_chat_room_get_nb_participants(linphone_chat_message_get_chat_room(self.message)) > 1) { + LinphoneChatRoom *chatroom = linphone_chat_message_get_chat_room(self.message); + + if (linphone_chat_room_get_nb_participants(chatroom) > 1) { [_messageActionsTitles addObject:NSLocalizedString(@"Infos", nil)]; [_messageActionsIcons addObject:@"menu_info"]; [_messageActionsBlocks addObject:^{ @@ -906,6 +909,31 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; }]; } + + if (!linphone_chat_message_is_outgoing(self.message) + && [FastAddressBook getContactWithAddress:linphone_chat_message_get_from_address(self.message)] == nil + && !(linphone_chat_room_get_capabilities(chatroom) & LinphoneChatRoomCapabilitiesOneToOne) ) { + + LinphoneAddress *fromAddress = linphone_address_clone(linphone_chat_message_get_from_address(self.message)); + [_messageActionsTitles addObject:NSLocalizedString(@"Add to contact", nil)]; + [_messageActionsIcons addObject:@"contact_add_default"]; + [_messageActionsBlocks addObject:^{ + [thiz dismissPopup]; + linphone_address_clean(fromAddress); + char *lAddress = linphone_address_as_string_uri_only(fromAddress); + if (lAddress != NULL) { + NSString *normSip = [NSString stringWithUTF8String:lAddress]; + normSip = [normSip hasPrefix:@"sip:"] ? [normSip substringFromIndex:4] : normSip; + normSip = [normSip hasPrefix:@"sips:"] ? [normSip substringFromIndex:5] : normSip; + [ContactSelection setAddAddress:normSip]; + [ContactSelection setSelectionMode:ContactSelectionModeEdit]; + [ContactSelection enableSipFilter:FALSE]; + [PhoneMainView.instance changeCurrentView:ContactsListView.compositeViewDescription]; + ms_free(lAddress); + } + linphone_address_unref(fromAddress); + }]; + } [_messageActionsTitles addObject:NSLocalizedString(@"Delete", nil)]; [_messageActionsIcons addObject:@"menu_delete"];