From b73ab96def9bbf2b609cec1cacb0565b42b9abc0 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 14 Oct 2015 12:04:16 +0200 Subject: [PATCH] contact details top bar --- Classes/Base.lproj/ContactDetailsView.xib | 16 ++++ Classes/Base.lproj/ContactsListView.xib | 18 ++-- Classes/ContactDetailsView.m | 94 +++++++++---------- Classes/ContactsListView.m | 39 ++++---- Classes/DialerView.m | 13 +-- Classes/LinphoneUI/Base.lproj/TabBarView.xib | 18 ++-- .../LinphoneUI/Base.lproj/UIContactCell.xib | 29 +++--- Classes/LinphoneUI/TabBarView.h | 2 +- Classes/LinphoneUI/TabBarView.m | 4 +- Classes/Utils/FastAddressBook.m | 2 +- 10 files changed, 113 insertions(+), 122 deletions(-) diff --git a/Classes/Base.lproj/ContactDetailsView.xib b/Classes/Base.lproj/ContactDetailsView.xib index 159aa2e91..32a5ae076 100644 --- a/Classes/Base.lproj/ContactDetailsView.xib +++ b/Classes/Base.lproj/ContactDetailsView.xib @@ -9,6 +9,7 @@ + @@ -31,6 +32,19 @@ + + + + + + + + + - + @@ -159,14 +167,6 @@ - - - - - - - - diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 56821c4af..50b0cf0c1 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -22,12 +22,6 @@ @implementation ContactDetailsView -@synthesize tableController; -@synthesize contact; -@synthesize editButton; -@synthesize backButton; -@synthesize cancelButton; - static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void *context); #pragma mark - Lifecycle Functions @@ -51,21 +45,21 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info - (void)resetData { [self disableEdit:FALSE]; - if (contact == NULL) { + if (_contact == NULL) { ABAddressBookRevert(addressBook); return; } - LOGI(@"Reset data to contact %p", contact); - ABRecordID recordID = ABRecordGetRecordID(contact); + LOGI(@"Reset data to contact %p", _contact); + ABRecordID recordID = ABRecordGetRecordID(_contact); ABAddressBookRevert(addressBook); - contact = ABAddressBookGetPersonWithRecordID(addressBook, recordID); - if (contact == NULL) { + _contact = ABAddressBookGetPersonWithRecordID(addressBook, recordID); + if (_contact == NULL) { [PhoneMainView.instance popCurrentView]; return; } - _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO]; - [tableController setContact:contact]; + _avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO]; + [_tableController setContact:_contact]; } static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void *context) { @@ -76,28 +70,28 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } - (void)removeContact { - if (contact != NULL) { + if (_contact != NULL) { inhibUpdate = TRUE; - [[[LinphoneManager instance] fastAddressBook] removeContact:contact]; + [[[LinphoneManager instance] fastAddressBook] removeContact:_contact]; inhibUpdate = FALSE; } [PhoneMainView.instance popCurrentView]; } - (void)saveData { - if (contact == NULL) { + if (_contact == NULL) { [PhoneMainView.instance popCurrentView]; return; } // Add contact to book CFErrorRef error = NULL; - if (ABRecordGetRecordID(contact) == kABRecordInvalidID) { - ABAddressBookAddRecord(addressBook, contact, (CFErrorRef *)&error); + if (ABRecordGetRecordID(_contact) == kABRecordInvalidID) { + ABAddressBookAddRecord(addressBook, _contact, (CFErrorRef *)&error); if (error != NULL) { - LOGE(@"Add contact %p: Fail(%@)", contact, [(__bridge NSError *)error localizedDescription]); + LOGE(@"Add contact %p: Fail(%@)", _contact, [(__bridge NSError *)error localizedDescription]); } else { - LOGI(@"Add contact %p: Success!", contact); + LOGI(@"Add contact %p: Success!", _contact); } } @@ -115,15 +109,15 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } - (void)selectContact:(ABRecordRef)acontact andReload:(BOOL)reload { - contact = NULL; + _contact = NULL; [self resetData]; - contact = acontact; - _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO]; - [tableController setContact:contact]; + _contact = acontact; + _avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO]; + [_tableController setContact:_contact]; if (reload) { [self enableEdit:FALSE]; - [[tableController tableView] reloadData]; + [[_tableController tableView] reloadData]; } } @@ -134,17 +128,17 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info if (([username rangeOfString:@"@"].length > 0) && ([[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"] == true)) { - [tableController addEmailField:username]; + [_tableController addEmailField:username]; } else if ((linphone_proxy_config_is_phone_number(NULL, [username UTF8String])) && ([[LinphoneManager instance] lpConfigBoolForKey:@"save_new_contacts_as_phone_number"] == true)) { - [tableController addPhoneField:username]; + [_tableController addPhoneField:username]; } else { - [tableController addSipField:address]; + [_tableController addSipField:address]; } linphone_address_destroy(linphoneAddress); [self enableEdit:FALSE]; - [[tableController tableView] reloadData]; + [[_tableController tableView] reloadData]; } - (void)newContact { @@ -175,9 +169,9 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info [super viewWillAppear:animated]; if ([ContactSelection getSelectionMode] == ContactSelectionModeEdit || [ContactSelection getSelectionMode] == ContactSelectionModeNone) { - [editButton setHidden:FALSE]; + [_editButton setHidden:FALSE]; } else { - [editButton setHidden:TRUE]; + [_editButton setHidden:TRUE]; } } @@ -204,21 +198,21 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - - (void)enableEdit:(BOOL)animated { - if (![tableController isEditing]) { - [tableController setEditing:TRUE animated:animated]; + if (!_tableController.isEditing) { + [_tableController setEditing:TRUE animated:animated]; } - [editButton setOn]; - [cancelButton setHidden:FALSE]; - [backButton setHidden:TRUE]; + [_editButton setOn]; + [_cancelButton setHidden:FALSE]; + [_backButton setHidden:TRUE]; } - (void)disableEdit:(BOOL)animated { - if ([tableController isEditing]) { - [tableController setEditing:FALSE animated:animated]; + if (_tableController.isEditing) { + [_tableController setEditing:FALSE animated:animated]; } - [editButton setOff]; - [cancelButton setHidden:TRUE]; - [backButton setHidden:FALSE]; + [_editButton setOff]; + [_cancelButton setHidden:TRUE]; + [_backButton setHidden:FALSE]; } #pragma mark - Action Functions @@ -236,8 +230,8 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onEditClick:(id)event { - if ([tableController isEditing]) { - if ([tableController isValid]) { + if (_tableController.isEditing) { + if ([_tableController isValid]) { [self disableEdit:TRUE]; [self saveData]; } @@ -258,16 +252,16 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onAvatarClick:(id)sender { - if (tableController.isEditing) { + if (_tableController.isEditing) { [ImagePickerView SelectImageFromDevice:self atPosition:CGRectNull inView:nil]; } } - (void)onModification:(id)event { - if (![tableController isEditing] || [tableController isValid]) { - [editButton setEnabled:TRUE]; + if (!_tableController.isEditing || [_tableController isValid]) { + [_editButton setEnabled:TRUE]; } else { - [editButton setEnabled:FALSE]; + [_editButton setEnabled:FALSE]; } } @@ -276,7 +270,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)imagePickerDelegateImage:(UIImage *)image info:(NSDictionary *)info { FastAddressBook *fab = [LinphoneManager instance].fastAddressBook; CFErrorRef error = NULL; - if (!ABPersonRemoveImageData(contact, (CFErrorRef *)&error)) { + if (!ABPersonRemoveImageData(_contact, (CFErrorRef *)&error)) { LOGI(@"Can't remove entry: %@", [(__bridge NSError *)error localizedDescription]); } NSData *dataRef = UIImageJPEGRepresentation(image, 0.9f); @@ -284,7 +278,7 @@ static UICompositeViewDescription *compositeDescription = nil; [fab saveAddressBook]; - if (!ABPersonSetImageData(contact, cfdata, (CFErrorRef *)&error)) { + if (!ABPersonSetImageData(_contact, cfdata, (CFErrorRef *)&error)) { LOGI(@"Can't add entry: %@", [(__bridge NSError *)error localizedDescription]); } else { [fab saveAddressBook]; @@ -292,6 +286,6 @@ static UICompositeViewDescription *compositeDescription = nil; CFRelease(cfdata); - _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO]; + _avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO]; } @end diff --git a/Classes/ContactsListView.m b/Classes/ContactsListView.m index b937ea515..a99d04a8b 100644 --- a/Classes/ContactsListView.m +++ b/Classes/ContactsListView.m @@ -107,28 +107,21 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - ViewController Functions -- (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; -} - -- (void)relayoutTableView { - CGRect subViewFrame = self.view.frame; - // let the top bar be visible - subViewFrame.origin.y += self.topBar.frame.size.height; - subViewFrame.size.height -= self.topBar.frame.size.height; - [UIView animateWithDuration:0.2 - animations:^{ - self.tableController.tableView.frame = subViewFrame; - }]; -} +//- (void)relayoutTableView { +// CGRect subViewFrame = self.view.frame; +// // let the top bar be visible +// subViewFrame.origin.y += self.topBar.frame.size.height + self.searchBar.frame.size.height; +// subViewFrame.size.height -= self.topBar.frame.size.height + self.searchBar.frame.size.height; +// [UIView animateWithDuration:0.2 +// animations:^{ +// self.tableController.tableView.frame = subViewFrame; +// }]; +//} - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; _searchBar.showsCancelButton = (_searchBar.text.length > 0); - CGRect frame = _searchBar.frame; - frame.origin.y = topBar.frame.origin.y + topBar.frame.size.height; - _searchBar.frame = frame; [self update]; } @@ -167,7 +160,7 @@ static UICompositeViewDescription *compositeDescription = nil; } if (view == History_Linphone) { - [ContactSelection setSipFilter:[LinphoneManager instance].contactFilter]; + [ContactSelection setSipFilter:LinphoneManager.instance.contactFilter]; [ContactSelection enableEmailFilter:FALSE]; [tableController loadData]; linphoneButton.selected = TRUE; @@ -239,11 +232,11 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Rotation handling -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { - [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; - // the searchbar overlaps the subview in most rotation cases, we have to re-layout the view manually: - [self relayoutTableView]; -} +//- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { +// [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; +// // the searchbar overlaps the subview in most rotation cases, we have to re-layout the view manually: +// [self relayoutTableView]; +//} #pragma mark - ABPeoplePickerDelegate diff --git a/Classes/DialerView.m b/Classes/DialerView.m index a419cde3d..9f7f74bfd 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -413,17 +413,8 @@ static UICompositeViewDescription *compositeDescription = nil; if ([self displayDebugPopup:self.addressField.text]) { self.addressField.text = @""; } - if ([[addressField text] length] > 0) { - [addContactButton setEnabled:TRUE]; - [backspaceButton setEnabled:TRUE]; - [addCallButton setEnabled:TRUE]; - [transferButton setEnabled:TRUE]; - } else { - [addContactButton setEnabled:FALSE]; - [backspaceButton setEnabled:FALSE]; - [addCallButton setEnabled:FALSE]; - [transferButton setEnabled:FALSE]; - } + addContactButton.enabled = backspaceButton.enabled = addCallButton.enabled = transferButton.enabled = + ([[addressField text] length] > 0); } - (IBAction)onBackspaceClick:(id)sender { diff --git a/Classes/LinphoneUI/Base.lproj/TabBarView.xib b/Classes/LinphoneUI/Base.lproj/TabBarView.xib index b0acaf8b3..e0575fad8 100644 --- a/Classes/LinphoneUI/Base.lproj/TabBarView.xib +++ b/Classes/LinphoneUI/Base.lproj/TabBarView.xib @@ -1,6 +1,7 @@ + @@ -15,7 +16,7 @@ - + @@ -73,11 +74,10 @@ - + - - + @@ -127,13 +127,13 @@ - + - - - - + + + + diff --git a/Classes/LinphoneUI/Base.lproj/UIContactCell.xib b/Classes/LinphoneUI/Base.lproj/UIContactCell.xib index a25535ce8..1a3b0bee7 100644 --- a/Classes/LinphoneUI/Base.lproj/UIContactCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIContactCell.xib @@ -1,10 +1,10 @@ - 2048 - 14D136 + 1536 + 14F27 7706 - 1347.57 + 1348.17 758.70 com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -33,7 +33,7 @@ IBCocoaTouchFramework - + 274 @@ -41,6 +41,7 @@ 300 {{6, 6}, {32, 32}} + _NS:9 NO @@ -55,6 +56,7 @@ 274 {{46, 0}, {273, 44}} + _NS:328 @@ -111,8 +113,9 @@ 297 - {{327, 11}, {25, 22}} + {{314, 11}, {25, 22}} + _NS:9 NO IBCocoaTouchFramework @@ -123,6 +126,8 @@ {360, 44} + + _NS:9 @@ -231,7 +236,7 @@ UIContactCell - UITransparentTVCell + UITableViewCell UIImageView UIImageView @@ -264,14 +269,6 @@ ../Classes/LinphoneUI/UIRoundedImageView.h - - UITransparentTVCell - UITableViewCell - - IBProjectSource - ../Classes/LinphoneUI/UITransparentTVCell.h - - @@ -334,8 +331,8 @@ YES 3 - {261, 261} - {27, 23} + {255, 255} + {26, 22} diff --git a/Classes/LinphoneUI/TabBarView.h b/Classes/LinphoneUI/TabBarView.h index ccbb4104c..193fef6a6 100644 --- a/Classes/LinphoneUI/TabBarView.h +++ b/Classes/LinphoneUI/TabBarView.h @@ -31,7 +31,7 @@ @property(nonatomic, strong) IBOutlet UILabel *historyNotificationLabel; @property(nonatomic, strong) IBOutlet UIView *chatNotificationView; @property(nonatomic, strong) IBOutlet UILabel *chatNotificationLabel; -@property(weak, nonatomic) IBOutlet UIView *selectedBtnView; +@property(weak, nonatomic) IBOutlet UIImageView *selectedButtonImage; - (IBAction)onHistoryClick:(id)event; - (IBAction)onContactsClick:(id)event; diff --git a/Classes/LinphoneUI/TabBarView.m b/Classes/LinphoneUI/TabBarView.m index eb976ca9a..b77ed43a2 100644 --- a/Classes/LinphoneUI/TabBarView.m +++ b/Classes/LinphoneUI/TabBarView.m @@ -216,7 +216,7 @@ static NSString *const kDisappearAnimation = @"disappear"; contactsButton.selected = [view equal:ContactsListView.compositeViewDescription]; dialerButton.selected = [view equal:DialerView.compositeViewDescription]; chatButton.selected = [view equal:ChatsListView.compositeViewDescription]; - CGRect selectedNewFrame = _selectedBtnView.frame; + CGRect selectedNewFrame = _selectedButtonImage.frame; selectedNewFrame.origin.x = (historyButton.selected ? historyButton.frame.origin.x @@ -224,7 +224,7 @@ static NSString *const kDisappearAnimation = @"disappear"; ? contactsButton.frame.origin.x : (dialerButton.selected ? dialerButton.frame.origin.x : (chatButton.selected ? chatButton.frame.origin.x : 0)))); - _selectedBtnView.frame = selectedNewFrame; + _selectedButtonImage.frame = selectedNewFrame; } #pragma mark - Action Functions diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 35b88483c..8f823cb25 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -268,7 +268,7 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void // Check if one of the contact' sip URI matches the expected SIP filter ABMultiValueRef personSipAddresses = ABRecordCopyValue(person, kABPersonInstantMessageProperty); BOOL match = false; - NSString *domain = [ContactSelection getSipFilter]; + NSString *domain = LinphoneManager.instance.contactFilter; for (int i = 0; i < ABMultiValueGetCount(personSipAddresses) && !match; ++i) { CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(personSipAddresses, i);