diff --git a/Classes/Base.lproj/CallView.xib b/Classes/Base.lproj/CallView.xib index 6c328929b..e91646707 100644 --- a/Classes/Base.lproj/CallView.xib +++ b/Classes/Base.lproj/CallView.xib @@ -101,7 +101,7 @@ - + @@ -127,16 +127,16 @@ - + - + - + @@ -144,7 +144,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -552,7 +552,7 @@ - + diff --git a/Classes/CallIncomingView.m b/Classes/CallIncomingView.m index 16c8caf77..e612a4106 100644 --- a/Classes/CallIncomingView.m +++ b/Classes/CallIncomingView.m @@ -98,14 +98,12 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)update { - // [self view]; // Force view load - const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; char *uri = linphone_address_as_string_uri_only(addr); addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); - avatarImage.image = [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:NO]; + avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:NO]; } #pragma mark - Property Functions diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index 1eb3272ab..412901eeb 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -55,8 +55,7 @@ static UICompositeViewDescription *compositeDescription = nil; char *uri = linphone_address_as_string_uri_only(addr); _addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); - _avatarImage.image = - [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:NO]; } } diff --git a/Classes/CallView.m b/Classes/CallView.m index d1d269088..d19442516 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -447,23 +447,19 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { } - (void)onCurrentCallChange { - LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]); - if (!call) { - _noActiveCallView.hidden = NO; - return; - } + LinphoneCore *lc = [LinphoneManager getLc]; + LinphoneCall *call = linphone_core_get_current_call(lc); - _callView.hidden = linphone_call_is_in_conference(call); - _conferenceView.hidden = !_callView.hidden; - _noActiveCallView.hidden = YES; + _noActiveCallView.hidden = (call || linphone_core_is_in_conference(lc)); + _callView.hidden = !call; + _conferenceView.hidden = !linphone_core_is_in_conference(lc); - if (call && !linphone_call_is_in_conference(call)) { + if (!_callView.hidden) { const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; char *uri = linphone_address_as_string_uri_only(addr); ms_free(uri); - _avatarImage.image = - [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:NO]; } } diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index eff74db0e..516ba4d66 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -189,8 +189,7 @@ static UICompositeViewDescription *compositeDescription = nil; } [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:linphoneAddress]; _addressLabel.accessibilityValue = _addressLabel.text; - _avatarImage.image = - [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:linphoneAddress] thumbnail:YES]; + _avatarImage.image = [FastAddressBook imageForAddress:linphoneAddress thumbnail:YES]; } static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state, void *ud) { @@ -439,7 +438,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st } - (IBAction)onCallClick:(id)sender { - NSString *displayName = [FastAddressBook getContactDisplayName:linphone_chat_room_get_peer_address(chatRoom)]; + NSString *displayName = [FastAddressBook displayNameForAddress:linphone_chat_room_get_peer_address(chatRoom)]; // Go to dialer view DialerView *view = VIEW(DialerView); [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; diff --git a/Classes/ContactDetailsTableView.m b/Classes/ContactDetailsTableView.m index e049e0e73..cbe122e4b 100644 --- a/Classes/ContactDetailsTableView.m +++ b/Classes/ContactDetailsTableView.m @@ -649,12 +649,13 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { } else if (contactSections[section] == ContactSections_Last_Name && self.tableView.isEditing) { text = NSLocalizedString(@"Last name", nil); canAddEntry = NO; - } else if ([self getSectionData:section].count > 0) { + } else if ([self getSectionData:section].count > 0 || self.tableView.isEditing) { if (contactSections[section] == ContactSections_Number) { text = NSLocalizedString(@"Phone numbers", nil); } else if (contactSections[section] == ContactSections_Sip) { text = NSLocalizedString(@"SIP addresses", nil); - } else if (contactSections[section] == ContactSections_Email) { + } else if (contactSections[section] == ContactSections_Email && + [LinphoneManager.instance lpConfigBoolForKey:@"show_contacts_emails_preference"]) { text = NSLocalizedString(@"Email addresses", nil); } } diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 61741a7ba..aa0bc8140 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -60,7 +60,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info [PhoneMainView.instance popCurrentView]; return; } - _avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForContact:_contact thumbnail:NO]; [_tableController setContact:_contact]; } @@ -114,7 +114,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info _contact = NULL; [self resetData]; _contact = acontact; - _avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForContact:_contact thumbnail:NO]; [ContactDisplay setDisplayNameLabel:_nameLabel forContact:acontact]; [_tableController setContact:_contact]; @@ -304,6 +304,6 @@ static UICompositeViewDescription *compositeDescription = nil; CFRelease(cfdata); - _avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForContact:_contact thumbnail:NO]; } @end diff --git a/Classes/ContactsListTableView.m b/Classes/ContactsListTableView.m index 96d613314..d0939c242 100644 --- a/Classes/ContactsListTableView.m +++ b/Classes/ContactsListTableView.m @@ -199,7 +199,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info // Cached avatar UIImage *image = [avatarMap objectForKey:[NSNumber numberWithInt:ABRecordGetRecordID(contact)]]; if (image == nil) { - image = [FastAddressBook getContactImage:contact thumbnail:true]; + image = [FastAddressBook imageForContact:contact thumbnail:true]; [avatarMap setObject:image forKey:[NSNumber numberWithInt:ABRecordGetRecordID(contact)]]; } [cell.avatarImage setImage:image]; diff --git a/Classes/DialerView.m b/Classes/DialerView.m index 5dbf6b174..ca47071d6 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -359,7 +359,8 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)call:(NSString *)address { - NSString *displayName = [FastAddressBook getContactDisplayName:[FastAddressBook getContact:address]]; + ABRecordRef contact = [FastAddressBook getContact:address]; + NSString *displayName = contact ? [FastAddressBook displayNameForContact:contact] : nil; [self call:address displayName:displayName]; } diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index ea48c72f5..67b2a9e3d 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -162,7 +162,7 @@ static UICompositeViewDescription *compositeDescription = nil; ABRecordRef contact = [FastAddressBook getContactWithAddress:addr]; _addContactButton.hidden = (contact != nil); [ContactDisplay setDisplayNameLabel:_contactLabel forAddress:addr]; - _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForContact:contact thumbnail:NO]; char *addrURI = linphone_address_as_string_uri_only(addr); _addressLabel.text = [NSString stringWithUTF8String:addrURI]; ms_free(addrURI); diff --git a/Classes/LinphoneUI/UICallButton.m b/Classes/LinphoneUI/UICallButton.m index 2bc5bd91e..3b7d37f6b 100644 --- a/Classes/LinphoneUI/UICallButton.m +++ b/Classes/LinphoneUI/UICallButton.m @@ -87,8 +87,9 @@ } if ([address length] > 0) { - NSString *displayName = [FastAddressBook getContactDisplayName:[FastAddressBook getContact:address]]; - [[LinphoneManager instance] call:address displayName:displayName transfer:FALSE]; + ABRecordRef contact = [FastAddressBook getContact:address]; + NSString *displayName = contact ? [FastAddressBook displayNameForContact:contact] : nil; + [LinphoneManager.instance call:address displayName:displayName transfer:FALSE]; } } diff --git a/Classes/LinphoneUI/UICallConferenceCell.m b/Classes/LinphoneUI/UICallConferenceCell.m index 2e9c21ca6..8a23e1e3d 100644 --- a/Classes/LinphoneUI/UICallConferenceCell.m +++ b/Classes/LinphoneUI/UICallConferenceCell.m @@ -37,7 +37,7 @@ const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; - _avatarImage.image = [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:YES]; + _avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:YES]; int duration = linphone_call_get_duration(call); [_durationLabel setText:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60), nil]]; diff --git a/Classes/LinphoneUI/UICallPausedCell.m b/Classes/LinphoneUI/UICallPausedCell.m index d68f9b58c..7a58fd14a 100644 --- a/Classes/LinphoneUI/UICallPausedCell.m +++ b/Classes/LinphoneUI/UICallPausedCell.m @@ -39,7 +39,7 @@ const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; - _avatarImage.image = [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:NO]; + _avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:NO]; int duration = linphone_call_get_duration(call); [_durationLabel setText:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60), nil]]; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index c9e19f18a..096c19294 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -110,7 +110,7 @@ [LinphoneUtils setSelfAvatar:_avatarImage]; } else { ABRecordRef contact = [FastAddressBook getContactWithAddress:linphone_chat_message_get_peer_address(_message)]; - _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:YES]; + _avatarImage.image = [FastAddressBook imageForContact:contact thumbnail:YES]; } _backgroundColorImage.image = _bottomBarColor.image = [UIImage imageNamed:(outgoing ? @"color_A" : @"color_D")]; diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index fc60a292e..2c2c16f06 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -71,7 +71,7 @@ } const LinphoneAddress *addr = linphone_chat_room_get_peer_address(chatRoom); [ContactDisplay setDisplayNameLabel:addressLabel forAddress:addr]; - avatarImage.image = [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:NO]; + avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:NO]; LinphoneChatMessage *last_message = linphone_chat_room_get_user_data(chatRoom); if (last_message) { diff --git a/Classes/LinphoneUI/UIHistoryCell.m b/Classes/LinphoneUI/UIHistoryCell.m index cd0f0c69c..1be027582 100644 --- a/Classes/LinphoneUI/UIHistoryCell.m +++ b/Classes/LinphoneUI/UIHistoryCell.m @@ -96,7 +96,7 @@ [ContactDisplay setDisplayNameLabel:displayNameLabel forAddress:addr]; ABRecordRef contact = [FastAddressBook getContactWithAddress:addr]; - _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:TRUE]; + _avatarImage.image = [FastAddressBook imageForContact:contact thumbnail:TRUE]; } - (void)setEditing:(BOOL)editing { diff --git a/Classes/Utils/FastAddressBook.h b/Classes/Utils/FastAddressBook.h index b07018c1d..a53fa7b86 100644 --- a/Classes/Utils/FastAddressBook.h +++ b/Classes/Utils/FastAddressBook.h @@ -39,8 +39,9 @@ + (ABRecordRef)getContact:(NSString *)address; + (ABRecordRef)getContactWithAddress:(const LinphoneAddress *)address; -+ (NSString *)getContactDisplayName:(ABRecordRef)contact; -+ (UIImage *)getContactImage:(ABRecordRef)contact thumbnail:(BOOL)thumbnail; ++ (UIImage *)imageForContact:(ABRecordRef)contact thumbnail:(BOOL)thumbnail; ++ (UIImage *)imageForAddress:(const LinphoneAddress *)addr thumbnail:(BOOL)thumbnail; + + (BOOL)contactHasValidSipDomain:(ABRecordRef)person; + (NSString *)displayNameForContact:(ABRecordRef)person; diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 24c8e5c9f..9e596d98a 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -26,15 +26,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void *context); -+ (NSString *)getContactDisplayName:(ABRecordRef)contact { - NSString *retString = nil; - if (contact) { - retString = CFBridgingRelease(ABRecordCopyCompositeName(contact)); - } - return retString; -} - -+ (UIImage *)getContactImage:(ABRecordRef)contact thumbnail:(BOOL)thumbnail { ++ (UIImage *)imageForContact:(ABRecordRef)contact thumbnail:(BOOL)thumbnail { UIImage *retImage = nil; if (contact && ABPersonHasImageData(contact)) { NSData *imgData = CFBridgingRelease(ABPersonCopyImageDataWithFormat( @@ -51,6 +43,10 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info return retImage; } ++ (UIImage *)imageForAddress:(const LinphoneAddress *)addr thumbnail:(BOOL)thumbnail { + return [FastAddressBook imageForContact:[FastAddressBook getContactWithAddress:addr] thumbnail:thumbnail]; +} + + (ABRecordRef)getContact:(NSString *)address { if (LinphoneManager.instance.fastAddressBook != nil) { @synchronized(LinphoneManager.instance.fastAddressBook.addressBookMap) { @@ -307,6 +303,9 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty)); NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName]; + // TODO: we may use the following so that first name / last name is properly displayed? + // retString = CFBridgingRelease(ABRecordCopyCompositeName(contact)); + NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty)); NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName]; diff --git a/submodules/linphone b/submodules/linphone index af28361f2..e9c787b79 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit af28361f22aef16e3b317696017463972b00acfc +Subproject commit e9c787b7990a06d7cbd715f9dce2322488661950