diff --git a/Classes/InCallViewController.m b/Classes/InCallViewController.m index 4a8e3442f..2a3bbe6bd 100644 --- a/Classes/InCallViewController.m +++ b/Classes/InCallViewController.m @@ -127,10 +127,6 @@ static UICompositeViewDescription *compositeDescription = nil; [[NSNotificationCenter defaultCenter] removeObserver:self name:@"LinphoneCallUpdate" object:nil]; - - [[NSNotificationCenter defaultCenter] removeObserver:self - name:UIDeviceOrientationDidChangeNotification - object:nil]; } - (void)viewWillAppear:(BOOL)animated { @@ -145,16 +141,11 @@ static UICompositeViewDescription *compositeDescription = nil; name:@"LinphoneCallUpdate" object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(orientationChanged:) - name:UIDeviceOrientationDidChangeNotification - object:nil]; - // Update on show LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); LinphoneCallState state = (call != NULL)?linphone_call_get_state(call): 0; [self callUpdate:call state:state animated:FALSE]; - [self orientationUpdate]; + [self orientationUpdate:[PhoneMainView instance].interfaceOrientation]; if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { [callTableController viewDidAppear:animated]; @@ -196,7 +187,13 @@ static UICompositeViewDescription *compositeDescription = nil; } +- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; + [self orientationUpdate:toInterfaceOrientation]; +} + - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; CGRect frame = [videoPreview frame]; switch (toInterfaceOrientation) { case UIInterfaceOrientationPortrait: @@ -217,25 +214,25 @@ static UICompositeViewDescription *compositeDescription = nil; [videoPreview setFrame:frame]; } + #pragma mark - -- (void)orientationUpdate { +- (void)orientationUpdate:(UIInterfaceOrientation)orientation { int oldLinphoneOrientation = linphone_core_get_device_rotation([LinphoneManager getLc]); - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; int newRotation = 0; switch (orientation) { - case UIDeviceOrientationPortrait: + case UIInterfaceOrientationPortrait: newRotation = 0; break; - case UIDeviceOrientationPortraitUpsideDown: + case UIInterfaceOrientationPortraitUpsideDown: newRotation = 180; break; - case UIDeviceOrientationLandscapeRight: - newRotation = 90; - break; - case UIDeviceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: newRotation = 270; break; + case UIInterfaceOrientationLandscapeLeft: + newRotation = 90; + break; default: newRotation = oldLinphoneOrientation; } @@ -477,10 +474,6 @@ static void hideSpinner(LinphoneCall* call, void* user_data) { #pragma mark - Event Functions -- (void)orientationChanged:(NSNotification*) notif { - [self orientationUpdate]; -} - - (void)callUpdateEvent: (NSNotification*) notif { LinphoneCall *call = [[notif.userInfo objectForKey: @"call"] pointerValue]; LinphoneCallState state = [[notif.userInfo objectForKey: @"state"] intValue]; diff --git a/Classes/LinphoneUI/UICompositeViewController.h b/Classes/LinphoneUI/UICompositeViewController.h index f4ad7f907..98e59a478 100644 --- a/Classes/LinphoneUI/UICompositeViewController.h +++ b/Classes/LinphoneUI/UICompositeViewController.h @@ -76,7 +76,7 @@ UICompositeViewDescription *currentViewDescription; CATransition *viewTransition; - UIDeviceOrientation currentOrientation; + UIInterfaceOrientation currentOrientation; } @property (retain) CATransition *viewTransition; @@ -90,5 +90,6 @@ - (void)setStateBarHidden:(BOOL) hidden; - (void)setToolBarHidden:(BOOL) hidden; - (UIViewController *)getCurrentViewController; +- (UIInterfaceOrientation)currentOrientation; @end diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index 2068160e1..57ef2eef2 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -93,7 +93,7 @@ - (void)initUICompositeViewController { self->viewControllerCache = [[NSMutableDictionary alloc] init]; - self->currentOrientation = UIDeviceOrientationUnknown; + currentOrientation = UIDeviceOrientationUnknown; } - (id)init{ @@ -219,6 +219,10 @@ #pragma mark - +- (UIInterfaceOrientation)currentOrientation { + return currentOrientation; +} + + (void)addSubView:(UIViewController*)controller view:(UIView*)view { if(controller != nil) { if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { @@ -379,9 +383,10 @@ UIInterfaceOrientation correctOrientation = [self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]]; if(currentOrientation != correctOrientation) { [PhoneMainView forceOrientation:correctOrientation animated:currentOrientation!=UIDeviceOrientationUnknown]; + currentOrientation = correctOrientation; + } else { + [self updateInterfaceOrientation:correctOrientation]; } - currentOrientation = correctOrientation; - [self updateInterfaceOrientation:correctOrientation]; } else { oldViewDescription = (currentViewDescription != nil)? [currentViewDescription copy]: nil; } diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 3b49f4320..cc510e626 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -235,6 +235,10 @@ static PhoneMainView* phoneMainViewInstance=nil; [mainViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; } +- (UIInterfaceOrientation)interfaceOrientation { + return [mainViewController currentOrientation]; +} + #pragma mark - Event Functions diff --git a/submodules/linphone b/submodules/linphone index 54ec1064f..e93d9096f 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 54ec1064fdff1c56c796f0e25437c414e328e105 +Subproject commit e93d9096ff433d3195c177e4c767881406e71d88