From d95028089be2307a500f9449e46c1034d6fb3113 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 22 Oct 2015 10:16:11 +0200 Subject: [PATCH] Contacts detail now working!!! --- Classes/Base.lproj/ContactDetailsView.xib | 6 +- Classes/ContactDetailsTableView.m | 123 ++++++++---------- Classes/ContactDetailsView.m | 2 +- Classes/LinphoneUI/UIContactDetailsCell.h | 38 ++++++ Classes/LinphoneUI/UIContactDetailsCell.m | 96 ++++++++++++++ Classes/LinphoneUI/UIContactDetailsCell.xib | 98 ++++++++++++++ Classes/LinphoneUI/UIEditableTableViewCell.h | 27 ---- Classes/LinphoneUI/UIEditableTableViewCell.m | 114 ---------------- .../LinphoneUI/UIEditableTableViewCell.xib | 33 ----- Classes/LinphoneUI/UIIconButton.h | 1 + Classes/LinphoneUI/UIIconButton.m | 4 + linphone.xcodeproj/project.pbxproj | 20 +-- 12 files changed, 305 insertions(+), 257 deletions(-) create mode 100644 Classes/LinphoneUI/UIContactDetailsCell.h create mode 100644 Classes/LinphoneUI/UIContactDetailsCell.m create mode 100644 Classes/LinphoneUI/UIContactDetailsCell.xib delete mode 100644 Classes/LinphoneUI/UIEditableTableViewCell.h delete mode 100644 Classes/LinphoneUI/UIEditableTableViewCell.m delete mode 100644 Classes/LinphoneUI/UIEditableTableViewCell.xib diff --git a/Classes/Base.lproj/ContactDetailsView.xib b/Classes/Base.lproj/ContactDetailsView.xib index 239e01980..20fcf95da 100644 --- a/Classes/Base.lproj/ContactDetailsView.xib +++ b/Classes/Base.lproj/ContactDetailsView.xib @@ -93,14 +93,14 @@ - + - + diff --git a/Classes/ContactDetailsTableView.m b/Classes/ContactDetailsTableView.m index a38b498b7..e049e0e73 100644 --- a/Classes/ContactDetailsTableView.m +++ b/Classes/ContactDetailsTableView.m @@ -19,7 +19,7 @@ #import "ContactDetailsTableView.h" #import "PhoneMainView.h" -#import "UIEditableTableViewCell.h" +#import "UIContactDetailsCell.h" #import "UACellBackgroundView.h" #import "Utils.h" #import "OrderedDictionary.h" @@ -496,13 +496,11 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *kCellId = @"ContactDetailsCell"; - UIEditableTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; + static NSString *kCellId = @"UIContactDetailsCell"; + UIContactDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { - cell = [[UIEditableTableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:kCellId]; - [cell.detailTextField setDelegate:self]; - [cell.detailTextField setAutocapitalizationType:UITextAutocapitalizationTypeNone]; - [cell.detailTextField setAutocorrectionType:UITextAutocorrectionTypeNo]; + cell = [[UIContactDetailsCell alloc] initWithIdentifier:kCellId]; + [cell.editTextfield setDelegate:self]; } NSMutableArray *sectionDict = [self getSectionData:[indexPath section]]; @@ -516,10 +514,12 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { value = (__bridge NSString *)(ABRecordCopyValue(contact, [self propertyIDForSection:ContactSections_First_Name])); label = nil; + [cell hideDeleteButton]; } else if (contactSections[indexPath.section] == ContactSections_Last_Name) { value = (__bridge NSString *)(ABRecordCopyValue(contact, [self propertyIDForSection:ContactSections_Last_Name])); label = nil; + [cell hideDeleteButton]; } else if (contactSections[[indexPath section]] == ContactSections_Number) { ABMultiValueRef lMap = ABRecordCopyValue(contact, kABPersonPhoneProperty); NSInteger index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]); @@ -569,18 +569,17 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { } CFRelease(lMap); } - [cell.textLabel setText:label]; - [cell.detailTextLabel setText:value]; - [cell.detailTextField setText:value]; + [cell.editTextfield setText:value]; + cell.addressLabel.text = value; if (contactSections[[indexPath section]] == ContactSections_Number) { - [cell.detailTextField setKeyboardType:UIKeyboardTypePhonePad]; - [cell.detailTextField setPlaceholder:NSLocalizedString(@"Phone number", nil)]; + [cell.editTextfield setKeyboardType:UIKeyboardTypePhonePad]; + [cell.editTextfield setPlaceholder:NSLocalizedString(@"Phone number", nil)]; } else if (contactSections[[indexPath section]] == ContactSections_Sip) { - [cell.detailTextField setKeyboardType:UIKeyboardTypeASCIICapable]; - [cell.detailTextField setPlaceholder:NSLocalizedString(@"SIP address", nil)]; + [cell.editTextfield setKeyboardType:UIKeyboardTypeASCIICapable]; + [cell.editTextfield setPlaceholder:NSLocalizedString(@"SIP address", nil)]; } else if (contactSections[[indexPath section]] == ContactSections_Email) { - [cell.detailTextField setKeyboardType:UIKeyboardTypeASCIICapable]; - [cell.detailTextField setPlaceholder:NSLocalizedString(@"Email address", nil)]; + [cell.editTextfield setKeyboardType:UIKeyboardTypeASCIICapable]; + [cell.editTextfield setPlaceholder:NSLocalizedString(@"Email address", nil)]; } return cell; } @@ -589,46 +588,7 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { [tableView deselectRowAtIndexPath:indexPath animated:NO]; NSMutableArray *sectionDict = [self getSectionData:[indexPath section]]; Entry *entry = [sectionDict objectAtIndex:[indexPath row]]; - if (![self isEditing]) { - NSString *dest = NULL; - ; - if (contactSections[[indexPath section]] == ContactSections_Number) { - ABMultiValueRef lMap = ABRecordCopyValue(contact, kABPersonPhoneProperty); - NSInteger index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]); - NSString *valueRef = CFBridgingRelease(ABMultiValueCopyValueAtIndex(lMap, index)); - if (valueRef != NULL) { - char normalizedPhoneNumber[256]; - linphone_proxy_config_normalize_number(linphone_core_get_default_proxy_config([LinphoneManager getLc]), - [valueRef UTF8String], normalizedPhoneNumber, - sizeof(normalizedPhoneNumber)); - dest = [NSString stringWithUTF8String:normalizedPhoneNumber]; - } - CFRelease(lMap); - } else if (contactSections[[indexPath section]] == ContactSections_Sip) { - ABMultiValueRef lMap = ABRecordCopyValue(contact, kABPersonInstantMessageProperty); - NSInteger index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]); - CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(lMap, index); - NSString *valueRef = (__bridge NSString *)(CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey)); - dest = [FastAddressBook normalizeSipURI:(NSString *)valueRef]; - CFRelease(lDict); - CFRelease(lMap); - } else if (contactSections[[indexPath section]] == ContactSections_Email) { - ABMultiValueRef lMap = ABRecordCopyValue(contact, kABPersonEmailProperty); - NSInteger index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]); - NSString *valueRef = CFBridgingRelease(ABMultiValueCopyValueAtIndex(lMap, index)); - if (valueRef != NULL) { - dest = [FastAddressBook normalizeSipURI:(NSString *)(valueRef)]; - } - CFRelease(lMap); - } - if (dest != nil) { - NSString *displayName = [FastAddressBook getContactDisplayName:contact]; - // Go to dialer view - DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - [view call:dest displayName:displayName]; - } - } else { + if ([self isEditing]) { NSString *key = nil; ABPropertyID property = [self propertyIDForSection:contactSections[indexPath.section]]; @@ -677,22 +637,18 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == ContactSections_First_Name || indexPath.section == ContactSections_Last_Name) { - return UITableViewCellEditingStyleNone; - } - NSInteger last_index = [[self getSectionData:[indexPath section]] count] - 1; - if (indexPath.row == last_index) { - return UITableViewCellEditingStyleInsert; - } - return UITableViewCellEditingStyleDelete; + return UITableViewCellEditingStyleNone; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { NSString *text = nil; + BOOL canAddEntry = self.tableView.isEditing; if (contactSections[section] == ContactSections_First_Name && self.tableView.isEditing) { text = NSLocalizedString(@"First name", nil); + canAddEntry = NO; } else if (contactSections[section] == ContactSections_Last_Name && self.tableView.isEditing) { text = NSLocalizedString(@"Last name", nil); + canAddEntry = NO; } else if ([self getSectionData:section].count > 0) { if (contactSections[section] == ContactSections_Number) { text = NSLocalizedString(@"Phone numbers", nil); @@ -707,10 +663,10 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { return nil; } - UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 20)]; + UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 35)]; tempView.backgroundColor = [UIColor whiteColor]; - UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, 300, 10)]; + UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, 300, 35)]; tempLabel.backgroundColor = [UIColor clearColor]; tempLabel.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_E"]]; tempLabel.text = text.uppercaseString; @@ -718,9 +674,31 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { tempLabel.font = [UIFont systemFontOfSize:12]; [tempView addSubview:tempLabel]; + if (canAddEntry) { + CGRect frame = CGRectMake(255, 5, 30, 30); + frame.origin.x = tableView.frame.size.width - 35; + UIIconButton *tempAddButton = [[UIIconButton alloc] initWithFrame:frame]; + [tempAddButton setImage:[UIImage imageNamed:@"add_field_default"] forState:UIControlStateNormal]; + [tempAddButton setImage:[UIImage imageNamed:@"add_field_over"] forState:UIControlStateHighlighted]; + [tempAddButton setImage:[UIImage imageNamed:@"add_field_over"] forState:UIControlStateSelected]; + [tempAddButton addTarget:self action:@selector(onAddClick:) forControlEvents:UIControlEventTouchUpInside]; + tempAddButton.tag = section; + [tempView addSubview:tempAddButton]; + } + return tempView; } +- (void)onAddClick:(id)sender { + NSInteger section = ((UIButton *)sender).tag; + UITableView *tableView = VIEW(ContactDetailsView).tableController.tableView; + NSInteger count = [self.tableView numberOfRowsInSection:section]; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:count inSection:section]; + [tableView.dataSource tableView:tableView + commitEditingStyle:UITableViewCellEditingStyleInsert + forRowAtIndexPath:indexPath]; +} + #pragma mark - ContactDetailsLabelDelegate Functions - (void)changeContactDetailsLabel:(NSString *)value { @@ -767,10 +745,10 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { - (BOOL)textFieldShouldEndEditing:(UITextField *)textField { UIView *view = [textField superview]; // Find TableViewCell - while (view != nil && ![view isKindOfClass:[UIEditableTableViewCell class]]) + while (view != nil && ![view isKindOfClass:[UIContactDetailsCell class]]) view = [view superview]; if (view != nil) { - UIEditableTableViewCell *cell = (UIEditableTableViewCell *)view; + UIContactDetailsCell *cell = (UIContactDetailsCell *)view; NSIndexPath *path = [self.tableView indexPathForCell:cell]; NSMutableArray *sectionDict = [self getSectionData:[path section]]; Entry *entry = [sectionDict objectAtIndex:[path row]]; @@ -791,7 +769,7 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { CFRelease(lMap); } - [cell.detailTextLabel setText:value]; + cell.editTextfield.text = value; } else { LOGE(@"Not valid UIEditableTableViewCell"); } @@ -804,6 +782,13 @@ static const ContactSections_e contactSections[ContactSections_MAX] = { return true; } +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + if (tableView.isEditing) { + return 44; + } else { + return 88; + } +} - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 1e-5; } diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 7f4811ecc..61741a7ba 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -223,7 +223,7 @@ static UICompositeViewDescription *compositeDescription = nil; CGRect frame = _tableController.tableView.frame; frame.origin.y = _nameLabel.frame.origin.y; - if (editing) { + if (!editing) { frame.origin.y += _nameLabel.frame.size.height; } _tableController.tableView.frame = frame; diff --git a/Classes/LinphoneUI/UIContactDetailsCell.h b/Classes/LinphoneUI/UIContactDetailsCell.h new file mode 100644 index 000000000..d168f372b --- /dev/null +++ b/Classes/LinphoneUI/UIContactDetailsCell.h @@ -0,0 +1,38 @@ +/* UIEditableTableViewCell.h + * + * Copyright (C) 2012 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import + +#import "UIIconButton.h" + +@interface UIContactDetailsCell : UITableViewCell + +@property(weak, nonatomic) IBOutlet UIView *defaultView; +@property(weak, nonatomic) IBOutlet UILabel *addressLabel; +@property(weak, nonatomic) IBOutlet UITextField *editTextfield; +@property(weak, nonatomic) IBOutlet UIView *editView; +@property(weak, nonatomic) IBOutlet UIIconButton *deleteButton; + +- (id)initWithIdentifier:(NSString *)identifier; +- (void)hideDeleteButton; +- (IBAction)onCallClick:(id)sender; +- (IBAction)onChatClick:(id)sender; +- (IBAction)onDeleteClick:(id)sender; + +@end diff --git a/Classes/LinphoneUI/UIContactDetailsCell.m b/Classes/LinphoneUI/UIContactDetailsCell.m new file mode 100644 index 000000000..eb37e12fe --- /dev/null +++ b/Classes/LinphoneUI/UIContactDetailsCell.m @@ -0,0 +1,96 @@ +/* UIEditableTableViewCell.m + * + * Copyright (C) 2012 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import "UIContactDetailsCell.h" +#import "PhoneMainView.h" + +@implementation UIContactDetailsCell + +#pragma mark - Lifecycle Functions + +- (id)initWithIdentifier:(NSString *)identifier { + if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]) != nil) { + NSArray *arrayOfViews = + [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil]; + + // resize cell to match .nib size. It is needed when resized the cell to + // correctly adapt its height too + UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:0]); + [self setFrame:CGRectMake(0, 0, sub.frame.size.width, sub.frame.size.height)]; + [self addSubview:sub]; + } + return self; +} + +#pragma mark - UITableViewCell Functions + +- (void)hideDeleteButton { + CGRect newFrame = _editTextfield.frame; + newFrame.size.width += _deleteButton.frame.size.width; + _editTextfield.frame = newFrame; + + _deleteButton.hidden = YES; +} + +- (void)setEditing:(BOOL)editing animated:(BOOL)animated { + [super setEditing:editing animated:animated]; + + _defaultView.hidden = editing; + _editView.hidden = !editing; +} + +- (void)setEditing:(BOOL)editing { + [self setEditing:editing animated:FALSE]; +} + +- (IBAction)onCallClick:(id)event { + LinphoneAddress *addr = linphone_core_interpret_url([LinphoneManager getLc], _addressLabel.text.UTF8String); + char *lAddress = linphone_address_as_string_uri_only(addr); + if (lAddress == NULL) + return; + NSString *displayName = [FastAddressBook displayNameForAddress:addr]; + + DialerView *view = VIEW(DialerView); + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + [view call:[NSString stringWithUTF8String:lAddress] displayName:displayName]; + ms_free(lAddress); + linphone_address_destroy(addr); +} + +- (IBAction)onChatClick:(id)event { + LinphoneAddress *addr = linphone_core_interpret_url([LinphoneManager getLc], _addressLabel.text.UTF8String); + if (addr == NULL) + return; + [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; + ChatConversationView *view = VIEW(ChatConversationView); + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + LinphoneChatRoom *room = linphone_core_get_chat_room([LinphoneManager getLc], addr); + [view setChatRoom:room]; + linphone_address_destroy(addr); +} + +- (IBAction)onDeleteClick:(id)sender { + UITableView *tableView = VIEW(ContactDetailsView).tableController.tableView; + NSIndexPath *indexPath = [tableView indexPathForCell:self]; + [tableView.dataSource tableView:tableView + commitEditingStyle:UITableViewCellEditingStyleDelete + forRowAtIndexPath:indexPath]; +} + +@end diff --git a/Classes/LinphoneUI/UIContactDetailsCell.xib b/Classes/LinphoneUI/UIContactDetailsCell.xib new file mode 100644 index 000000000..4b84e867d --- /dev/null +++ b/Classes/LinphoneUI/UIContactDetailsCell.xib @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Classes/LinphoneUI/UIEditableTableViewCell.h b/Classes/LinphoneUI/UIEditableTableViewCell.h deleted file mode 100644 index 0c1f2012e..000000000 --- a/Classes/LinphoneUI/UIEditableTableViewCell.h +++ /dev/null @@ -1,27 +0,0 @@ -/* UIEditableTableViewCell.h - * - * Copyright (C) 2012 Belledonne Comunications, Grenoble, France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#import - -@interface UIEditableTableViewCell : UITableViewCell - -@property (nonatomic, strong) IBOutlet UIView *verticalSep; -@property (nonatomic, strong) IBOutlet UITextField *detailTextField; - -@end diff --git a/Classes/LinphoneUI/UIEditableTableViewCell.m b/Classes/LinphoneUI/UIEditableTableViewCell.m deleted file mode 100644 index 4d8cd8b10..000000000 --- a/Classes/LinphoneUI/UIEditableTableViewCell.m +++ /dev/null @@ -1,114 +0,0 @@ -/* UIEditableTableViewCell.m - * - * Copyright (C) 2012 Belledonne Comunications, Grenoble, France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#import "UIEditableTableViewCell.h" - -@implementation UIEditableTableViewCell - -@synthesize detailTextField; -@synthesize verticalSep; - -#pragma mark - Lifecycle Functions - -- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; - if (self) { - UITextField *tf = [[UITextField alloc] init]; - tf.hidden = TRUE; - tf.clearButtonMode = UITextFieldViewModeWhileEditing; - tf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; - tf.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; - - self.detailTextField = tf; - - UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:[UIFont systemFontSize]]; - [self.detailTextLabel setFont:font]; - [self.detailTextField setFont:font]; - - self.detailTextLabel.backgroundColor = self.detailTextField.backgroundColor = - [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A"]]; - - [self.contentView addSubview:detailTextField]; - - // a vertical separator that will come between the text and detailed text - UIView *v = [[UIView alloc] initWithFrame:CGRectMake(80, 5, 1, 34)]; - [v setBackgroundColor:[UIColor lightGrayColor]]; - [v setHidden:TRUE]; - - self.verticalSep = v; - - [self.contentView addSubview:verticalSep]; - } - return self; -} - -#pragma mark - View Functions - -- (void)layoutSubviews { - [super layoutSubviews]; - - CGRect superframe = [[self.detailTextField superview] frame]; - CGRect detailEditFrame; - detailEditFrame.origin.x = 15; - detailEditFrame.origin.y = 5; - detailEditFrame.size.height = superframe.size.height - 10; - -#if 0 - if ([[self.textLabel text] length] != 0) { - detailEditFrame.origin.x += [self.textLabel frame].size.width + 8; - - // shrink left text width by 10px - CGRect leftLabelFrame = [self.textLabel frame]; - leftLabelFrame.size.width -= 10; - [self.textLabel setFrame:leftLabelFrame]; - - // place separator between left text and detailed text - CGRect separatorFrame = [self.verticalSep frame]; - separatorFrame.origin.x = leftLabelFrame.size.width + leftLabelFrame.origin.x + 5; - [self.verticalSep setFrame:separatorFrame]; - [self.verticalSep setHidden:FALSE]; - } -#endif - // put the detailed text edit view at the correct position - detailEditFrame.size.width = superframe.size.width - 10 - detailEditFrame.origin.x; - self.detailTextField.frame = detailEditFrame; -} - -#pragma mark - UITableViewCell Functions - -- (void)setEditing:(BOOL)editing animated:(BOOL)animated { - [super setEditing:editing animated:animated]; - if (editing) { - [self.detailTextField setHidden:FALSE]; - [self.detailTextLabel setHidden:TRUE]; - } else { - [self.detailTextField setHidden:TRUE]; - [self.detailTextLabel setHidden:FALSE]; - } -} - -- (void)setEditing:(BOOL)editing { - [self setEditing:editing animated:FALSE]; -} - -- (void)setSelected:(BOOL)selected animated:(BOOL)animated { - [super setSelected:selected animated:animated]; -} - -@end diff --git a/Classes/LinphoneUI/UIEditableTableViewCell.xib b/Classes/LinphoneUI/UIEditableTableViewCell.xib deleted file mode 100644 index 60b4509ae..000000000 --- a/Classes/LinphoneUI/UIEditableTableViewCell.xib +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Classes/LinphoneUI/UIIconButton.h b/Classes/LinphoneUI/UIIconButton.h index 741b833b9..641d06ad0 100644 --- a/Classes/LinphoneUI/UIIconButton.h +++ b/Classes/LinphoneUI/UIIconButton.h @@ -9,4 +9,5 @@ #import @interface UIIconButton : UIButton + @end diff --git a/Classes/LinphoneUI/UIIconButton.m b/Classes/LinphoneUI/UIIconButton.m index 8fa252ba3..04c422dd7 100644 --- a/Classes/LinphoneUI/UIIconButton.m +++ b/Classes/LinphoneUI/UIIconButton.m @@ -35,4 +35,8 @@ return [[super initWithFrame:frame] fixBackgroundImageForState]; } +- (void)setImage:(UIImage *)image forState:(UIControlState)state { + [super setImage:image forState:state]; + [self fixBackgroundImageForState]; +} @end diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 205fc2330..f913a0051 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -107,7 +107,7 @@ 636BC9971B5F921B00C754CE /* UIIconButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 636BC9961B5F921B00C754CE /* UIIconButton.m */; }; 63701DD61BA31DA1006A9AE3 /* UIConfirmationDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 63701DD51BA31DA1006A9AE3 /* UIConfirmationDialog.xib */; }; 63701DDF1BA32039006A9AE3 /* UIConfirmationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 63701DDE1BA32039006A9AE3 /* UIConfirmationDialog.m */; }; - 637144571BD531CE007E7C06 /* UIEditableTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 637144561BD531CE007E7C06 /* UIEditableTableViewCell.xib */; }; + 637144571BD531CE007E7C06 /* UIContactDetailsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 637144561BD531CE007E7C06 /* UIContactDetailsCell.xib */; }; 637157A11B283FE200C91677 /* FileTransferDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 637157A01B283FE200C91677 /* FileTransferDelegate.m */; }; 637527C91BBA8EF700FDEA6F /* add_field_default.png in Resources */ = {isa = PBXBuildFile; fileRef = 6375271A1BBA8EF700FDEA6F /* add_field_default.png */; }; 637527CA1BBA8EF700FDEA6F /* add_field_over.png in Resources */ = {isa = PBXBuildFile; fileRef = 6375271B1BBA8EF700FDEA6F /* add_field_over.png */; }; @@ -428,7 +428,7 @@ D381881915FE3FCA00C3EDCA /* CallView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D381881C15FE3FCA00C3EDCA /* CallView.xib */; }; D3A55FBC15877E5E003FD403 /* UIContactCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D3A55FBB15877E5E003FD403 /* UIContactCell.m */; }; D3A8BB7015A6C7D500F96BE5 /* UIChatBubbleTextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D3A8BB6F15A6C7D500F96BE5 /* UIChatBubbleTextCell.m */; }; - D3C6526715AC1A8F0092A874 /* UIEditableTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D3C6526615AC1A8F0092A874 /* UIEditableTableViewCell.m */; }; + D3C6526715AC1A8F0092A874 /* UIContactDetailsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D3C6526615AC1A8F0092A874 /* UIContactDetailsCell.m */; }; D3D5126C160B3A8E00946DF8 /* AssistantSubviews.xib in Resources */ = {isa = PBXBuildFile; fileRef = D3D5126A160B3A8E00946DF8 /* AssistantSubviews.xib */; }; D3EA53FD159850E80037DC6B /* LinphoneManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EA53FC159850E80037DC6B /* LinphoneManager.m */; }; D3EA540D1598528B0037DC6B /* ChatsListTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EA540C1598528B0037DC6B /* ChatsListTableView.m */; }; @@ -737,7 +737,7 @@ 63701DD51BA31DA1006A9AE3 /* UIConfirmationDialog.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UIConfirmationDialog.xib; sourceTree = ""; }; 63701DDD1BA32039006A9AE3 /* UIConfirmationDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIConfirmationDialog.h; sourceTree = ""; }; 63701DDE1BA32039006A9AE3 /* UIConfirmationDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIConfirmationDialog.m; sourceTree = ""; }; - 637144561BD531CE007E7C06 /* UIEditableTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UIEditableTableViewCell.xib; sourceTree = ""; }; + 637144561BD531CE007E7C06 /* UIContactDetailsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UIContactDetailsCell.xib; sourceTree = ""; }; 6371579F1B283FE200C91677 /* FileTransferDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileTransferDelegate.h; path = Utils/FileTransferDelegate.h; sourceTree = ""; }; 637157A01B283FE200C91677 /* FileTransferDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileTransferDelegate.m; path = Utils/FileTransferDelegate.m; sourceTree = ""; }; 6375271A1BBA8EF700FDEA6F /* add_field_default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_field_default.png; sourceTree = ""; }; @@ -1086,8 +1086,8 @@ D3A55FBB15877E5E003FD403 /* UIContactCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIContactCell.m; sourceTree = ""; }; D3A8BB6E15A6C7D500F96BE5 /* UIChatBubbleTextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIChatBubbleTextCell.h; sourceTree = ""; }; D3A8BB6F15A6C7D500F96BE5 /* UIChatBubbleTextCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIChatBubbleTextCell.m; sourceTree = ""; }; - D3C6526515AC1A8F0092A874 /* UIEditableTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditableTableViewCell.h; sourceTree = ""; }; - D3C6526615AC1A8F0092A874 /* UIEditableTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIEditableTableViewCell.m; sourceTree = ""; }; + D3C6526515AC1A8F0092A874 /* UIContactDetailsCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIContactDetailsCell.h; sourceTree = ""; }; + D3C6526615AC1A8F0092A874 /* UIContactDetailsCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIContactDetailsCell.m; sourceTree = ""; }; D3EA53FB159850E80037DC6B /* LinphoneManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneManager.h; sourceTree = ""; }; D3EA53FC159850E80037DC6B /* LinphoneManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinphoneManager.m; sourceTree = ""; }; D3EA540B1598528B0037DC6B /* ChatsListTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatsListTableView.h; sourceTree = ""; }; @@ -1510,9 +1510,9 @@ F088488D19FF8C41007FFCF3 /* UIContactCell.xib */, 2248E90C12F7E4CF00220D9C /* UIDigitButton.h */, 2248E90D12F7E4CF00220D9C /* UIDigitButton.m */, - D3C6526515AC1A8F0092A874 /* UIEditableTableViewCell.h */, - D3C6526615AC1A8F0092A874 /* UIEditableTableViewCell.m */, - 637144561BD531CE007E7C06 /* UIEditableTableViewCell.xib */, + D3C6526515AC1A8F0092A874 /* UIContactDetailsCell.h */, + D3C6526615AC1A8F0092A874 /* UIContactDetailsCell.m */, + 637144561BD531CE007E7C06 /* UIContactDetailsCell.xib */, 2214EB8712F84EBB002A5394 /* UIHangUpButton.h */, 2214EB8812F84EBB002A5394 /* UIHangUpButton.m */, D31C9C96158A1CDE00756B45 /* UIHistoryCell.h */, @@ -2366,7 +2366,7 @@ 639CEAFD1A1DF4D9004DE38F /* StatusBarView.xib in Resources */, 637527DD1BBA8EF700FDEA6F /* call_status_incoming.png in Resources */, 637528321BBA8EF700FDEA6F /* numpad_3_over.png in Resources */, - 637144571BD531CE007E7C06 /* UIEditableTableViewCell.xib in Resources */, + 637144571BD531CE007E7C06 /* UIContactDetailsCell.xib in Resources */, F088488A19FF8C41007FFCF3 /* UIContactCell.xib in Resources */, 637527E51BBA8EF700FDEA6F /* camera_switch_disabled.png in Resources */, 6375280F1BBA8EF700FDEA6F /* delete_field_default.png in Resources */, @@ -2719,7 +2719,7 @@ D3128FE115AABC7E00A2147A /* ContactDetailsView.m in Sources */, D37C639B15AADEF6009D0BAC /* ContactDetailsTableView.m in Sources */, 63E59A3F1ADE70D900646FB3 /* InAppProductsManager.m in Sources */, - D3C6526715AC1A8F0092A874 /* UIEditableTableViewCell.m in Sources */, + D3C6526715AC1A8F0092A874 /* UIContactDetailsCell.m in Sources */, 631348301B6F7B6600C6BDCB /* UIRoundBorderedButton.m in Sources */, C90FAA7915AF54E6002091CB /* HistoryDetailsView.m in Sources */, 63FB30351A680E73008CA393 /* UIRoundedImageView.m in Sources */,