// // CCSplit.m // Crypto Cloud Technology Nextcloud // // Created by Marino Faggiana on 09/10/15. // Copyright (c) 2014 TWS. All rights reserved. // // Author Marino Faggiana // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // #import "CCSplit.h" #import "AppDelegate.h" @interface CCSplit () { } @end @implementation CCSplit #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Init ===== #pragma -------------------------------------------------------------------------------------------- - (id)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.delegate = self; [self inizialize]; } // E' apparsa - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self newAccount]; // Jailbroken if (app.isDeviceJailbroken && [CCUtility getMessageJailbroken] == NO) { [CCUtility setMessageJailbroken:YES]; UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Device Jailbroken" message:[CCUtility localizableBrand:@"_Device_Jailbroken_" table:nil] delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil]; [alertView show]; } } - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [coordinator animateAlongsideTransition:nil completion:^(id context) { if (self.view.frame.size.width == ([[UIScreen mainScreen] bounds].size.width*([[UIScreen mainScreen] bounds].size.width<[[UIScreen mainScreen] bounds].size.height))+([[UIScreen mainScreen] bounds].size.height*([[UIScreen mainScreen] bounds].size.width>[[UIScreen mainScreen] bounds].size.height))) { // Portrait } else { // Landscape } }]; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; } #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== inizialization ===== #pragma -------------------------------------------------------------------------------------------- - (void)inizialize { // setting version self.version = [CCUtility setVersionCryptoCloud]; // view how to if exists [self showIntro]; // init home [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil]; } #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Intro ===== #pragma -------------------------------------------------------------------------------------------- - (void)showIntro { BOOL isIntro = [CCUtility getIntro:self.version]; if ([app.activeAccount length] > 0 && isIntro == NO) { //[self bannerHide]; self.intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view]; //[self.intro showIntroVersion:self.version duration:1.0 review:NO]; } } - (void)introDidFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped { NSString *version = [CCUtility getVersionCryptoCloud]; [CCUtility setIntro:version]; } #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== newAccount ===== #pragma -------------------------------------------------------------------------------------------- - (void)newAccount { // REMOVECODE //if ([app.activeAccount length] == 0 || [[CCUtility getKeyChainPasscodeForUUID:[CCUtility getUUID]] length] == 0) { if ([app.activeAccount length] == 0) { CCLogin *viewController = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"CCLogin"]; [self presentViewController:viewController animated:YES completion:nil]; } } #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Split View Controller ===== #pragma -------------------------------------------------------------------------------------------- - (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController { return YES; } - (UIViewController *)splitViewController:(UISplitViewController *)splitViewController separateSecondaryViewControllerFromPrimaryViewController:(UIViewController *)primaryViewController { if ([primaryViewController isKindOfClass:[UINavigationController class]]) { for (UIViewController *controller in [(UINavigationController *)primaryViewController viewControllers]) { if ([controller isKindOfClass:[UINavigationController class]] && [[(UINavigationController *)controller visibleViewController] isKindOfClass:[CCDetail class]]) { return controller; } } } // No detail view present UINavigationController *secondaryViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CCDetailNC"]; // Ensure back button is enabled UIViewController *detailViewController = [secondaryViewController visibleViewController]; detailViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem; detailViewController.navigationItem.leftItemsSupplementBackButton = YES; return secondaryViewController; } - (UIViewController *)primaryViewControllerForExpandingSplitViewController:(UISplitViewController *)splitViewController { UITabBarController *tbMaster = splitViewController.viewControllers[0]; UINavigationController *ncMaster = [tbMaster selectedViewController]; //UIViewController *main = [ncMaster.viewControllers firstObject]; UIViewController *detail = [ncMaster.viewControllers lastObject]; if ([detail isKindOfClass:[CCDetail class]]) { [ncMaster popViewControllerAnimated:NO]; } return nil; } // sender = CCMain // vc = UINavigationController detail - (void)showDetailViewController:(UIViewController *)vc sender:(id)sender { UINavigationController *ncDetail = (UINavigationController *)vc; if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) { if ([self.viewControllers[0] isKindOfClass:[UITabBarController class]]) { UINavigationController *ncMaster = [self.viewControllers[0] selectedViewController]; [ncMaster pushViewController:ncDetail.topViewController animated:YES]; return; } } [super showDetailViewController:vc sender:sender]; // display icon "\" ncDetail.topViewController.navigationItem.leftBarButtonItem = self.displayModeButtonItem; self.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible; } // OK - (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode { UIViewController *viewController = [svc.viewControllers lastObject]; if ([viewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)viewController; UIViewController *detail = [navigationController.viewControllers firstObject]; if ([detail isKindOfClass:[CCDetail class]]) { [(CCDetail *)detail performSelector:@selector(changeToDisplayMode) withObject:nil afterDelay:0.05]; } } } @end