From 1139019cf8d83caf663c6651f641ec2962c824ec Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 2 Oct 2012 11:31:43 +0200 Subject: [PATCH] Fix Call cell pause button state Fix CompositeView rotation --- Classes/InCallTableViewController.m | 8 +- Classes/LinphoneUI/UICallCell.h | 3 + Classes/LinphoneUI/UICallCell.m | 108 ++++++++++-------- .../LinphoneUI/UICompositeViewController.m | 51 +++------ 4 files changed, 85 insertions(+), 85 deletions(-) diff --git a/Classes/InCallTableViewController.m b/Classes/InCallTableViewController.m index 831f59842..cf13e8be2 100644 --- a/Classes/InCallTableViewController.m +++ b/Classes/InCallTableViewController.m @@ -182,7 +182,9 @@ enum TableSection { const MSList *list = linphone_core_get_calls([LinphoneManager getLc]); while(list != NULL) { UICallCellData *data = [self getCallData:(LinphoneCall*)list->data]; - data->minimize = true; + if(data) { + data->minimize = true; + } list = list->next; } [[self tableView] reloadData]; @@ -192,7 +194,9 @@ enum TableSection { const MSList *list = linphone_core_get_calls([LinphoneManager getLc]); while(list != NULL) { UICallCellData *data = [self getCallData:(LinphoneCall*)list->data]; - data->minimize = false; + if(data) { + data->minimize = false; + } list = list->next; } [[self tableView] reloadData]; diff --git a/Classes/LinphoneUI/UICallCell.h b/Classes/LinphoneUI/UICallCell.h index 5fefb7bc5..8621ba4bc 100644 --- a/Classes/LinphoneUI/UICallCell.h +++ b/Classes/LinphoneUI/UICallCell.h @@ -38,6 +38,9 @@ typedef enum _UICallCellOtherView { - (id)init:(LinphoneCall*) call; +@property (nonatomic, retain) UIImage *image; +@property (nonatomic, retain) NSString *address; + @end @interface UICallCell : UITableViewCell { diff --git a/Classes/LinphoneUI/UICallCell.m b/Classes/LinphoneUI/UICallCell.m index 6d6e53d7b..d84003213 100644 --- a/Classes/LinphoneUI/UICallCell.m +++ b/Classes/LinphoneUI/UICallCell.m @@ -20,21 +20,73 @@ #import #import "UICallCell.h" - +#import "UILinphone.h" #import "LinphoneManager.h" #import "FastAddressBook.h" @implementation UICallCellData +@synthesize address; +@synthesize image; + - (id)init:(LinphoneCall*) acall { self = [super init]; if(self != nil) { self->minimize = false; self->view = UICallCellOtherView_Avatar; self->call = acall; + image = [[UIImage imageNamed:@"avatar_unknown.png"] retain]; + address = [@"Unknown" retain]; + [self update]; } return self; } + +- (void)update { + if(call == NULL) { + [LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update call cell: null call or data"]; + return; + } + const LinphoneAddress* addr = linphone_call_get_remote_address(call); + + 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]]; + ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; + if(contact) { + useLinphoneAddress = false; + self.address = [FastAddressBook getContactDisplayName:contact]; + UIImage *tmpImage = [FastAddressBook getContactImage:contact thumbnail:false]; + if(tmpImage != nil) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, (unsigned long)NULL), ^(void) { + [tmpImage forceDecompression]; + self.image = tmpImage; + }); + } + } + ms_free(lAddress); + } + if(useLinphoneAddress) { + const char* lDisplayName = linphone_address_get_display_name(addr); + const char* lUserName = linphone_address_get_username(addr); + if (lDisplayName) + self.address = [NSString stringWithUTF8String:lDisplayName]; + else if(lUserName) + self.address = [NSString stringWithUTF8String:lUserName]; + } + } +} + +- (void)dealloc { + [address release]; + [image release]; + + [super dealloc]; +} + @end @implementation UICallCell @@ -201,7 +253,6 @@ } if(adata != nil) { data = [adata retain]; - [self updateContact]; } } @@ -309,53 +360,6 @@ #pragma mark - -- (void)updateContact { - if(data == nil || data->call == NULL) { - [LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update call cell: null call or data"]; - return; - } - LinphoneCall *call = data->call; - const LinphoneAddress* addr = linphone_call_get_remote_address(call); - - 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]]; - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if(contact) { - image = [FastAddressBook getContactImage:contact thumbnail:false]; - 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]; - } - } - - // Set Image - if(image == nil) { - image = [UIImage imageNamed:@"avatar_unknown.png"]; - } - [avatarImage setImage:image]; - - // Set Address - if(address == nil) { - address = @"Unknown"; - } - [addressLabel setText:address]; -} - - (void)update { if(data == nil || data->call == NULL) { [LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update call cell: null call or data"]; @@ -363,6 +367,11 @@ } LinphoneCall *call = data->call; + [pauseButton setType:UIPauseButtonType_Call call:call]; + + [addressLabel setText:data.address]; + [avatarImage setImage:data.image]; + LinphoneCallState state = linphone_call_get_state(call); if(!conferenceCell) { if(state == LinphoneCallOutgoingRinging) { @@ -407,7 +416,6 @@ [self setFrame:frame]; [otherView setHidden:true]; } - [pauseButton setType:UIPauseButtonType_Call call:call]; [self updateStats]; diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index c9f1877fe..a415343f0 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -384,38 +384,6 @@ return UIInterfaceOrientationPortrait; } -- (void)updateInterfaceOrientation:(UIInterfaceOrientation)correctOrientation { - UIInterfaceOrientation orientation; - - orientation = self.interfaceOrientation; - if(orientation != correctOrientation) { - [super willRotateToInterfaceOrientation:correctOrientation duration:0]; - [super willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; - [super didRotateFromInterfaceOrientation:orientation]; - } - - orientation = self.contentViewController.interfaceOrientation; - if(orientation != correctOrientation) { - [self.contentViewController willRotateToInterfaceOrientation:correctOrientation duration:0]; - [self.contentViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; - [self.contentViewController didRotateFromInterfaceOrientation:orientation]; - } - - orientation = self.tabBarViewController.interfaceOrientation; - if(orientation != correctOrientation) { - [self.tabBarViewController willRotateToInterfaceOrientation:correctOrientation duration:0]; - [self.tabBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; - [self.tabBarViewController didRotateFromInterfaceOrientation:orientation]; - } - - orientation = self.stateBarViewController.interfaceOrientation; - if(orientation != correctOrientation) { - [self.stateBarViewController willRotateToInterfaceOrientation:correctOrientation duration:0]; - [self.stateBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; - [self.stateBarViewController didRotateFromInterfaceOrientation:orientation]; - } -} - #define IPHONE_STATUSBAR_HEIGHT 20 - (void)update: (UICompositeViewDescription*) description tabBar:(NSNumber*)tabBar stateBar:(NSNumber*)stateBar fullscreen:(NSNumber*)fullscreen { @@ -469,7 +437,24 @@ if(currentOrientation != correctOrientation) { [PhoneMainView setOrientation:correctOrientation animated:currentOrientation!=UIDeviceOrientationUnknown]; } else { - [self updateInterfaceOrientation:correctOrientation]; + if(oldContentViewController != newContentViewController) { + UIInterfaceOrientation oldOrientation = self.contentViewController.interfaceOrientation; + [self.contentViewController willRotateToInterfaceOrientation:correctOrientation duration:0]; + [self.contentViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; + [self.contentViewController didRotateFromInterfaceOrientation:oldOrientation]; + } + if(oldTabBarViewController != newTabBarViewController) { + UIInterfaceOrientation oldOrientation = self.tabBarViewController.interfaceOrientation; + [self.tabBarViewController willRotateToInterfaceOrientation:correctOrientation duration:0]; + [self.tabBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; + [self.tabBarViewController didRotateFromInterfaceOrientation:oldOrientation]; + } + if(oldStateBarViewController != newStateBarViewController) { + UIInterfaceOrientation oldOrientation = self.stateBarViewController.interfaceOrientation; + [self.stateBarViewController willRotateToInterfaceOrientation:correctOrientation duration:0]; + [self.stateBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0]; + [self.stateBarViewController didRotateFromInterfaceOrientation:oldOrientation]; + } } } else { oldViewDescription = (currentViewDescription != nil)? [currentViewDescription copy]: nil;