forked from mirrors/linphone-iphone
96 lines
3 KiB
Objective-C
96 lines
3 KiB
Objective-C
/* UIContactCell.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 Library 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 "UIContactCell.h"
|
|
#import "Utils.h"
|
|
#import "FastAddressBook.h"
|
|
#import "UILabel+Boldify.h"
|
|
|
|
@implementation UIContactCell
|
|
|
|
@synthesize nameLabel;
|
|
@synthesize avatarImage;
|
|
@synthesize contact;
|
|
|
|
#pragma mark - Lifecycle Functions
|
|
|
|
- (id)initWithIdentifier:(NSString *)identifier {
|
|
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]) != nil) {
|
|
NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"UIContactCell" owner:self options:nil];
|
|
|
|
if ([arrayOfViews count] >= 1) {
|
|
[self.contentView addSubview:[arrayOfViews objectAtIndex:0]];
|
|
}
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Property Functions
|
|
|
|
- (void)setContact:(ABRecordRef)acontact {
|
|
contact = acontact;
|
|
if (contact != nil) {
|
|
NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty));
|
|
NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName];
|
|
|
|
NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty));
|
|
NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName];
|
|
|
|
NSString *lOrganization = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonOrganizationProperty));
|
|
NSString *lLocalizedOrganization = [FastAddressBook localizedLabel:lOrganization];
|
|
|
|
if (lLocalizedFirstName == nil && lLocalizedLastName == nil) {
|
|
[nameLabel setText:(NSString *)(lLocalizedOrganization)];
|
|
} else {
|
|
nameLabel.text = [NSString stringWithFormat:@"%@ %@", lLocalizedFirstName, lLocalizedLastName];
|
|
[nameLabel boldSubstring:lLocalizedLastName];
|
|
}
|
|
|
|
_linphoneImage.hidden = !([FastAddressBook contactHasValidSipDomain:contact]);
|
|
}
|
|
}
|
|
|
|
#pragma mark -
|
|
|
|
- (void)touchUp:(id)sender {
|
|
[self setHighlighted:true animated:true];
|
|
}
|
|
|
|
- (void)touchDown:(id)sender {
|
|
[self setHighlighted:false animated:true];
|
|
}
|
|
|
|
- (NSString *)accessibilityLabel {
|
|
return nameLabel.text;
|
|
}
|
|
|
|
- (void)setHighlighted:(BOOL)highlighted {
|
|
[self setHighlighted:highlighted animated:FALSE];
|
|
}
|
|
|
|
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
|
|
[super setHighlighted:highlighted animated:animated];
|
|
if (highlighted) {
|
|
[nameLabel setTextColor:[UIColor whiteColor]];
|
|
} else {
|
|
[nameLabel setTextColor:[UIColor blackColor]];
|
|
}
|
|
}
|
|
|
|
@end
|