From 85b809f2c554f9089ad1276e9a0482b2f475b0d9 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Wed, 8 Aug 2012 16:58:55 +0200 Subject: [PATCH] Fix keyboard auto correction for contact views Fix contact without first name enhance contact first name / last name sizes --- Classes/LinphoneUI/UIContactCell.m | 37 +++++++++++---------- Classes/LinphoneUI/UIContactCell.xib | 29 ++++++++-------- Classes/LinphoneUI/UIContactDetailsHeader.m | 3 ++ 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Classes/LinphoneUI/UIContactCell.m b/Classes/LinphoneUI/UIContactCell.m index 2f1374df1..8e087186a 100644 --- a/Classes/LinphoneUI/UIContactCell.m +++ b/Classes/LinphoneUI/UIContactCell.m @@ -79,7 +79,7 @@ CFStringRef lFirstName = ABRecordCopyValue(contact, kABPersonFirstNameProperty); CFStringRef lLocalizedFirstName = (lFirstName != nil)?ABAddressBookCopyLocalizedLabel(lFirstName):nil; CFStringRef lLastName = ABRecordCopyValue(contact, kABPersonLastNameProperty); - CFStringRef lLocalizedLastName = (lFirstName != nil)?ABAddressBookCopyLocalizedLabel(lLastName):nil; + CFStringRef lLocalizedLastName = (lLastName != nil)?ABAddressBookCopyLocalizedLabel(lLastName):nil; if(lLocalizedFirstName != nil) [firstNameLabel setText: (NSString *)lLocalizedFirstName]; @@ -99,33 +99,34 @@ CFRelease(lLocalizedFirstName); if(lFirstName != nil) CFRelease(lFirstName); - - // Avatar - /*UIImage *image = [FastAddressBook getContactImage:contact thumbnail:true]; - if(image == nil) { - image = [UIImage imageNamed:@"avatar_unknown_small.png"]; - } - [avatarImage setImage:image];*/ - +} + +- (void)layoutSubviews { + [super layoutSubviews]; // // Adapt size // CGRect firstNameFrame = [firstNameLabel frame]; CGRect lastNameFrame = [lastNameLabel frame]; - lastNameFrame.origin.x -= firstNameFrame.size.width; - // Compute firstName size - CGSize contraints; - contraints.height = [firstNameLabel frame].size.height; - contraints.width = ([lastNameLabel frame].size.width + [lastNameLabel frame].origin.x) - [firstNameLabel frame].origin.x; - CGSize firstNameSize = [[firstNameLabel text] sizeWithFont:[firstNameLabel font] constrainedToSize: contraints]; + CGSize firstNameSize = [[firstNameLabel text] sizeWithFont:[firstNameLabel font]]; + CGSize lastNameSize = [[lastNameLabel text] sizeWithFont:[firstNameLabel font]]; + float sum = firstNameSize.width + 5 + lastNameSize.width; + float limit = self.bounds.size.width - 5 - firstNameFrame.origin.x; + if(sum >limit) { + firstNameSize.width *= limit/sum; + lastNameSize.width *= limit/sum; + } + firstNameFrame.size.width = firstNameSize.width; + lastNameFrame.size.width = lastNameSize.width; // Compute lastName size & position - lastNameFrame.origin.x += firstNameFrame.size.width; - lastNameFrame.size.width = (contraints.width + [firstNameLabel frame].origin.x) - lastNameFrame.origin.x; - + lastNameFrame.origin.x = firstNameFrame.origin.x + firstNameFrame.size.width; + if(firstNameFrame.size.width) + lastNameFrame.origin.x += 5; + [firstNameLabel setFrame: firstNameFrame]; [lastNameLabel setFrame: lastNameFrame]; } diff --git a/Classes/LinphoneUI/UIContactCell.xib b/Classes/LinphoneUI/UIContactCell.xib index 3a2893e5d..5fdff6747 100644 --- a/Classes/LinphoneUI/UIContactCell.xib +++ b/Classes/LinphoneUI/UIContactCell.xib @@ -3,18 +3,18 @@ 1296 11E53 - 2182 + 2549 1138.47 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 + 1498 - IBUIImageView - IBUIView - IBUILabel IBProxyObject + IBUIImageView + IBUILabel + IBUIView com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -34,11 +34,11 @@ - 292 + 274 - 292 + 300 {{6, 6}, {32, 32}} @@ -55,6 +55,10 @@ _NS:328 + + 3 + MCAwAA + NO YES 7 @@ -77,7 +81,6 @@ 25 16 - NO @@ -85,7 +88,9 @@ {{111, 0}, {200, 44}} + _NS:328 + NO YES 7 @@ -108,7 +113,6 @@ 25 16 - NO {320, 44} @@ -116,10 +120,7 @@ _NS:9 - - 3 - MCAwAA - + IBCocoaTouchFramework @@ -254,6 +255,6 @@ YES 3 - 1181 + 1498 diff --git a/Classes/LinphoneUI/UIContactDetailsHeader.m b/Classes/LinphoneUI/UIContactDetailsHeader.m index 2ca7037a9..48ead3574 100644 --- a/Classes/LinphoneUI/UIContactDetailsHeader.m +++ b/Classes/LinphoneUI/UIContactDetailsHeader.m @@ -170,6 +170,9 @@ UIEditableTableViewCell *cell = [atableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[[UIEditableTableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:kCellId] autorelease]; + [cell.detailTextField setAutocapitalizationType:UITextAutocapitalizationTypeWords]; + [cell.detailTextField setAutocorrectionType:UITextAutocorrectionTypeNo]; + [cell.detailTextField setKeyboardType:UIKeyboardTypeDefault]; } ABPropertyID property = [[propertyList objectAtIndex:[indexPath row]] intValue];