diff --git a/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.h b/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.h index bf7bf62156..d15ad79f86 100755 --- a/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.h +++ b/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.h @@ -59,7 +59,7 @@ typedef enum _MGSplitViewDividerStyle { - (IBAction)toggleMasterView:(id)sender; // toggles display of the master view in the current orientation. - (IBAction)showMasterPopover:(id)sender; // shows the master view in a popover spawned from the provided barButtonItem, if it's currently hidden. - (void)notePopoverDismissed; // should rarely be needed, because you should not change the popover's delegate. If you must, then call this when it's dismissed. - +- (void) removeThePopover; // Conveniences for you, because I care. - (BOOL)isShowingMaster; - (void)setSplitPosition:(float)posn animated:(BOOL)animate; // Allows for animation of splitPosition changes. The property's regular setter is not animated. diff --git a/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.m b/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.m index 42df8ca92e..b4a111b9e3 100755 --- a/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.m +++ b/Owncloud iOs Client/ExternalLibreries/MGSplitViewController/MGSplitViewController.m @@ -77,7 +77,7 @@ - (NSString *)nameOfInterfaceOrientation:(UIInterfaceOrientation)theOrientation - (BOOL)isLandscape { - return UIInterfaceOrientationIsLandscape(self.interfaceOrientation); + return UIInterfaceOrientationIsLandscape([self getTheInterfaceOrientation]); } @@ -90,13 +90,26 @@ - (BOOL)shouldShowMasterForInterfaceOrientation:(UIInterfaceOrientation)theOrien - (BOOL)shouldShowMaster { - return [self shouldShowMasterForInterfaceOrientation:self.interfaceOrientation]; + return [self shouldShowMasterForInterfaceOrientation:[self getTheInterfaceOrientation]]; } - (BOOL)isShowingMaster { - return [self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view); + BOOL showingMaster = NO; + + if ([self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view)) { + showingMaster = YES; + } + + return showingMaster; + +} + +- (UIInterfaceOrientation)getTheInterfaceOrientation{ + + return [[UIApplication sharedApplication] statusBarOrientation]; + } @@ -176,12 +189,6 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface //Only for ios 6 - (BOOL)shouldAutorotate { - UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; - - if (orientation==UIInterfaceOrientationPortrait) { - - } - return YES; } @@ -194,8 +201,10 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + [self.masterViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; [self.detailViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + } @@ -212,7 +221,8 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInte // Re-tile views. _reconfigurePopup = YES; - [self layoutSubviewsForInterfaceOrientation:toInterfaceOrientation withAnimation:YES]; + [self layoutSubviews]; + AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate]; [app.detailViewController adjustGalleryScrollView]; @@ -241,9 +251,40 @@ - (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrie } +#pragma mark - iOS 8 rotation method. + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + + NSTimeInterval duration = 0.0; + + // willRotateToInterfaceOrientation code goes here + [self willRotateToInterfaceOrientation:[self getTheInterfaceOrientation] duration:duration]; + + if(![self isShowingMaster] && ![self isLandscape]){ + _reconfigurePopup = YES; + [self reconfigureForMasterInPopover:NO]; + [self layoutSubviews]; + } + + + [coordinator animateAlongsideTransition:^(id context) { + // willAnimateRotationToInterfaceOrientation code goes here + [self willAnimateRotationToInterfaceOrientation:[self getTheInterfaceOrientation] duration:duration]; + + } completion:^(id context) { + // didRotateFromInterfaceOrientation goes here (nothing for now) + [self didRotateFromInterfaceOrientation:[self getTheInterfaceOrientation]]; + }]; + + + [super viewWillTransitionToSize: size withTransitionCoordinator: coordinator]; +} + + - (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation { - UIScreen *screen = [UIScreen mainScreen]; + UIScreen *screen = [UIScreen mainScreen]; + CGRect fullScreenRect = screen.bounds; // always implicitly in Portrait orientation. CGRect appFrame = screen.applicationFrame; @@ -256,7 +297,7 @@ - (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation float height = fullScreenRect.size.height; // Correct for orientation. - if (UIInterfaceOrientationIsLandscape(theOrientation)) { + if (UIInterfaceOrientationIsLandscape(theOrientation) && !IS_IOS8) { width = height; height = fullScreenRect.size.width; } @@ -278,7 +319,7 @@ - (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrienta if (_reconfigurePopup) { [self reconfigureForMasterInPopover:![self shouldShowMasterForInterfaceOrientation:theOrientation]]; } - + // Layout the master, detail and divider views appropriately, adding/removing subviews as needed. // First obtain relevant geometry. CGSize fullSize = [self splitViewSizeForOrientation:theOrientation]; @@ -521,13 +562,13 @@ - (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrienta - (void)layoutSubviewsWithAnimation:(BOOL)animate { - [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:animate]; + [self layoutSubviewsForInterfaceOrientation:[self getTheInterfaceOrientation] withAnimation:animate]; } - (void)layoutSubviews { - [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:YES]; + [self layoutSubviewsForInterfaceOrientation:[self getTheInterfaceOrientation] withAnimation:YES]; } @@ -622,7 +663,11 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover } //Define the size of the popOver - _hiddenPopoverController.popoverContentSize=CGSizeMake(320, [[UIScreen mainScreen] bounds].size.height); + + + UIScreen *screen = [UIScreen mainScreen]; + + _hiddenPopoverController.popoverContentSize=CGSizeMake(320, screen.bounds.size.height); // Inform delegate of this state of affairs. if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willHideViewController:withBarButtonItem:forPopoverController:)]) { @@ -633,8 +678,12 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover } } else if (!inPopover && _hiddenPopoverController && _barButtonItem) { - // I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray. - [_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + + if (!IS_IOS8) { + // I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray. + [_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + } + // Remove master from popover and destroy popover, if it exists. [_hiddenPopoverController dismissPopoverAnimated:NO]; @@ -653,10 +702,11 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover _barButtonItem = nil; // Move master view. - UIView *masterView = self.masterViewController.view; - if (masterView && masterView.superview != self.view) { - [masterView removeFromSuperview]; - } + UIView *masterView = self.masterViewController.view; + if (masterView && masterView.superview != self.view) { + [masterView removeFromSuperview]; + } + } } @@ -715,8 +765,7 @@ - (IBAction)toggleSplitOrientation:(id)sender } -- (IBAction)toggleMasterBeforeDetail:(id)sender -{ +- (IBAction)toggleMasterBeforeDetail:(id)sender { BOOL showingMaster = [self isShowingMaster]; if (showingMaster) { if (_cornerViews) { @@ -735,28 +784,32 @@ - (IBAction)toggleMasterBeforeDetail:(id)sender } } +- (void) removeThePopover { + + if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) { + [_hiddenPopoverController dismissPopoverAnimated:NO]; + } +} -- (IBAction)toggleMasterView:(id)sender -{ - if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) { - [_hiddenPopoverController dismissPopoverAnimated:NO]; - } - +- (IBAction)toggleMasterView:(id)sender { if (![self isShowingMaster]) { // We're about to show the master view. Ensure it's in place off-screen to be animated in. _reconfigurePopup = YES; [self reconfigureForMasterInPopover:NO]; [self layoutSubviews]; - } + } // This action functions on the current primary orientation; it is independent of the other primary orientation. [UIView beginAnimations:@"toggleMaster" context:nil]; if (self.isLandscape) { - self.showsMasterInLandscape = !_showsMasterInLandscape; + + self.showsMasterInLandscape = !_showsMasterInLandscape; } else { self.showsMasterInPortrait = !_showsMasterInPortrait; } [UIView commitAnimations]; + + } @@ -908,7 +961,8 @@ - (void)setSplitPosition:(float)posn // Check to see if delegate wishes to constrain the position. float newPosn = posn; BOOL constrained = NO; - CGSize fullSize = [self splitViewSizeForOrientation:self.interfaceOrientation]; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; + CGSize fullSize = [self splitViewSizeForOrientation:orientation]; if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:constrainSplitPosition:splitViewSize:)]) { newPosn = [_delegate splitViewController:self constrainSplitPosition:newPosn splitViewSize:fullSize]; constrained = YES; // implicitly trust delegate's response. diff --git a/Owncloud iOs Client/Files/Preview/DetailView/DetailViewController.m b/Owncloud iOs Client/Files/Preview/DetailView/DetailViewController.m index 4c739a889f..6730d00b3c 100755 --- a/Owncloud iOs Client/Files/Preview/DetailView/DetailViewController.m +++ b/Owncloud iOs Client/Files/Preview/DetailView/DetailViewController.m @@ -700,7 +700,7 @@ - (void) openGalleryFileOnUpdatingProcess: (BOOL) isUpdatingProcess { * We use this feature for example to charge Help page. */ -- (void)finishLinkLoad{ +- (void)finishLinkLoad { [_titleLabel setText:_linkTitle]; } @@ -1901,29 +1901,37 @@ - (IBAction)toggleMasterView:(id)sender { [_galleryView prepareScrollViewBeforeTheRotation]; } - //Tell to splitController to extend the detailview - [splitController toggleMasterView:sender]; + [splitController removeThePopover]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + + //Tell to splitController to extend the detailview + [splitController toggleMasterView:sender]; + + + //Change the global flag + if (_isExtend==NO) { + //Set the constraint + _leftMarginTitleLabelConstraint.constant = 92; + _isExtend = YES; + } else { + //Set the constraint + _leftMarginTitleLabelConstraint.constant = 62; + _isExtend = NO; + } + + //Managed the objects of landscape view. + [self landscapeView]; + + //If galleryView charged indicated adjust the scroll view + if (_galleryView) { + _isExtending = YES; + [self adjustGalleryScrollView]; + } + + + }); - //Change the global flag - if (_isExtend==NO) { - //Set the constraint - _leftMarginTitleLabelConstraint.constant = 92; - _isExtend = YES; - } else { - //Set the constraint - _leftMarginTitleLabelConstraint.constant = 62; - _isExtend = NO; - } - - //Managed the objects of landscape view. - [self landscapeView]; - - //If galleryView charged indicated adjust the scroll view - if (_galleryView) { - _isExtending = YES; - [self adjustGalleryScrollView]; - } } @@ -2008,6 +2016,33 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO [self showPopover]; } + +#pragma mark - iOS 8 rotation method. + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; + + NSTimeInterval duration = 0.5; + + // willRotateToInterfaceOrientation code goes here + [self willRotateToInterfaceOrientation:orientation duration:duration]; + + [coordinator animateAlongsideTransition:^(id context) { + // willAnimateRotationToInterfaceOrientation code goes here + [self willAnimateRotationToInterfaceOrientation:orientation duration:duration]; + + + } completion:^(id context) { + // didRotateFromInterfaceOrientation goes here (nothing for now) + [self didRotateFromInterfaceOrientation:orientation]; + + }]; + + + [super viewWillTransitionToSize: size withTransitionCoordinator: coordinator]; +} + /* * Method that tell to galleryView to adjust the scroll view after the rotation */ diff --git a/Owncloud iOs Client/Utils/SystemConstants.h b/Owncloud iOs Client/Utils/SystemConstants.h index 4b27899ec0..8d7516e13a 100644 --- a/Owncloud iOs Client/Utils/SystemConstants.h +++ b/Owncloud iOs Client/Utils/SystemConstants.h @@ -6,6 +6,7 @@ // // -#define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) +#define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] == 7) +#define IS_IOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #define IS_PORTRAIT (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) \ No newline at end of file