diff --git a/Classes/Base.lproj/HistoryDetailsViewController.xib b/Classes/Base.lproj/HistoryDetailsViewController.xib index 4efb9cf94..d367ba3e9 100644 --- a/Classes/Base.lproj/HistoryDetailsViewController.xib +++ b/Classes/Base.lproj/HistoryDetailsViewController.xib @@ -8,8 +8,9 @@ - + + @@ -49,11 +50,11 @@ - + - + @@ -61,7 +62,7 @@ - + @@ -99,17 +100,23 @@ diff --git a/Classes/HistoryDetailsTableViewController.m b/Classes/HistoryDetailsTableViewController.m index 7f36f46b3..e0b7e7543 100644 --- a/Classes/HistoryDetailsTableViewController.m +++ b/Classes/HistoryDetailsTableViewController.m @@ -44,7 +44,7 @@ LinphoneCallLog *log = [[callLogs objectAtIndex:[indexPath row]] pointerValue]; int duration = linphone_call_log_get_duration(log); time_t callTime = linphone_call_log_get_start_date(log); - + cell.textLabel.textAlignment = NSTextAlignmentCenter; [cell.textLabel setText:[NSString stringWithFormat:@"%@ - %d sec", [LinphoneUtils timeToString:callTime withStyle:NSDateFormatterMediumStyle], diff --git a/Classes/HistoryDetailsViewController.h b/Classes/HistoryDetailsViewController.h index ca292f75b..b32916592 100644 --- a/Classes/HistoryDetailsViewController.h +++ b/Classes/HistoryDetailsViewController.h @@ -29,18 +29,9 @@ LinphoneCallLog *callLog; NSDateFormatter *dateFormatter; } +@property(weak, nonatomic) IBOutlet UILabel *contactLabel; @property (nonatomic, strong) IBOutlet UIImageView *avatarImage; @property (nonatomic, strong) IBOutlet UILabel *addressLabel; -@property (nonatomic, strong) IBOutlet UILabel *dateLabel; -@property (nonatomic, strong) IBOutlet UILabel *dateHeaderLabel; -@property (nonatomic, strong) IBOutlet UILabel *durationLabel; -@property (nonatomic, strong) IBOutlet UILabel *durationHeaderLabel; -@property (nonatomic, strong) IBOutlet UILabel *typeLabel; -@property (nonatomic, strong) IBOutlet UILabel *typeHeaderLabel; -@property (nonatomic, strong) IBOutlet UILabel *plainAddressLabel; -@property (nonatomic, strong) IBOutlet UILabel *plainAddressHeaderLabel; -@property (nonatomic, strong) IBOutlet UIButton *callButton; -@property (nonatomic, strong) IBOutlet UIButton *messageButton; @property (nonatomic, strong) IBOutlet UIButton *addContactButton; @property (nonatomic, copy, setter=setCallLogId:) NSString *callLogId; @property(weak, nonatomic) IBOutlet UIView *headerView; @@ -48,10 +39,9 @@ @property(strong, nonatomic) IBOutlet HistoryDetailsTableViewController *tableView; - (IBAction)onBackClick:(id)event; -- (IBAction)onContactClick:(id)event; - (IBAction)onAddContactClick:(id)event; - (IBAction)onCallClick:(id)event; -- (IBAction)onMessageClick:(id)event; +- (IBAction)onChatClick:(id)event; - (void)setCallLogId:(NSString *)acallLogId; @end diff --git a/Classes/HistoryDetailsViewController.m b/Classes/HistoryDetailsViewController.m index 6f95cfbac..4c22e4211 100644 --- a/Classes/HistoryDetailsViewController.m +++ b/Classes/HistoryDetailsViewController.m @@ -25,21 +25,6 @@ @implementation HistoryDetailsViewController { } -@synthesize callLogId; -@synthesize avatarImage; -@synthesize addressLabel; -@synthesize dateLabel; -@synthesize dateHeaderLabel; -@synthesize durationLabel; -@synthesize durationHeaderLabel; -@synthesize typeLabel; -@synthesize typeHeaderLabel; -@synthesize plainAddressLabel; -@synthesize plainAddressHeaderLabel; -@synthesize callButton; -@synthesize messageButton; -@synthesize addContactButton; - #pragma mark - LifeCycle Functions - (id)init { @@ -78,7 +63,7 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Property Functions - (void)setCallLogId:(NSString *)acallLogId { - self->callLogId = [acallLogId copy]; + _callLogId = [acallLogId copy]; [self update]; } @@ -90,11 +75,6 @@ static UICompositeViewDescription *compositeDescription = nil; UITapGestureRecognizer *headerTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onContactClick:)]; [_headerView addGestureRecognizer:headerTapGesture]; - - [HistoryDetailsViewController adaptSize:dateHeaderLabel field:dateLabel]; - [HistoryDetailsViewController adaptSize:durationHeaderLabel field:durationLabel]; - [HistoryDetailsViewController adaptSize:typeHeaderLabel field:typeLabel]; - [HistoryDetailsViewController adaptSize:plainAddressHeaderLabel field:plainAddressLabel]; } - (void)viewWillAppear:(BOOL)animated { @@ -102,7 +82,7 @@ static UICompositeViewDescription *compositeDescription = nil; BOOL use_system = [[LinphoneManager instance] lpConfigBoolForKey:@"use_system_contacts"]; if (use_system) { - [addContactButton setHidden:TRUE]; + _addContactButton.hidden = TRUE; } [_tableView loadData]; @@ -158,129 +138,41 @@ static UICompositeViewDescription *compositeDescription = nil; [field setFrame:fieldFrame]; } -- (void)update { - +- (void)retrieveCallLog { // Look for the call log callLog = NULL; const MSList *list = linphone_core_get_call_logs([LinphoneManager getLc]); while (list != NULL) { LinphoneCallLog *log = (LinphoneCallLog *)list->data; const char *cid = linphone_call_log_get_call_id(log); - if (cid != NULL && [callLogId isEqualToString:[NSString stringWithUTF8String:cid]]) { + if (cid != NULL && [_callLogId isEqualToString:[NSString stringWithUTF8String:cid]]) { callLog = log; break; } list = list->next; } +} +- (void)update { // Pop if callLog is null + [self retrieveCallLog]; if (callLog == NULL) { [[PhoneMainView instance] popCurrentView]; return; } LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); + // this address should NEVER be NULL: if this assert is broken, the bug is elsewhere. + assert(addr != NULL); - UIImage *image = nil; - NSString *address = nil; - if (addr != NULL) { - BOOL useLinphoneAddress = true; - // contact name - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress) { - NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]]; - contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if (contact) { - image = [FastAddressBook getContactImage:contact thumbnail:true]; - address = [FastAddressBook getContactDisplayName:contact]; - useLinphoneAddress = false; - } - ms_free(lAddress); - } - if (useLinphoneAddress) { - const char *lDisplayName = linphone_address_get_display_name(addr); - const char *lUserName = linphone_address_get_username(addr); - if (lDisplayName) - address = [NSString stringWithUTF8String:lDisplayName]; - else if (lUserName) - address = [NSString stringWithUTF8String:lUserName]; - } - } + [FastAddressBook setDisplayNameLabel:_contactLabel forAddress:addr]; + _avatarImage.image = [FastAddressBook avatarForAddress:addr]; + char *addrURI = linphone_address_as_string_uri_only(addr); + _addressLabel.text = [NSString stringWithUTF8String:addrURI]; + ms_free(addrURI); - // Set Image - if (image == nil) { - image = [UIImage imageNamed:@"avatar_unknown.png"]; - } - [avatarImage setImage:image]; - - // Set Address - if (address == nil) { - address = NSLocalizedString(@"Unknown", nil); - } - [addressLabel setText:address]; - - // Hide/Show add button BOOL use_system = [[LinphoneManager instance] lpConfigBoolForKey:@"use_system_contacts"]; - if (contact) { - [addContactButton setHidden:TRUE]; - } else if (!use_system) { - [addContactButton setHidden:FALSE]; - } - - // State - NSMutableString *state = [NSMutableString string]; - if (linphone_call_log_get_dir(callLog) == LinphoneCallIncoming) { - [state setString:NSLocalizedString(@"Incoming call", nil)]; - } else { - [state setString:NSLocalizedString(@"Outgoing call", nil)]; - } - switch (linphone_call_log_get_status(callLog)) { - case LinphoneCallSuccess: - break; - case LinphoneCallAborted: - [state appendString:NSLocalizedString(@" (Aborted)", nil)]; - break; - case LinphoneCallMissed: - [state appendString:NSLocalizedString(@" (Missed)", nil)]; - break; - case LinphoneCallDeclined: - [state appendString:NSLocalizedString(@" (Declined)", nil)]; - break; - } - [typeLabel setText:state]; - - // Date - NSDate *startData = [NSDate dateWithTimeIntervalSince1970:linphone_call_log_get_start_date(callLog)]; - [dateLabel setText:[dateFormatter stringFromDate:startData]]; - - // Duration - int duration = linphone_call_log_get_duration(callLog); - [durationLabel - setText:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), duration - 60 * (duration / 60), nil]]; - - // contact name - [plainAddressLabel setText:@""]; - if (addr != NULL) { - if ([[LinphoneManager instance] lpConfigBoolForKey:@"contact_display_username_only"]) { - [plainAddressLabel setText:[NSString stringWithUTF8String:linphone_address_get_username(addr) - ? linphone_address_get_username(addr) - : ""]]; - } else { - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress != NULL) { - [plainAddressLabel setText:[NSString stringWithUTF8String:lAddress]]; - ms_free(lAddress); - } - } - } - - if (addr != NULL) { - [callButton setHidden:FALSE]; - [messageButton setHidden:FALSE]; - } else { - [callButton setHidden:TRUE]; - [messageButton setHidden:TRUE]; - } + _addContactButton.hidden = contact || use_system; } #pragma mark - Action Functions @@ -315,51 +207,31 @@ static UICompositeViewDescription *compositeDescription = nil; [ContactSelection setSipFilter:nil]; [ContactSelection enableEmailFilter:FALSE]; [ContactSelection setNameOrEmailFilter:nil]; - ContactsViewController *controller = DYNAMIC_CAST( - [[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] - push:TRUE], - ContactsViewController); - if (controller != nil) { - } + DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] + push:TRUE], + ContactsViewController); ms_free(lAddress); } } } - (IBAction)onCallClick:(id)event { - LinphoneAddress *addr; - addr = linphone_call_log_get_remote_address(callLog); - + LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); char *lAddress = linphone_address_as_string_uri_only(addr); if (lAddress == NULL) return; - - NSString *displayName = nil; - if (contact != nil) { - displayName = [FastAddressBook getContactDisplayName:contact]; - } else { - const char *lDisplayName = linphone_address_get_display_name(addr); - const char *lUserName = linphone_address_get_username(addr); - if (lDisplayName) - displayName = [NSString stringWithUTF8String:lDisplayName]; - else if (lUserName) - displayName = [NSString stringWithUTF8String:lUserName]; - } + NSString *displayName = [FastAddressBook displayNameForAddress:addr]; DialerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[DialerViewController compositeViewDescription]], DialerViewController); if (controller != nil) { - if (displayName != nil) { - [controller call:[NSString stringWithUTF8String:lAddress] displayName:displayName]; - } else { - [controller call:[NSString stringWithUTF8String:lAddress]]; - } + [controller call:[NSString stringWithUTF8String:lAddress] displayName:displayName]; } ms_free(lAddress); } -- (IBAction)onMessageClick:(id)event { +- (IBAction)onChatClick:(id)event { LinphoneAddress *addr; addr = linphone_call_log_get_remote_address(callLog); diff --git a/Classes/LinphoneUI/Base.lproj/UIMainBar.xib b/Classes/LinphoneUI/Base.lproj/UIMainBar.xib index e269f6777..07ed5111f 100644 --- a/Classes/LinphoneUI/Base.lproj/UIMainBar.xib +++ b/Classes/LinphoneUI/Base.lproj/UIMainBar.xib @@ -1,7 +1,6 @@ - diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 875531ed9..af7fed6e1 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -95,7 +95,7 @@ _chatLatestTimeLabel.hidden = NO; } else { chatContentLabel.text = nil; - _chatLatestTimeLabel.hidden = YES; + _chatLatestTimeLabel.text = NSLocalizedString(@"Now", nil); } int count = linphone_chat_room_get_unread_messages_count(chatRoom); diff --git a/Classes/Utils/FastAddressBook.h b/Classes/Utils/FastAddressBook.h index 4d830d9f4..fcfb52ae6 100644 --- a/Classes/Utils/FastAddressBook.h +++ b/Classes/Utils/FastAddressBook.h @@ -46,4 +46,7 @@ + (BOOL)contactHasValidSipDomain:(ABRecordRef)person; + (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr; + (void)setDisplayNameLabel:(UILabel *)label forContact:(ABRecordRef)contact; ++ (NSString *)displayNameForAddress:(const LinphoneAddress *)addr; ++ (NSString *)displayNameForContact:(ABRecordRef)contact; + @end diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 0d2088c9a..849d16b4b 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -312,6 +312,14 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void } + (void)setDisplayNameLabel:(UILabel *)label forContact:(ABRecordRef)contact { + label.text = [FastAddressBook displayNameForContact:contact]; + NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty)); + NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName]; + [label boldSubstring:lLocalizedLastName]; +} + ++ (NSString *)displayNameForContact:(ABRecordRef)contact { + NSString *ret = nil; if (contact != nil) { NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty)); NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName]; @@ -323,16 +331,16 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void NSString *lLocalizedOrganization = [FastAddressBook localizedLabel:lOrganization]; if (lLocalizedFirstName == nil && lLocalizedLastName == nil) { - label.text = (NSString *)lLocalizedOrganization; + ret = (NSString *)lLocalizedOrganization; } else { - label.text = [NSString stringWithFormat:@"%@ %@", lLocalizedFirstName, lLocalizedLastName]; - [label boldSubstring:lLocalizedLastName]; + ret = [NSString stringWithFormat:@"%@ %@", lLocalizedFirstName, lLocalizedLastName]; } } + return ret; } -+ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr { - label.text = NSLocalizedString(@"Unknown", nil); ++ (NSString *)displayNameForAddress:(const LinphoneAddress *)addr { + NSString *ret = NSLocalizedString(@"Unknown", nil); if (addr != NULL) { char *lAddress = linphone_address_as_string_uri_only(addr); if (lAddress) { @@ -340,18 +348,22 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void ms_free(lAddress); ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; if (contact) { - [FastAddressBook setDisplayNameLabel:label forContact:contact]; - return; + return [FastAddressBook displayNameForContact:contact]; } } const char *lDisplayName = linphone_address_get_display_name(addr); const char *lUserName = linphone_address_get_username(addr); if (lDisplayName) { - label.text = [NSString stringWithUTF8String:lDisplayName]; + ret = [NSString stringWithUTF8String:lDisplayName]; } else if (lUserName) { - label.text = [NSString stringWithUTF8String:lUserName]; + ret = [NSString stringWithUTF8String:lUserName]; } } + return ret; +} + ++ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr { + label.text = [FastAddressBook displayNameForAddress:addr]; } + (UIImage *)avatarForAddress:(const LinphoneAddress *)addr { diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 42c20ee9c..118e13497 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -244,8 +244,6 @@ 634CEE161B6630DB00D7A921 /* valid.png in Resources */ = {isa = PBXBuildFile; fileRef = 634CED911B6630DB00D7A921 /* valid.png */; }; 634CEE171B6630DB00D7A921 /* voicemail.png in Resources */ = {isa = PBXBuildFile; fileRef = 634CED921B6630DB00D7A921 /* voicemail.png */; }; 635775251B6673EC00C8B704 /* HistoryDetailsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 635775241B6673EC00C8B704 /* HistoryDetailsTableViewController.m */; }; - 6357752E1B6676C200C8B704 /* UIHistoryDetailsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6357752D1B6676C200C8B704 /* UIHistoryDetailsCell.m */; }; - 635775311B66777200C8B704 /* UIHistoryDetailsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6357752F1B66777200C8B704 /* UIHistoryDetailsCell.xib */; }; 636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D31A1DEBCB0009B839 /* AboutViewController.xib */; }; 636316D41A1DEC650009B839 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsViewController.xib */; }; 636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; }; @@ -803,9 +801,6 @@ 634CED921B6630DB00D7A921 /* voicemail.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = voicemail.png; sourceTree = ""; }; 635775231B6673EC00C8B704 /* HistoryDetailsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HistoryDetailsTableViewController.h; sourceTree = ""; }; 635775241B6673EC00C8B704 /* HistoryDetailsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HistoryDetailsTableViewController.m; sourceTree = ""; }; - 6357752C1B6676C200C8B704 /* UIHistoryDetailsCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIHistoryDetailsCell.h; sourceTree = ""; }; - 6357752D1B6676C200C8B704 /* UIHistoryDetailsCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIHistoryDetailsCell.m; sourceTree = ""; }; - 635775301B66777200C8B704 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/UIHistoryDetailsCell.xib; sourceTree = ""; }; 636316D21A1DEBCB0009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/AboutViewController.xib; sourceTree = ""; }; 636316D51A1DEC650009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SettingsViewController.xib; sourceTree = ""; }; 636316D81A1DECC90009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/PhoneMainView.xib; sourceTree = ""; }; @@ -1448,9 +1443,6 @@ 340751E6150F38FD00B89C47 /* UIVideoButton.m */, 634610041B61330300548952 /* UILabel+Boldify.h */, 634610051B61330300548952 /* UILabel+Boldify.m */, - 6357752C1B6676C200C8B704 /* UIHistoryDetailsCell.h */, - 6357752D1B6676C200C8B704 /* UIHistoryDetailsCell.m */, - 6357752F1B66777200C8B704 /* UIHistoryDetailsCell.xib */, ); path = LinphoneUI; sourceTree = ""; @@ -2201,7 +2193,6 @@ buildActionMask = 2147483647; files = ( 634CEE161B6630DB00D7A921 /* valid.png in Resources */, - 635775311B66777200C8B704 /* UIHistoryDetailsCell.xib in Resources */, 634CEDC71B6630DB00D7A921 /* delete.png in Resources */, 636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */, 634CEDF31B6630DB00D7A921 /* options_start_conference.png in Resources */, @@ -2569,7 +2560,6 @@ D3ED40191602172200BF332B /* HPGrowingTextView.m in Sources */, D3ED401B1602172200BF332B /* HPTextViewInternal.m in Sources */, D37EE162160377D7003608A6 /* DTActionSheet.m in Sources */, - 6357752E1B6676C200C8B704 /* UIHistoryDetailsCell.m in Sources */, D35E91F4160CA10B0023116B /* UILinphoneTextField.m in Sources */, D35E91F8160CA4FF0023116B /* UILinphoneButton.m in Sources */, D306459E1611EC2A00BB571E /* UILoadingImageView.m in Sources */, @@ -2701,14 +2691,6 @@ name = OutgoingCallViewController.xib; sourceTree = ""; }; - 6357752F1B66777200C8B704 /* UIHistoryDetailsCell.xib */ = { - isa = PBXVariantGroup; - children = ( - 635775301B66777200C8B704 /* Base */, - ); - name = UIHistoryDetailsCell.xib; - sourceTree = ""; - }; 636316D31A1DEBCB0009B839 /* AboutViewController.xib */ = { isa = PBXVariantGroup; children = (