From 2dffddd07ba4f458cac21cd3c9e260b202c516cb Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Fri, 10 Aug 2012 16:15:33 +0200 Subject: [PATCH] Improve Contact details view --- Classes/ContactDetailsTableViewController.m | 47 ++++++++++-------- Classes/LinphoneUI/UIContactDetailsHeader.m | 13 +++-- Classes/LinphoneUI/UIContactDetailsHeader.xib | 7 ++- Resources/en.lproj/Localizable.strings | Bin 13234 -> 13274 bytes 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Classes/ContactDetailsTableViewController.m b/Classes/ContactDetailsTableViewController.m index b36a4bc77..66e5b439d 100644 --- a/Classes/ContactDetailsTableViewController.m +++ b/Classes/ContactDetailsTableViewController.m @@ -56,12 +56,13 @@ @implementation ContactDetailsTableViewController enum _ContactSections { - ContactSections_Number = 0, + ContactSections_None = 0, + ContactSections_Number, ContactSections_Sip, ContactSections_MAX }; -static const int contactSections[ContactSections_MAX] = {ContactSections_Number, ContactSections_Sip}; +static const int contactSections[ContactSections_MAX] = {ContactSections_None, ContactSections_Number, ContactSections_Sip}; @synthesize footerController; @synthesize headerController; @@ -370,6 +371,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, } self->contact = acontact; [self loadData]; + [headerController setContact:contact]; } - (void)addSipField:(NSString*)address { @@ -551,18 +553,23 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, if(!editing) { [ContactDetailsTableViewController findAndResignFirstResponder:[self tableView]]; } - - [super setEditing:editing animated:animated]; + + [headerController setEditing:editing animated:animated]; + [footerController setEditing:editing animated:animated]; if(animated) { [self.tableView beginUpdates]; } if(editing) { - for (int section = 0; section <[self numberOfSectionsInTableView:[self tableView]]; ++section) { + for (int section = 0; section < [self numberOfSectionsInTableView:[self tableView]]; ++section) { + if(contactSections[section] == ContactSections_Number || + contactSections[section] == ContactSections_Sip) [self addEntry:self.tableView section:section animated:animated]; } } else { - for (int section = 0; section <[self numberOfSectionsInTableView:[self tableView]]; ++section) { + for (int section = 0; section < [self numberOfSectionsInTableView:[self tableView]]; ++section) { + if(contactSections[section] == ContactSections_Number || + contactSections[section] == ContactSections_Sip) [self removeEmptyEntry:self.tableView section:section animated:animated]; } } @@ -570,8 +577,10 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, [self.tableView endUpdates]; } - [headerController setEditing:editing animated:animated]; - [footerController setEditing:editing animated:animated]; + [super setEditing:editing animated:animated]; + if(contactDetailsDelegate != nil) { + [contactDetailsDelegate onModification:nil]; + } } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -583,11 +592,8 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - if(section == 0) { - UIView *headerView = [headerController view]; - [headerController setContact:contact]; - [headerController setEditing:[self isEditing] animated:FALSE]; - return headerView; + if(section == ContactSections_None) { + return [headerController view]; } else { return nil; } @@ -595,8 +601,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if(section == (ContactSections_MAX - 1)) { - UIView *footerView = [footerController view]; - return footerView; + return [footerController view]; } else { return nil; } @@ -606,7 +611,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, if(contactSections[section] == ContactSections_Number) { return NSLocalizedString(@"Phone numbers", nil); } else if(contactSections[section] == ContactSections_Sip) { - return NSLocalizedString(@"SIP", nil); + return NSLocalizedString(@"SIP addresses", nil); } return nil; } @@ -616,8 +621,8 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - if(section == 0) { - return [UIContactDetailsHeader height:[self isEditing]]; + if(section == ContactSections_None) { + return [UIContactDetailsHeader height:[headerController isEditing]]; } else { // Hide section if nothing in it if([[self getSectionData:section] count] > 0) @@ -628,8 +633,10 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number, } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { - if(section != 0) { - return [UIContactDetailsFooter height:[self isEditing]]; + if(section == (ContactSections_MAX - 1)) { + return [UIContactDetailsFooter height:[footerController isEditing]]; + } else if(section == ContactSections_None) { + return 0.000001f; // Hack UITableView = 0 } return 10.0f; } diff --git a/Classes/LinphoneUI/UIContactDetailsHeader.m b/Classes/LinphoneUI/UIContactDetailsHeader.m index 1d7bfa4ef..5e0de1c51 100644 --- a/Classes/LinphoneUI/UIContactDetailsHeader.m +++ b/Classes/LinphoneUI/UIContactDetailsHeader.m @@ -39,6 +39,7 @@ propertyList = [[NSArray alloc] initWithObjects: [NSNumber numberWithInt:kABPersonFirstNameProperty], [NSNumber numberWithInt:kABPersonLastNameProperty], nil]; + editing = FALSE; } - (id)init { @@ -83,6 +84,9 @@ - (void)viewDidLoad { [super viewDidLoad]; removeTableBackground(tableView); // Can't do it in Xib: issue with ios4 + [normalView setAlpha:1.0f]; + [editView setAlpha:0.0f]; + [tableView setEditing:TRUE animated:false]; } @@ -159,16 +163,11 @@ [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3]; } - [tableView setEditing:editing animated:animated]; if(editing) { - CGRect frame = [editView frame]; - frame.size.height = [UIContactDetailsHeader height:editing]; - [editView setFrame:frame]; + [editView setAlpha:1.0f]; [normalView setAlpha:0.0f]; } else { - CGRect frame = [editView frame]; - frame.size.height = 0; - [editView setFrame:frame]; + [editView setAlpha:0.0f]; [normalView setAlpha:1.0f]; } if(animated) { diff --git a/Classes/LinphoneUI/UIContactDetailsHeader.xib b/Classes/LinphoneUI/UIContactDetailsHeader.xib index e6fe80dcc..2ad58ddc6 100644 --- a/Classes/LinphoneUI/UIContactDetailsHeader.xib +++ b/Classes/LinphoneUI/UIContactDetailsHeader.xib @@ -35,7 +35,7 @@ - 290 + 274 @@ -378,6 +378,7 @@ AAgACAAIAAEAAQABAAE UILabel UIImageView + id UIView UIView UITableView @@ -391,6 +392,10 @@ AAgACAAIAAEAAQABAAE avatarImage UIImageView + + contactDetailsDelegate + id + editView UIView diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 5077d42c483f1e9860dbab51c2a4180c35602a88..02cb7259b09d1aa8151aad640e438a6eb99c691e 100644 GIT binary patch delta 44 xcmdm#ek*;$5;Z{uhD3%GAS_}?Whe&1)XDPd%8aR#FRI2)UZBRZSx9{W4*)!#4UPZ+ delta 36 qcmcbWzA1gf5;cA$1_cINAXZ`sX7FSPm>j4YJ$Zqe$Yw9~2|NJB3JM|s