Skip to content

Commit

Permalink
Merge pull request #6065 from vishalduggal/timob-17648
Browse files Browse the repository at this point in the history
[TIMOB-17648] iOS8: iPad Alert dialog does not consider window orientation modes
  • Loading branch information
jonalter committed Sep 12, 2014
2 parents 57cf553 + 157d145 commit b3d1a5b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions iphone/Classes/TiRootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@

BOOL statusBarIsHidden;
BOOL statusBarVisibilityChanged;
NSInteger activeAlertControllerCount;
}

//Titanium Support
-(CGRect)resizeView;
-(void)repositionSubviews;
-(UIView *)topWindowProxyView;
-(NSUInteger)supportedOrientationsForAppDelegate;
-(void)incrementActiveAlertControllerCount;
-(void)decrementActiveAlertControllerCount;
-(void)updateStatusBar;
@property (nonatomic, readonly) BOOL statusBarInitiallyHidden;
@property (nonatomic, readonly) UIStatusBarStyle defaultStatusBarStyle;
Expand Down
28 changes: 26 additions & 2 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -916,12 +916,17 @@ -(TiOrientationFlags)getDefaultOrientations
return defaultOrientations;
}

-(UIViewController*)topPresentedController
-(UIViewController*)topPresentedControllerCheckingPopover:(BOOL)checkPopover
{
UIViewController* topmostController = self;
UIViewController* presentedViewController = nil;
while ( topmostController != nil ) {
presentedViewController = [topmostController presentedViewController];
if (checkPopover && [TiUtils isIOS8OrGreater]) {
if (presentedViewController.modalPresentationStyle == UIModalPresentationPopover) {
presentedViewController = nil;
}
}
if (presentedViewController != nil) {
topmostController = presentedViewController;
presentedViewController = nil;
Expand All @@ -933,6 +938,11 @@ -(UIViewController*)topPresentedController
return topmostController;
}

-(UIViewController*)topPresentedController
{
return [self topPresentedControllerCheckingPopover:NO];
}

-(UIViewController<TiControllerContainment>*)topContainerController;
{
UIViewController* topmostController = self;
Expand Down Expand Up @@ -1098,11 +1108,25 @@ - (BOOL)shouldAutorotate{
return YES;
}

-(void)incrementActiveAlertControllerCount
{
++activeAlertControllerCount;
}
-(void)decrementActiveAlertControllerCount
{
--activeAlertControllerCount;
}

-(NSUInteger)supportedOrientationsForAppDelegate;
{
if (forcingStatusBarOrientation) {
return 0;
}

if ([TiUtils isIOS8OrGreater] && activeAlertControllerCount > 0) {
return [self supportedInterfaceOrientations];
}

//Since this is used just for intersection, ok to return UIInterfaceOrientationMaskAll
return 30;//UIInterfaceOrientationMaskAll
}
Expand All @@ -1114,7 +1138,7 @@ - (NSUInteger)supportedInterfaceOrientations{
}
//IOS6. If we are presenting a modal view controller, get the supported
//orientations from the modal view controller
UIViewController* topmostController = [self topPresentedController];
UIViewController* topmostController = [self topPresentedControllerCheckingPopover:YES];
if (topmostController != self) {
NSUInteger retVal = [topmostController supportedInterfaceOrientations];
if ([topmostController isBeingDismissed]) {
Expand Down
3 changes: 3 additions & 0 deletions iphone/Classes/TiUIAlertDialogProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#import "TiUIAlertDialogProxy.h"
#import "TiUtils.h"
#import "TiApp.h"

static NSCondition* alertCondition;
static BOOL alertShowing = NO;
Expand Down Expand Up @@ -53,6 +54,7 @@ -(void) cleanup
[self forgetSelf];
[self autorelease];
RELEASE_TO_NIL(alert);
[[[TiApp app] controller] decrementActiveAlertControllerCount];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
}
Expand Down Expand Up @@ -131,6 +133,7 @@ -(void)show:(id)args
[alert setAlertViewStyle:style];

[self retain];
[[[TiApp app] controller] incrementActiveAlertControllerCount];
[alert show];
}
}
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIOptionDialogProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ -(void)show:(id)args
[actionSheet setDestructiveButtonIndex:[TiUtils intValue:[self valueForKey:@"destructive"] def:-1]];

[self retain];
[[[TiApp app] controller] incrementActiveAlertControllerCount];

if ([TiUtils isIPad])
{
Expand Down Expand Up @@ -104,6 +105,7 @@ -(void)completeWithButton:(int)buttonIndex
nil];
[self fireEvent:@"click" withObject:event];
}
[[[TiApp app] controller] decrementActiveAlertControllerCount];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self forgetSelf];
[self release];
Expand Down

0 comments on commit b3d1a5b

Please sign in to comment.