From fda16165ce1f0bebb41b5c66fdd49bb7381d85a0 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 23 Nov 2017 16:40:30 +0100 Subject: [PATCH] better condition to differentiate simple from group chat rooms --- Classes/ChatConversationCreateView.m | 2 +- Classes/ChatConversationView.m | 13 +++++++++---- Classes/LinphoneUI/UIChatCell.m | 6 +++--- Classes/PhoneMainView.h | 2 ++ submodules/linphone | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Classes/ChatConversationCreateView.m b/Classes/ChatConversationCreateView.m index a489e8ffc..0a1484709 100644 --- a/Classes/ChatConversationCreateView.m +++ b/Classes/ChatConversationCreateView.m @@ -102,7 +102,7 @@ void create_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState - (void)createChatRoom { _waitView.hidden = NO; - LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, "dummy subject"); + LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, LINPHONE_DUMMY_SUBJECT); NSString *addr = _tableController.contactsGroup[0]; LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(room); diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index c8175be3c..483764b67 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -131,8 +131,9 @@ static UICompositeViewDescription *compositeDescription = nil; [_pictureButton setEnabled:fileSharingEnabled]; [self callUpdateEvent:nil]; - PhoneMainView.instance.currentRoom = self.chatRoom; - if (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: "dummy subject", "dummy subject") != 0) + PhoneMainView.instance.currentRoom = _chatRoom; + if (linphone_chat_room_can_handle_participants(_chatRoom) + && (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT, LINPHONE_DUMMY_SUBJECT) != 0 || linphone_chat_room_get_nb_participants(_chatRoom) > 1)) _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom)]; else { const LinphoneAddress *addr = linphone_participant_get_address(linphone_chat_room_get_participants(_chatRoom)->data); @@ -375,12 +376,16 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)updateSuperposedButtons { [_backToCallButton update]; - _infoButton.hidden = (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: "dummy subject", "dummy subject") == 0) || !_backToCallButton.hidden || _tableController.tableView.isEditing; + _infoButton.hidden = (!linphone_chat_room_can_handle_participants(_chatRoom) + || (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT, LINPHONE_DUMMY_SUBJECT) == 0 && linphone_chat_room_get_nb_participants(_chatRoom) == 1) + || !_backToCallButton.hidden + || _tableController.tableView.isEditing); _callButton.hidden = !_backToCallButton.hidden || !_infoButton.hidden || _tableController.tableView.isEditing; } - (void)updateParticipantLabel { - if (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: "dummy subject", "dummy subject") == 0) { + if (!linphone_chat_room_can_handle_participants(_chatRoom) + || (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT, LINPHONE_DUMMY_SUBJECT) == 0 && linphone_chat_room_get_nb_participants(_chatRoom) == 1)) { _particpantsLabel.hidden = TRUE; } else { _particpantsLabel.hidden = FALSE; diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 5b4e8822c..be588936e 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -64,8 +64,8 @@ return; } - const char *subject = linphone_chat_room_get_subject(chatRoom) ?: "dummy subject"; - if (strcmp(subject, "dummy subject") != 0) { + const char *subject = linphone_chat_room_get_subject(chatRoom) ?: LINPHONE_DUMMY_SUBJECT; + if (linphone_chat_room_can_handle_participants(chatRoom) && (strcmp(subject, LINPHONE_DUMMY_SUBJECT) != 0 || linphone_chat_room_get_nb_participants(chatRoom) > 1)) { _addressLabel.text = [NSString stringWithUTF8String:subject]; [_avatarImage setImage:[UIImage imageNamed:@"chat_group_avatar.png"] bordered:NO withRoundedRadius:YES]; } else { @@ -77,7 +77,7 @@ [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; } } else { - _addressLabel.text = [NSString stringWithUTF8String:"dummy subject"]; + _addressLabel.text = [NSString stringWithUTF8String:LINPHONE_DUMMY_SUBJECT]; } } diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index 5b79887a0..c1049c4fc 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -57,6 +57,8 @@ #define VIEW(x) \ DYNAMIC_CAST([PhoneMainView.instance.mainViewController getCachedController:x.compositeViewDescription.name], x) +#define LINPHONE_DUMMY_SUBJECT "dummy subject" + @class PhoneMainView; @interface RootViewManager : NSObject diff --git a/submodules/linphone b/submodules/linphone index 97cd45702..60915d8a1 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 97cd45702cc7c7774807d4b0e97e332c2373286f +Subproject commit 60915d8a159424576ad3db515a91cf49d7aad286