From 5987d4a4567f71ff7b3a9a2740cc4ab24c08eaa4 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 22 Jun 2017 11:31:58 +0200 Subject: [PATCH] Always display Avatar image the same way --- Classes/CallIncomingView.m | 2 +- Classes/CallOutgoingView.m | 2 +- Classes/CallView.m | 2 +- Classes/Contact.h | 2 +- Classes/Contact.m | 5 ++--- Classes/ContactDetailsView.m | 6 +++--- Classes/ContactsListTableView.m | 2 +- Classes/HistoryDetailsView.m | 2 +- Classes/LinphoneUI/UICallConferenceCell.m | 2 +- Classes/LinphoneUI/UICallPausedCell.m | 2 +- Classes/LinphoneUI/UIChatBubbleTextCell.m | 3 +-- Classes/LinphoneUI/UIChatCell.m | 2 +- Classes/LinphoneUI/UIHistoryCell.m | 2 +- Classes/Utils/FastAddressBook.h | 4 ++-- Classes/Utils/FastAddressBook.m | 8 ++++---- 15 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Classes/CallIncomingView.m b/Classes/CallIncomingView.m index b73f4ff28..17cd56edf 100644 --- a/Classes/CallIncomingView.m +++ b/Classes/CallIncomingView.m @@ -99,7 +99,7 @@ static UICompositeViewDescription *compositeDescription = nil; char *uri = linphone_address_as_string_uri_only(addr); _addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:YES withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:YES withRoundedRadius:YES]; _tabBar.hidden = linphone_call_params_video_enabled(linphone_call_get_remote_params(_call)); _tabVideoBar.hidden = !_tabBar.hidden; diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index a18ebff95..e8afaa1dd 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -67,7 +67,7 @@ static UICompositeViewDescription *compositeDescription = nil; char *uri = linphone_address_as_string_uri_only(addr); _addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:YES withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; [self hideSpeaker:LinphoneManager.instance.bluetoothAvailable]; diff --git a/Classes/CallView.m b/Classes/CallView.m index 7d93e0b45..57b8d13da 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -423,7 +423,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; char *uri = linphone_address_as_string_uri_only(addr); ms_free(uri); - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:YES withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:YES withRoundedRadius:YES]; } } diff --git a/Classes/Contact.h b/Classes/Contact.h index edeb22d0c..bd7cdbfad 100644 --- a/Classes/Contact.h +++ b/Classes/Contact.h @@ -24,7 +24,7 @@ @property BOOL added; - (void)setAvatar:(UIImage *)avatar; -- (UIImage *)avatar:(BOOL)thumbnail; +- (UIImage *)avatar; - (NSString *)displayName; - (instancetype)initWithPerson:(ABRecordRef)person; diff --git a/Classes/Contact.m b/Classes/Contact.m index 6e99cccf0..74435fa9c 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -94,10 +94,9 @@ } #pragma mark - Getters -- (UIImage *)avatar:(BOOL)thumbnail { +- (UIImage *)avatar { if (_person && ABPersonHasImageData(_person)) { - NSData *imgData = CFBridgingRelease(ABPersonCopyImageDataWithFormat( - _person, thumbnail ? kABPersonImageFormatThumbnail : kABPersonImageFormatOriginalSize)); + NSData *imgData = CFBridgingRelease(ABPersonCopyImageDataWithFormat(_person, kABPersonImageFormatThumbnail)); return [UIImage imageWithData:imgData]; } return nil; diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index d5a7b4f1d..bc75671ff 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -57,7 +57,7 @@ } LOGI(@"Reset data to contact %p", _contact); - [_avatarImage setImage:[FastAddressBook imageForContact:_contact thumbnail:NO] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForContact:_contact] bordered:NO withRoundedRadius:YES]; [_tableController setContact:_contact]; _emptyLabel.hidden = YES; _avatarImage.hidden = !_emptyLabel.hidden; @@ -93,7 +93,7 @@ _deleteButton.hidden = !_emptyLabel.hidden; _editButton.hidden = !_emptyLabel.hidden; - [_avatarImage setImage:[FastAddressBook imageForContact:_contact thumbnail:NO] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForContact:_contact] bordered:NO withRoundedRadius:YES]; [ContactDisplay setDisplayNameLabel:_nameLabel forContact:_contact]; [_tableController setContact:_contact]; @@ -527,7 +527,7 @@ static UICompositeViewDescription *compositeDescription = nil; [_contact setAvatar:image]; - [_avatarImage setImage:[FastAddressBook imageForContact:_contact thumbnail:NO] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForContact:_contact] bordered:NO withRoundedRadius:YES]; } diff --git a/Classes/ContactsListTableView.m b/Classes/ContactsListTableView.m index b4d121f5c..21b045b35 100644 --- a/Classes/ContactsListTableView.m +++ b/Classes/ContactsListTableView.m @@ -305,7 +305,7 @@ static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) { Contact *contact = subAr[indexPath.row]; // Cached avatar - UIImage *image = [FastAddressBook imageForContact:contact thumbnail:true]; + UIImage *image = [FastAddressBook imageForContact:contact]; [cell.avatarImage setImage:image bordered:NO withRoundedRadius:YES]; [cell setContact:contact]; [super accessoryForCell:cell atPath:indexPath]; diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index 73e2381b1..b3360caee 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -135,7 +135,7 @@ static UICompositeViewDescription *compositeDescription = nil; LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); _addContactButton.hidden = ([FastAddressBook getContactWithAddress:addr] != nil); [ContactDisplay setDisplayNameLabel:_contactLabel forAddress:addr]; - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; char *addrURI = linphone_address_as_string_uri_only(addr); _addressLabel.text = [NSString stringWithUTF8String:addrURI]; ms_free(addrURI); diff --git a/Classes/LinphoneUI/UICallConferenceCell.m b/Classes/LinphoneUI/UICallConferenceCell.m index ce2dde8f8..52c513e19 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 setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; _durationLabel.text = [LinphoneUtils durationToString:linphone_call_get_duration(call)]; } diff --git a/Classes/LinphoneUI/UICallPausedCell.m b/Classes/LinphoneUI/UICallPausedCell.m index 9107bcd75..95990b4db 100644 --- a/Classes/LinphoneUI/UICallPausedCell.m +++ b/Classes/LinphoneUI/UICallPausedCell.m @@ -40,7 +40,7 @@ [_pauseButton setType:UIPauseButtonType_Call call:call]; const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; _durationLabel.text = [LinphoneUtils durationToString:linphone_call_get_duration(call)]; } [_pauseButton update]; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 703e4c6ed..289e188bd 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -124,8 +124,7 @@ if (outgoing) { _avatarImage.image = [LinphoneUtils selfAvatar]; } else { - [_avatarImage setImage:[FastAddressBook imageForAddress:linphone_chat_message_get_peer_address(_message) - thumbnail:YES] + [_avatarImage setImage:[FastAddressBook imageForAddress:linphone_chat_message_get_peer_address(_message)] bordered:NO withRoundedRadius:YES]; } diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 770b28736..55eedc5fc 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -65,7 +65,7 @@ } const LinphoneAddress *addr = linphone_chat_room_get_peer_address(chatRoom); [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; 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 ee7334646..7f74b47ec 100644 --- a/Classes/LinphoneUI/UIHistoryCell.m +++ b/Classes/LinphoneUI/UIHistoryCell.m @@ -105,7 +105,7 @@ [displayNameLabel.text stringByAppendingString:[NSString stringWithFormat:@" (%lu)", count]]; } - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; } - (void)setEditing:(BOOL)editing { diff --git a/Classes/Utils/FastAddressBook.h b/Classes/Utils/FastAddressBook.h index 6267bff55..4db2bebe4 100644 --- a/Classes/Utils/FastAddressBook.h +++ b/Classes/Utils/FastAddressBook.h @@ -39,8 +39,8 @@ + (Contact *)getContactWithAddress:(const LinphoneAddress *)address; -+ (UIImage *)imageForContact:(Contact *)contact thumbnail:(BOOL)thumbnail; -+ (UIImage *)imageForAddress:(const LinphoneAddress *)addr thumbnail:(BOOL)thumbnail; ++ (UIImage *)imageForContact:(Contact *)contact; ++ (UIImage *)imageForAddress:(const LinphoneAddress *)addr; + (BOOL)contactHasValidSipDomain:(Contact *)person; + (BOOL)isSipURIValid:(NSString*)addr; diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 7b7abcc70..0d79d967a 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -31,9 +31,9 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void *context); -+ (UIImage *)imageForContact:(Contact *)contact thumbnail:(BOOL)thumbnail { ++ (UIImage *)imageForContact:(Contact *)contact { @synchronized(LinphoneManager.instance.fastAddressBook.addressBookMap) { - UIImage *retImage = [contact avatar:thumbnail]; + UIImage *retImage = [contact avatar]; if (retImage == nil) { retImage = [UIImage imageNamed:@"avatar.png"]; } @@ -44,11 +44,11 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } } -+ (UIImage *)imageForAddress:(const LinphoneAddress *)addr thumbnail:(BOOL)thumbnail { ++ (UIImage *)imageForAddress:(const LinphoneAddress *)addr { if ([LinphoneManager isMyself:addr] && [LinphoneUtils hasSelfAvatar]) { return [LinphoneUtils selfAvatar]; } - return [FastAddressBook imageForContact:[FastAddressBook getContactWithAddress:addr] thumbnail:thumbnail]; + return [FastAddressBook imageForContact:[FastAddressBook getContactWithAddress:addr]]; } + (Contact *)getContact:(NSString *)address {