From 7272ccf0d21ba3592b293fcb30523cb4842730a3 Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Thu, 5 Oct 2023 14:44:52 -0500 Subject: [PATCH] #1247 (Mac Catalyst edition) --- clients/ios/Classes/ActivityModule.m | 8 +- clients/ios/Classes/AddSiteViewController.m | 6 +- .../Classes/AuthorizeServicesViewController.m | 5 +- clients/ios/Classes/BaseViewController.h | 9 ++- clients/ios/Classes/BaseViewController.m | 30 +++++++ .../ios/Classes/DetailViewController.swift | 18 ++--- clients/ios/Classes/FeedChooserTitleView.m | 2 +- clients/ios/Classes/FeedDetailGridView.swift | 2 + .../Classes/FeedDetailObjCViewController.h | 2 + .../Classes/FeedDetailObjCViewController.m | 16 +++- clients/ios/Classes/FeedTableCell.m | 13 ++- clients/ios/Classes/FeedsObjCViewController.h | 2 + clients/ios/Classes/FeedsObjCViewController.m | 66 +++++++++++++--- .../FirstTimeUserAddFriendsViewController.m | 2 +- .../FirstTimeUserAddNewsBlurViewController.m | 2 +- .../FirstTimeUserAddSitesViewController.m | 2 +- .../ios/Classes/FirstTimeUserViewController.m | 2 +- clients/ios/Classes/FolderTitleView.m | 18 ++--- .../ios/Classes/FriendsListViewController.m | 6 +- clients/ios/Classes/InteractionsModule.m | 8 +- clients/ios/Classes/LoginViewController.m | 12 +-- clients/ios/Classes/MoveSiteViewController.m | 2 +- clients/ios/Classes/NewsBlurAppDelegate.h | 2 - clients/ios/Classes/NewsBlurAppDelegate.m | 79 +++++++++---------- .../ios/Classes/NotificationsViewController.m | 2 +- .../ios/Classes/OriginalStoryViewController.m | 10 +-- clients/ios/Classes/ShareViewController.m | 2 +- clients/ios/Classes/SmallActivityCell.m | 3 +- clients/ios/Classes/SmallInteractionCell.m | 5 +- clients/ios/Classes/Story.swift | 4 +- .../Classes/StoryDetailObjCViewController.m | 20 +++-- .../Classes/StoryPagesObjCViewController.m | 8 +- clients/ios/Classes/TrainerViewController.m | 2 +- clients/ios/Classes/UnreadCountView.m | 4 +- .../ios/NewsBlur.xcodeproj/project.pbxproj | 6 +- .../AFNetworking/AFURLRequestSerialization.m | 4 +- .../AFNetworking/AFURLSessionManager.m | 6 +- .../UIRefreshControl+AFNetworking.h | 2 +- .../UIRefreshControl+AFNetworking.m | 2 +- .../IASKAppSettingsViewController.m | 2 +- .../Models/IASKSettingsReader.m | 2 +- .../OnePasswordExtension.m | 2 +- .../ios/Resources/MainInterface.storyboard | 28 ++++--- 43 files changed, 270 insertions(+), 158 deletions(-) diff --git a/clients/ios/Classes/ActivityModule.m b/clients/ios/Classes/ActivityModule.m index 59637f53f9..5656e03de0 100644 --- a/clients/ios/Classes/ActivityModule.m +++ b/clients/ios/Classes/ActivityModule.m @@ -154,7 +154,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger activitiesCount = [appDelegate.userActivitiesArray count]; int minimumHeight; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { minimumHeight = MINIMUM_ACTIVITY_HEIGHT_IPAD; } else { minimumHeight = MINIMUM_ACTIVITY_HEIGHT_IPHONE; @@ -165,7 +165,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa } id activityCell; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { activityCell = [[ActivityCell alloc] init]; } else { activityCell = [[SmallActivityCell alloc] init]; @@ -185,7 +185,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N ActivityCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ActivityCell"]; if (cell == nil) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { cell = [[ActivityCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ActivityCell"]; @@ -304,7 +304,7 @@ - (UITableViewCell *)makeLoadingCell { UIImage *img = [UIImage imageNamed:@"fleuron.png"]; UIImageView *fleuron = [[UIImageView alloc] initWithImage:img]; int height; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { height = MINIMUM_ACTIVITY_HEIGHT_IPAD; } else { height = MINIMUM_ACTIVITY_HEIGHT_IPHONE; diff --git a/clients/ios/Classes/AddSiteViewController.m b/clients/ios/Classes/AddSiteViewController.m index b8517af6e8..deb96de737 100644 --- a/clients/ios/Classes/AddSiteViewController.m +++ b/clients/ios/Classes/AddSiteViewController.m @@ -93,7 +93,7 @@ - (void)viewWillAppear:(BOOL)animated { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { // return YES; @@ -130,7 +130,7 @@ - (CGSize)preferredContentSize { } - (IBAction)doCancelButton { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [appDelegate hidePopover]; } else { [appDelegate hidePopoverAnimated:YES]; @@ -272,7 +272,7 @@ - (IBAction)addSite { [self.errorLabel setText:[responseObject valueForKey:@"message"]]; [self.errorLabel setHidden:NO]; } else { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self->appDelegate hidePopover]; } else { [self->appDelegate hidePopoverAnimated:YES]; diff --git a/clients/ios/Classes/AuthorizeServicesViewController.m b/clients/ios/Classes/AuthorizeServicesViewController.m index 2d3e2b9db4..70d0f418ef 100644 --- a/clients/ios/Classes/AuthorizeServicesViewController.m +++ b/clients/ios/Classes/AuthorizeServicesViewController.m @@ -53,7 +53,7 @@ - (void)viewWillAppear:(BOOL)animated { [self.webView loadRequest:requestObj]; }]; - if (self.fromStory && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (self.fromStory && !appDelegate.isPhone) { UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle: @"Cancel" style: UIBarButtonItemStylePlain @@ -75,6 +75,7 @@ - (void)doCancelButton { } - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + BOOL isPhone = appDelegate.isPhone; NSURLRequest *request = navigationAction.request; NSString *URLString = [[request URL] absoluteString]; NSLog(@"URL STRING IS %@", URLString); @@ -86,7 +87,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati if (self.fromStory) { [self.appDelegate refreshUserProfile:^{ - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!isPhone) { [self.appDelegate.shareNavigationController viewWillAppear:YES]; [self.appDelegate.modalNavigationController dismissViewControllerAnimated:YES completion:nil]; } else { diff --git a/clients/ios/Classes/BaseViewController.h b/clients/ios/Classes/BaseViewController.h index 7666afb74a..960576a102 100644 --- a/clients/ios/Classes/BaseViewController.h +++ b/clients/ios/Classes/BaseViewController.h @@ -1,8 +1,13 @@ #import #import "MBProgressHUD.h" -@interface BaseViewController : UIViewController { -} +@interface BaseViewController : UIViewController + +@property (nonatomic, readonly) BOOL isPhone; +@property (nonatomic, readonly) BOOL isMac; +@property (nonatomic, readonly) BOOL isVision; +@property (nonatomic, readonly) BOOL isPortrait; +@property (nonatomic, readonly) BOOL isCompactWidth; - (void)informError:(id)error; - (void)informError:(id)error statusCode:(NSInteger)statusCode; diff --git a/clients/ios/Classes/BaseViewController.m b/clients/ios/Classes/BaseViewController.m index f026a48210..999aba944a 100644 --- a/clients/ios/Classes/BaseViewController.m +++ b/clients/ios/Classes/BaseViewController.m @@ -177,4 +177,34 @@ - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } +- (BOOL)isPhone { + return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone; +} + +- (BOOL)isMac { + return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomMac; +} + +- (BOOL)isVision { + if (@available(iOS 17.0, *)) { + return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomVision; + } else { + return NO; + } +} + +- (BOOL)isPortrait { + UIInterfaceOrientation orientation = self.view.window.windowScene.interfaceOrientation; + if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { + return YES; + } else { + return NO; + } +} + +- (BOOL)isCompactWidth { + return self.view.window.windowScene.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact; + //return self.compactWidth > 0.0; +} + @end diff --git a/clients/ios/Classes/DetailViewController.swift b/clients/ios/Classes/DetailViewController.swift index 8a92af4a5a..78c20f6ede 100644 --- a/clients/ios/Classes/DetailViewController.swift +++ b/clients/ios/Classes/DetailViewController.swift @@ -185,20 +185,10 @@ class DetailViewController: BaseViewController { } } - /// Returns `true` if the device is an iPhone, otherwise `false`. - @objc var isPhone: Bool { - return UIDevice.current.userInterfaceIdiom == .phone - } - - /// Returns `true` if the window is in portrait orientation, otherwise `false`. - @objc var isPortraitOrientation: Bool { - return view.window?.windowScene?.interfaceOrientation.isPortrait ?? false - } - /// Position of the divider between the views. var dividerPosition: CGFloat { get { - let key = isPortraitOrientation ? Key.verticalPosition : Key.horizontalPosition + let key = isPortrait ? Key.verticalPosition : Key.horizontalPosition let value = CGFloat(UserDefaults.standard.float(forKey: key)) if value == 0 { @@ -212,7 +202,7 @@ class DetailViewController: BaseViewController { return } - let key = isPortraitOrientation ? Key.verticalPosition : Key.horizontalPosition + let key = isPortrait ? Key.verticalPosition : Key.horizontalPosition UserDefaults.standard.set(Float(newValue), forKey: key) } @@ -453,6 +443,10 @@ private extension DetailViewController { func checkViewControllers() { let isTop = layout == .top +#if targetEnvironment(macCatalyst) +// splitViewController?.primaryBackgroundStyle = .sidebar //TODO: work in progress +#endif + if layout != .grid || isPhone { storyPagesViewController = listStoryPagesViewController _ = storyPagesViewController?.view diff --git a/clients/ios/Classes/FeedChooserTitleView.m b/clients/ios/Classes/FeedChooserTitleView.m index 106548bbb8..8f090aab5a 100644 --- a/clients/ios/Classes/FeedChooserTitleView.m +++ b/clients/ios/Classes/FeedChooserTitleView.m @@ -79,7 +79,7 @@ - (void)drawRect:(CGRect)rect { UIImage *folderImage = [UIImage imageNamed:@"folder-open"]; CGFloat folderImageViewX = 10.0; - if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) { + if (((NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate]).isPhone) { folderImageViewX = 7.0; } diff --git a/clients/ios/Classes/FeedDetailGridView.swift b/clients/ios/Classes/FeedDetailGridView.swift index 8b802e1cae..a7020b6a6e 100644 --- a/clients/ios/Classes/FeedDetailGridView.swift +++ b/clients/ios/Classes/FeedDetailGridView.swift @@ -136,6 +136,7 @@ struct FeedDetailGridView: View { } } .modify({ view in +#if !targetEnvironment(macCatalyst) if #available(iOS 15.0, *) { view.refreshable { if cache.canPullToRefresh { @@ -143,6 +144,7 @@ struct FeedDetailGridView: View { } } } +#endif }) } .background(Color.themed([0xE0E0E0, 0xFFF8CA, 0x363636, 0x101010])) diff --git a/clients/ios/Classes/FeedDetailObjCViewController.h b/clients/ios/Classes/FeedDetailObjCViewController.h index 8434d29949..05751935ff 100644 --- a/clients/ios/Classes/FeedDetailObjCViewController.h +++ b/clients/ios/Classes/FeedDetailObjCViewController.h @@ -50,7 +50,9 @@ @property (nonatomic) IBOutlet UIBarButtonItem * titleImageBarButton; @property (nonatomic, retain) NBNotifier *notifier; @property (nonatomic, retain) StoriesCollection *storiesCollection; +#if !TARGET_OS_MACCATALYST @property (nonatomic) UIRefreshControl *refreshControl; +#endif @property (nonatomic) UISearchBar *searchBar; @property (nonatomic) IBOutlet UIView *messageView; @property (nonatomic) IBOutlet UILabel *messageLabel; diff --git a/clients/ios/Classes/FeedDetailObjCViewController.m b/clients/ios/Classes/FeedDetailObjCViewController.m index 49dc5dc9fe..76f278fabd 100644 --- a/clients/ios/Classes/FeedDetailObjCViewController.m +++ b/clients/ios/Classes/FeedDetailObjCViewController.m @@ -106,7 +106,7 @@ - (void)viewDidLoad { if (@available(iOS 15.0, *)) { self.storyTitlesTable.allowsFocus = NO; } - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { self.storyTitlesTable.dragDelegate = self; self.storyTitlesTable.dragInteractionEnabled = YES; } @@ -119,10 +119,12 @@ - (void)viewDidLoad { initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; spacer2BarButton.width = 0; +#if !TARGET_OS_MACCATALYST self.refreshControl = [UIRefreshControl new]; self.refreshControl.tintColor = UIColorFromLightDarkRGB(0x0, 0xffffff); self.refreshControl.backgroundColor = UIColorFromRGB(0xE3E6E0); [self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; +#endif self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.storyTitlesTable.frame), 44.)]; @@ -434,7 +436,7 @@ - (void)viewWillAppear:(BOOL)animated { if (storiesCollection == nil) { NSString *appOpening = [userPreferences stringForKey:@"app_opening"]; - if ([appOpening isEqualToString:@"feeds"] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if ([appOpening isEqualToString:@"feeds"] && !self.isPhone) { self.messageLabel.text = @"Select a feed to read"; self.messageView.hidden = NO; } @@ -510,11 +512,13 @@ - (void)viewWillAppear:(BOOL)animated { [self.searchBar setShowsCancelButton:NO animated:YES]; } +#if !TARGET_OS_MACCATALYST if (self.canPullToRefresh) { self.storyTitlesTable.refreshControl = self.refreshControl; } else { self.storyTitlesTable.refreshControl = nil; } +#endif [self updateTheme]; @@ -1440,7 +1444,7 @@ - (void)testForTryFeed { NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; NSString *feedOpening = [preferences stringForKey:@"feed_opening"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && feedOpening == nil) { + if (!self.isPhone && feedOpening == nil) { feedOpening = @"story"; } @@ -3068,8 +3072,10 @@ - (void)updateTheme { self.navigationItem.titleView = [appDelegate makeFeedTitle:storiesCollection.activeFeed]; } +#if !TARGET_OS_MACCATALYST self.refreshControl.tintColor = UIColorFromLightDarkRGB(0x0, 0xffffff); self.refreshControl.backgroundColor = UIColorFromRGB(0xE3E6E0); +#endif self.searchBar.backgroundColor = UIColorFromRGB(0xE3E6E0); self.searchBar.tintColor = UIColorFromRGB(0xffffff); @@ -3165,6 +3171,7 @@ - (BOOL)canPullToRefresh { return appDelegate.storiesCollection.activeFeed != nil && !river && !infrequent && !saved && !read && !widget; } +#if !TARGET_OS_MACCATALYST - (void)refresh:(UIRefreshControl *)refreshControl { if (self.canPullToRefresh) { self.inPullToRefresh_ = YES; @@ -3173,10 +3180,13 @@ - (void)refresh:(UIRefreshControl *)refreshControl { [self finishRefresh]; } } +#endif - (void)finishRefresh { self.inPullToRefresh_ = NO; +#if !TARGET_OS_MACCATALYST [self.refreshControl endRefreshing]; +#endif } #pragma mark - diff --git a/clients/ios/Classes/FeedTableCell.m b/clients/ios/Classes/FeedTableCell.m index 88c0ab7a63..526af3f3ed 100644 --- a/clients/ios/Classes/FeedTableCell.m +++ b/clients/ios/Classes/FeedTableCell.m @@ -174,11 +174,18 @@ - (void)drawRect:(CGRect)r { BOOL isHighlighted = cell.highlighted || cell.selected; UIColor *backgroundColor; +#if TARGET_OS_MACCATALYST + backgroundColor = cell.isSocial ? UIColorFromRGB(0xD8E3DB) : + cell.isSearch ? UIColorFromRGB(0xDBDFE6) : + cell.isSaved ? UIColorFromRGB(0xDFDCD6) : + UIColor.clearColor; +#else backgroundColor = cell.isSocial ? UIColorFromRGB(0xD8E3DB) : cell.isSearch ? UIColorFromRGB(0xDBDFE6) : cell.isSaved ? UIColorFromRGB(0xDFDCD6) : UIColorFromRGB(0xF7F8F5); - +#endif + // [backgroundColor set]; self.backgroundColor = backgroundColor; cell.backgroundColor = backgroundColor; @@ -219,7 +226,7 @@ - (void)drawRect:(CGRect)r { paragraphStyle.alignment = NSTextAlignmentLeft; CGSize faviconSize; if (cell.isSocial) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!cell.appDelegate.isPhone) { faviconSize = CGSizeMake(28, 28); UIImage *feedIcon = [Utilities roundCorneredImage:cell.feedFavicon radius:4 convertToSize:faviconSize]; [feedIcon drawInRect:CGRectMake(9.0, CGRectGetMidY(r)-faviconSize.height/2, faviconSize.width, faviconSize.height)]; @@ -239,7 +246,7 @@ - (void)drawRect:(CGRect)r { } else { faviconSize = CGSizeMake(16, 16); UIImage *feedIcon = [Utilities roundCorneredImage:cell.feedFavicon radius:4 convertToSize:faviconSize]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!cell.appDelegate.isPhone) { [feedIcon drawInRect:CGRectMake(12.0, CGRectGetMidY(r)-faviconSize.height/2, faviconSize.width, faviconSize.height)]; [cell.feedTitle drawInRect:CGRectMake(36.0, titleOffsetY, r.size.width - ([cell.unreadCount offsetWidth] + 36) - 10, font.pointSize*1.4) withAttributes:@{NSFontAttributeName: font, diff --git a/clients/ios/Classes/FeedsObjCViewController.h b/clients/ios/Classes/FeedsObjCViewController.h index 7dda6f8b7e..bcac146ba8 100644 --- a/clients/ios/Classes/FeedsObjCViewController.h +++ b/clients/ios/Classes/FeedsObjCViewController.h @@ -74,7 +74,9 @@ UIGestureRecognizerDelegate, UISearchBarDelegate> { @property (nonatomic, readwrite) BOOL viewShowingAllFeeds; @property (nonatomic, readwrite) BOOL interactiveFeedDetailTransition; @property (nonatomic, readwrite) BOOL isOffline; +#if !TARGET_OS_MACCATALYST @property (nonatomic) UIRefreshControl *refreshControl; +#endif @property (nonatomic) UISearchBar *searchBar; @property (nonatomic, strong) NSArray *searchFeedIds; @property (nonatomic) NSCache *imageCache; diff --git a/clients/ios/Classes/FeedsObjCViewController.m b/clients/ios/Classes/FeedsObjCViewController.m index 68e59a5e2a..a5120fa5bd 100644 --- a/clients/ios/Classes/FeedsObjCViewController.m +++ b/clients/ios/Classes/FeedsObjCViewController.m @@ -113,12 +113,14 @@ - (void)viewDidLoad { self.rowHeights = [NSMutableDictionary dictionary]; self.folderTitleViews = [NSMutableDictionary dictionary]; +#if !TARGET_OS_MACCATALYST self.refreshControl = [UIRefreshControl new]; self.refreshControl.tintColor = UIColorFromLightDarkRGB(0x0, 0xffffff); self.refreshControl.backgroundColor = UIColorFromRGB(0xE3E6E0); [self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; self.feedTitlesTable.refreshControl = self.refreshControl; self.feedViewToolbar.translatesAutoresizingMaskIntoConstraints = NO; +#endif self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.feedTitlesTable.frame), 44.)]; @@ -169,7 +171,13 @@ - (void)viewDidLoad { [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: UIColorFromFixedRGB(0x4C4D4A)} forState:UIControlStateHighlighted]; +#if TARGET_OS_MACCATALYST +// self.view.superview.backgroundColor = UIColor.clearColor; +// self.view.backgroundColor = UIColor.clearColor; + self.view.backgroundColor = UIColorFromRGB(0xf4f4f4); //TODO: work in progress +#else self.view.backgroundColor = UIColorFromRGB(0xf4f4f4); +#endif self.navigationController.navigationBar.tintColor = UIColorFromRGB(0x8F918B); self.navigationController.navigationBar.translucent = NO; UIInterfaceOrientation orientation = self.view.window.windowScene.interfaceOrientation; @@ -194,7 +202,12 @@ - (void)viewDidLoad { self.notifier.topOffsetConstraint = [NSLayoutConstraint constraintWithItem:self.notifier attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.feedViewToolbar attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; [self.view addConstraint:self.notifier.topOffsetConstraint]; +#if TARGET_OS_MACCATALYST +// self.feedTitlesTable.backgroundColor = UIColor.clearColor; + self.feedTitlesTable.backgroundColor = UIColorFromRGB(0xf4f4f4); //TODO: work in progress +#else self.feedTitlesTable.backgroundColor = UIColorFromRGB(0xf4f4f4); +#endif self.feedTitlesTable.separatorColor = [UIColor clearColor]; self.feedTitlesTable.translatesAutoresizingMaskIntoConstraints = NO; self.feedTitlesTable.estimatedRowHeight = 0; @@ -228,7 +241,7 @@ - (void)viewWillAppear:(BOOL)animated { [self resetRowHeights]; -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && +// if (!self.isPhone && // !self.interactiveFeedDetailTransition) { // // [appDelegate.masterContainerViewController transitionFromFeedDetail]; @@ -236,6 +249,13 @@ - (void)viewWillAppear:(BOOL)animated { // NSLog(@"Feed List timing 0: %f", [NSDate timeIntervalSinceReferenceDate] - start); [super viewWillAppear:animated]; +#if TARGET_OS_MACCATALYST + UINavigationController *navController = self.navigationController; + UITitlebar *titlebar = navController.navigationBar.window.windowScene.titlebar; + + titlebar.titleVisibility = UITitlebarTitleVisibilityHidden; +#endif + NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults]; NSInteger intelligenceLevel = [userPreferences integerForKey:@"selectedIntelligence"]; @@ -421,7 +441,7 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)builder { + +} + #pragma mark - #pragma mark State Restoration @@ -897,7 +921,7 @@ - (void)finishLoadingFeedListWithDict:(NSDictionary *)results finished:(BOOL)fin [self refreshHeaderCounts]; [appDelegate checkForFeedNotifications]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && finished) { + if (!self.isPhone && finished) { [self cacheFeedRowLocations]; } @@ -1052,9 +1076,11 @@ - (IBAction)showSettingsPopover:(id)sender { MenuViewController *viewController = [MenuViewController new]; - [viewController addTitle:@"Preferences" iconName:@"dialog-preferences" iconColor:UIColorFromRGB(0xDF8566) selectionShouldDismiss:YES handler:^{ - [self.appDelegate showPreferences]; - }]; + if (!self.isMac) { + [viewController addTitle:@"Preferences" iconName:@"dialog-preferences" iconColor:UIColorFromRGB(0xDF8566) selectionShouldDismiss:YES handler:^{ + [self.appDelegate showPreferences]; + }]; + } [viewController addTitle:@"Mute Sites" iconName:@"menu_icn_mute.png" selectionShouldDismiss:YES handler:^{ [self.appDelegate showMuteSites]; @@ -1295,9 +1321,15 @@ - (void)updateTheme { self.feedViewToolbar.barTintColor = [UINavigationBar appearance].barTintColor; self.addBarButton.tintColor = UIColorFromRGB(0x8F918B); self.settingsBarButton.tintColor = UIColorFromRGB(0x8F918B); +#if TARGET_OS_MACCATALYST +// self.view.superview.backgroundColor = UIColor.clearColor; +// self.view.backgroundColor = UIColor.clearColor; + self.view.backgroundColor = UIColorFromRGB(0xf4f4f4); //TODO: work in progress +#else self.refreshControl.tintColor = UIColorFromLightDarkRGB(0x0, 0xffffff); self.refreshControl.backgroundColor = UIColorFromRGB(0xE3E6E0); self.view.backgroundColor = UIColorFromRGB(0xf4f4f4); +#endif [[ThemeManager themeManager] updateSegmentedControl:self.intelligenceControl]; @@ -1322,7 +1354,13 @@ - (void)updateTheme { self.searchBar.keyboardAppearance = UIKeyboardAppearanceDefault; } +#if TARGET_OS_MACCATALYST +// self.feedTitlesTable.backgroundColor = UIColor.clearColor; + self.feedTitlesTable.backgroundColor = UIColorFromRGB(0xf4f4f4); //TODO: work in progress +#else self.feedTitlesTable.backgroundColor = UIColorFromRGB(0xf4f4f4); +#endif + [self reloadFeedTitlesTable]; [self resetupGestures]; @@ -1678,7 +1716,7 @@ - (CGFloat)tableView:(UITableView *)tableView - (CGFloat)calculateHeightForRowAtIndexPath:(NSIndexPath *)indexPath { if (appDelegate.hasNoSites) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { return kBlurblogTableViewRowHeight; } else { return kPhoneBlurblogTableViewRowHeight; @@ -1722,13 +1760,13 @@ - (CGFloat)calculateHeightForRowAtIndexPath:(NSIndexPath *)indexPath { if ([folderName isEqualToString:@"river_blurblogs"] || [folderName isEqualToString:@"river_global"]) { // blurblogs - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { height = kBlurblogTableViewRowHeight; } else { height = kPhoneBlurblogTableViewRowHeight; } } else { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { height = kTableViewRowHeight; } else { height = kPhoneTableViewRowHeight; @@ -2448,7 +2486,7 @@ - (IBAction)selectIntelligence { [hud hide:YES afterDelay:0.5]; [self showExplainerOnEmptyFeedlist]; -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // FeedDetailViewController *storiesModule = self.appDelegate.dashboardViewController.storiesModule; // // storiesModule.storiesCollection.feedPage = 0; @@ -2677,15 +2715,19 @@ - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText #pragma mark - #pragma mark PullToRefresh +#if !TARGET_OS_MACCATALYST - (void)refresh:(UIRefreshControl *)refreshControl { self.inPullToRefresh_ = YES; [appDelegate reloadFeedsView:NO]; [appDelegate donateRefresh]; } +#endif - (void)finishRefresh { self.inPullToRefresh_ = NO; +#if !TARGET_OS_MACCATALYST [self.refreshControl endRefreshing]; +#endif } - (void)refreshFeedList { diff --git a/clients/ios/Classes/FirstTimeUserAddFriendsViewController.m b/clients/ios/Classes/FirstTimeUserAddFriendsViewController.m index 72124a4626..737299d4ce 100644 --- a/clients/ios/Classes/FirstTimeUserAddFriendsViewController.m +++ b/clients/ios/Classes/FirstTimeUserAddFriendsViewController.m @@ -53,7 +53,7 @@ - (void)viewWillAppear:(BOOL)animated { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { // return YES; diff --git a/clients/ios/Classes/FirstTimeUserAddNewsBlurViewController.m b/clients/ios/Classes/FirstTimeUserAddNewsBlurViewController.m index 308622701c..b2922cc699 100644 --- a/clients/ios/Classes/FirstTimeUserAddNewsBlurViewController.m +++ b/clients/ios/Classes/FirstTimeUserAddNewsBlurViewController.m @@ -51,7 +51,7 @@ - (void)viewDidAppear:(BOOL)animated { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { // return YES; diff --git a/clients/ios/Classes/FirstTimeUserAddSitesViewController.m b/clients/ios/Classes/FirstTimeUserAddSitesViewController.m index b37b658b43..99b06240ee 100644 --- a/clients/ios/Classes/FirstTimeUserAddSitesViewController.m +++ b/clients/ios/Classes/FirstTimeUserAddSitesViewController.m @@ -89,7 +89,7 @@ - (void)viewWillAppear:(BOOL)animated { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { // return YES; diff --git a/clients/ios/Classes/FirstTimeUserViewController.m b/clients/ios/Classes/FirstTimeUserViewController.m index f40444c8e5..6dbc872a0f 100644 --- a/clients/ios/Classes/FirstTimeUserViewController.m +++ b/clients/ios/Classes/FirstTimeUserViewController.m @@ -98,7 +98,7 @@ - (void)viewDidDisappear:(BOOL)animated { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { // return YES; diff --git a/clients/ios/Classes/FolderTitleView.m b/clients/ios/Classes/FolderTitleView.m index f20c40b3de..a33be9291d 100644 --- a/clients/ios/Classes/FolderTitleView.m +++ b/clients/ios/Classes/FolderTitleView.m @@ -213,7 +213,7 @@ - (void) drawRect:(CGRect)rect { if (section == NewsBlurTopSectionInfrequentSiteStories) { folderImage = [UIImage imageNamed:@"ak-icon-infrequent.png"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 7; @@ -221,7 +221,7 @@ - (void) drawRect:(CGRect)rect { allowLongPress = YES; } else if (section == NewsBlurTopSectionAllStories) { folderImage = [UIImage imageNamed:@"all-stories"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 7; @@ -229,42 +229,42 @@ - (void) drawRect:(CGRect)rect { allowLongPress = NO; } else if ([folderName isEqual:@"river_global"]) { folderImage = [UIImage imageNamed:@"global-shares"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 8; } } else if ([folderName isEqual:@"river_blurblogs"]) { folderImage = [UIImage imageNamed:@"all-shares"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 8; } } else if ([folderName isEqual:@"saved_searches"]) { folderImage = [UIImage imageNamed:@"search"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 7; } } else if ([folderName isEqual:@"saved_stories"]) { folderImage = [UIImage imageNamed:@"saved-stories"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 7; } } else if ([folderName isEqual:@"read_stories"]) { folderImage = [UIImage imageNamed:@"indicator-unread"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 7; } } else if ([folderName isEqual:@"widget_stories"]) { folderImage = [UIImage imageNamed:@"g_icn_folder_widget.png"]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { folderImageViewX = 10; } else { folderImageViewX = 7; @@ -275,7 +275,7 @@ - (void) drawRect:(CGRect)rect { } else { folderImage = [UIImage imageNamed:@"folder-open"]; } - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { } else { folderImageViewX = 7; } diff --git a/clients/ios/Classes/FriendsListViewController.m b/clients/ios/Classes/FriendsListViewController.m index b18f1c5ba7..641325bc06 100644 --- a/clients/ios/Classes/FriendsListViewController.m +++ b/clients/ios/Classes/FriendsListViewController.m @@ -156,7 +156,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege // if (self.inSearch_){ // return 0; // } else { -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){ +// if (!self.isPhone){ // return 28; // }else{ // return 21; @@ -168,7 +168,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { int headerLabelHeight, folderImageViewY; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { headerLabelHeight = 28; folderImageViewY = 3; } else { @@ -280,7 +280,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N // add a NO FRIENDS TO SUGGEST message on either the first or second row depending on iphone/ipad int row = 0; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { row = 1; } diff --git a/clients/ios/Classes/InteractionsModule.m b/clients/ios/Classes/InteractionsModule.m index b279074db7..4f1ba0dca3 100644 --- a/clients/ios/Classes/InteractionsModule.m +++ b/clients/ios/Classes/InteractionsModule.m @@ -154,7 +154,7 @@ -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger userInteractions = [appDelegate.userInteractionsArray count]; int minimumHeight; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { minimumHeight = MINIMUM_INTERACTION_HEIGHT_IPAD; } else { minimumHeight = MINIMUM_INTERACTION_HEIGHT_IPHONE; @@ -165,7 +165,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa } InteractionCell *interactionCell; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { interactionCell = [[InteractionCell alloc] init]; } else { interactionCell = [[SmallInteractionCell alloc] init]; @@ -190,7 +190,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N InteractionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InteractionCell"]; if (cell == nil) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { cell = [[InteractionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InteractionCell"]; } else { cell = [[SmallInteractionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InteractionCell"]; @@ -276,7 +276,7 @@ - (UITableViewCell *)makeLoadingCell { UIImageView *fleuron = [[UIImageView alloc] initWithImage:img]; int height; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { height = MINIMUM_INTERACTION_HEIGHT_IPAD; } else { height = MINIMUM_INTERACTION_HEIGHT_IPHONE; diff --git a/clients/ios/Classes/LoginViewController.m b/clients/ios/Classes/LoginViewController.m index a6cd9fe7ce..9c44685f9d 100644 --- a/clients/ios/Classes/LoginViewController.m +++ b/clients/ios/Classes/LoginViewController.m @@ -71,7 +71,7 @@ - (CGFloat)xForWidth:(CGFloat)width { } - (void)rearrangeViews { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { CGSize viewSize = self.view.bounds.size; CGFloat viewWidth = viewSize.width; CGFloat yOffset = 0; @@ -98,7 +98,7 @@ - (void)viewWillAppear:(BOOL)animated { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } // return NO; @@ -108,7 +108,7 @@ - (void)viewDidAppear:(BOOL)animated { [MBProgressHUD hideHUDForView:self.view animated:YES]; [super viewDidAppear:animated]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self updateControls]; [self rearrangeViews]; } @@ -141,7 +141,7 @@ - (void)showError:(NSString *)error { self.errorLabel.hidden = !hasError; self.forgotPasswordButton.hidden = !hasError; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { self.loginOptionalLabel.hidden = hasError; } } @@ -166,7 +166,7 @@ - (IBAction)findLoginFrom1Password:(id)sender { - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { if(textField == usernameInput) { [passwordInput becomeFirstResponder]; } else if (textField == passwordInput) { @@ -244,7 +244,7 @@ - (void)registerAccount { setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; NSMutableDictionary *params = [NSMutableDictionary dictionary]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [params setObject:[signUpUsernameInput text] forKey:@"username"]; [params setObject:[signUpPasswordInput text] forKey:@"password"]; } else { diff --git a/clients/ios/Classes/MoveSiteViewController.m b/clients/ios/Classes/MoveSiteViewController.m index 34190e24ab..d4eed46a66 100644 --- a/clients/ios/Classes/MoveSiteViewController.m +++ b/clients/ios/Classes/MoveSiteViewController.m @@ -61,7 +61,7 @@ - (void)viewDidLoad { //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // // Return YES for supported orientations -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // return YES; // } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { // return YES; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.h b/clients/ios/Classes/NewsBlurAppDelegate.h index f526de3db1..0ca8c817b7 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.h +++ b/clients/ios/Classes/NewsBlurAppDelegate.h @@ -287,7 +287,6 @@ SFSafariViewControllerDelegate> { @property (nonatomic, readwrite) BOOL hasQueuedReadStories; @property (nonatomic, readwrite) BOOL hasQueuedSavedStories; @property (nonatomic, readonly) BOOL showingSafariViewController; -@property (nonatomic, readonly) BOOL isCompactWidth; //@property (nonatomic) CGFloat compactWidth; @property (nonatomic, strong) BGAppRefreshTask *backgroundAppRefreshTask; @@ -395,7 +394,6 @@ SFSafariViewControllerDelegate> { - (BOOL)isSavedStoriesIntelligenceMode; - (NSArray *)allFeedIds; - (NSArray *)feedIdsForFolderTitle:(NSString *)folderTitle; -- (BOOL)isPortrait; - (void)confirmLogout; - (void)showConnectToService:(NSString *)serviceName; - (void)showAlert:(UIAlertController *)alert withViewController:(UIViewController *)vc; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index 56dcedca75..4e5f70f579 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -207,7 +207,7 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions: // self.navigationController.viewControllers = [NSArray arrayWithObject:self.feedsViewController]; self.storiesCollection = [StoriesCollection new]; -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPhond) { // self.window.rootViewController = self.masterContainerViewController; // } else { // self.window.rootViewController = self.navigationController; @@ -242,7 +242,7 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions: (unsigned long)NULL), ^(void) { [self setupReachability]; self.cacheImagesOperationQueue = [NSOperationQueue new]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { self.cacheImagesOperationQueue.maxConcurrentOperationCount = 2; } else { self.cacheImagesOperationQueue.maxConcurrentOperationCount = 1; @@ -423,6 +423,10 @@ - (BOOL)handleShortcutItem:(UIApplicationShortcutItem *)shortcutItem { return handled; } +- (void)buildMenuWithBuilder:(id)builder { + +} + - (void)delayedAddSite { [self.feedsViewController tapAddSite:self]; } @@ -476,7 +480,7 @@ - (void)registerDefaultsFromSettingsBundle { return; } - NSString *name = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? @"Root~ipad.plist" : @"Root.plist"; + NSString *name = !self.isPhone ? @"Root~ipad.plist" : @"Root.plist"; NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:name]]; NSArray *preferences = [settings objectForKey:@"PreferenceSpecifiers"]; @@ -767,7 +771,7 @@ - (void)showUserProfileModal:(id)sender { newUserProfile.navigationItem.title = self.activeUserProfileName; newUserProfile.navigationItem.backBarButtonItem.title = self.activeUserProfileName; [newUserProfile getUserProfile]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self showPopoverWithViewController:self.userProfileNavigationController contentSize:CGSizeMake(320, 454) sender:sender]; } else { [self.feedsNavigationController presentViewController:navController animated:YES completion:nil]; @@ -799,7 +803,7 @@ - (void)pushUserProfile { } - (void)hideUserProfileModal { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self hidePopover]; } else { [self.feedsNavigationController dismissViewControllerAnimated:YES completion:nil]; @@ -896,6 +900,11 @@ - (void)addSplitControlToMenuController:(MenuViewController *)menuViewController } - (void)showPreferences { + if (self.isMac) { +// [[UIApplication sharedApplication] sendAction:@selector(orderFrontPreferencesPanel:) to:nil from:nil forEvent:nil]; + return; + } + if (!preferencesViewController) { preferencesViewController = [[IASKAppSettingsViewController alloc] init]; [[ThemeManager themeManager] addThemeGestureRecognizerToView:self.preferencesViewController.view]; @@ -917,7 +926,7 @@ - (void)showPreferences { self.modalNavigationController = navController; self.modalNavigationController.navigationBar.translucent = NO; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { self.modalNavigationController.modalPresentationStyle = UIModalPresentationFormSheet; } @@ -1092,7 +1101,7 @@ - (void)showSendTo:(UIViewController *)vc sender:(id)sender } }]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { BOOL fromPopover = [self hidePopoverAnimated:NO]; [self.splitViewController presentViewController:activityViewController animated:!fromPopover completion:nil]; activityViewController.modalPresentationStyle = UIModalPresentationPopover; @@ -1132,7 +1141,7 @@ - (void)showShareView:(NSString *)type setReplyId:(NSString *)replyId { [self.shareViewController setCommentType:type]; -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // [self.masterContainerViewController transitionToShareView]; // [self.shareViewController setSiteInfo:type setUserId:userId setUsername:username setReplyId:replyId]; // } else { @@ -1154,7 +1163,7 @@ - (void)hideShareView:(BOOL)resetComment { self.shareViewController.currentType = nil; } -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // [self.masterContainerViewController transitionFromShareView]; // [self.storyPagesViewController becomeFirstResponder]; // } else @@ -1301,7 +1310,7 @@ - (void)openTrainSiteWithFeedLoaded:(BOOL)feedLoaded from:(id)sender { trainerViewController.storyTrainer = NO; trainerViewController.feedLoaded = feedLoaded; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { // trainerViewController.modalPresentationStyle=UIModalPresentationFormSheet; // [navController presentViewController:trainerViewController animated:YES completion:nil]; [self showPopoverWithViewController:self.trainerViewController contentSize:CGSizeMake(500, 630) sender:sender]; @@ -1320,7 +1329,7 @@ - (void)openTrainStory:(id)sender { trainerViewController.feedTrainer = NO; trainerViewController.storyTrainer = YES; trainerViewController.feedLoaded = YES; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self showPopoverWithViewController:self.trainerViewController contentSize:CGSizeMake(500, 630) sender:sender]; } else { if (self.trainNavigationController == nil) { @@ -1343,7 +1352,7 @@ - (void)openNotificationsWithFeed:(NSString *)feedId { - (void)openNotificationsWithFeed:(NSString *)feedId sender:(id)sender { UINavigationController *navController = self.feedsNavigationController; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self showPopoverWithViewController:self.notificationsViewController contentSize:CGSizeMake(420, 382) sender:sender]; } else { if (self.notificationsNavigationController == nil) { @@ -1453,13 +1462,17 @@ - (void)clearNetworkManager { networkManager.responseSerializer = [AFJSONResponseSerializer serializer]; [networkManager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; - NSString *currentiPhoneVersion = [[[NSBundle mainBundle] infoDictionary] + NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; NSString *UA; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { - UA = [NSString stringWithFormat:@"NewsBlur iPad App v%@", currentiPhoneVersion]; + if (self.isMac) { + UA = [NSString stringWithFormat:@"NewsBlur Mac App v%@", currentVersion]; + } else if (self.isVision) { + UA = [NSString stringWithFormat:@"NewsBlur Vision App v%@", currentVersion]; + } else if (self.isPhone) { + UA = [NSString stringWithFormat:@"NewsBlur iPhone App v%@", currentVersion]; } else { - UA = [NSString stringWithFormat:@"NewsBlur iPhone App v%@", currentiPhoneVersion]; + UA = [NSString stringWithFormat:@"NewsBlur iPad App v%@", currentVersion]; } [networkManager.requestSerializer setValue:UA forHTTPHeaderField:@"User-Agent"]; } @@ -1699,7 +1712,7 @@ - (void)loadFeed:(NSString *)feedId [self reloadFeedsView:NO]; // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // [self loadFeedDetailView]; // } else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { // // [self.feedsNavigationController popToRootViewControllerAnimated:NO]; @@ -1747,7 +1760,7 @@ - (void)loadTryFeedDetailView:(NSString *)feedId storiesCollection.activeFeed = feed; storiesCollection.activeFolder = nil; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self loadFeedDetailView]; } else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { // [self.feedsNavigationController popToRootViewControllerAnimated:NO]; @@ -1768,7 +1781,7 @@ - (void)loadTryFeedDetailView:(NSString *)feedId - (void)backgroundLoadNotificationStory { if (self.inFindingStoryMode) { if ([storiesCollection.activeFolder isEqualToString:@"widget_stories"]) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self.feedsViewController selectWidgetStories]; } else { [self loadRiverFeedDetailView:self.feedDetailViewController withFolder:self.widgetFolder]; @@ -1781,7 +1794,7 @@ - (void)backgroundLoadNotificationStory { } } else if (self.tryFeedFeedId && !self.isTryFeedView) { [self loadFeed:self.tryFeedFeedId withStory:self.tryFeedStoryId animated:NO]; - } else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && !self.isCompactWidth && self.storiesCollection == nil) { + } else if (!self.isPhone && !self.isCompactWidth && self.storiesCollection == nil) { [self loadRiverFeedDetailView:self.feedDetailViewController withFolder:storiesCollection.activeFolder]; } else if (self.pendingFolder != nil) { [self loadRiverFeedDetailView:self.feedDetailViewController withFolder:self.pendingFolder]; @@ -1821,7 +1834,7 @@ - (void)loadStarredDetailViewWithStory:(NSString *)contentId [self loadRiverFeedDetailView:feedDetailViewController withFolder:@"saved_stories"]; if (showHUD) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self.storyPagesViewController showShareHUD:@"Finding story..."]; } else { MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.feedDetailViewController.view animated:YES]; @@ -1888,20 +1901,6 @@ - (NSArray *)feedIdsForFolderTitle:(NSString *)folderTitle { } } -- (BOOL)isPortrait { - UIInterfaceOrientation orientation = self.window.windowScene.interfaceOrientation; - if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { - return YES; - } else { - return NO; - } -} - -- (BOOL)isCompactWidth { - return self.window.windowScene.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact; - //return self.compactWidth > 0.0; -} - - (void)confirmLogout { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Positive?" message:nil preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle: @"Logout" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -2112,7 +2111,7 @@ - (void)openDashboardRiverForStory:(NSString *)contentId [self loadRiverFeedDetailView:feedDetailViewController withFolder:@"river_dashboard"]; if (showHUD) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self.storyPagesViewController showShareHUD:@"Finding story..."]; } else { MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.feedDetailViewController.view animated:YES]; @@ -2225,7 +2224,7 @@ - (void)loadStoryDetailView { [self.detailViewController checkLayout]; } - BOOL animated = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && + BOOL animated = (!self.isPhone && !self.tryFeedCategory); [self.storyPagesViewController view]; [self.storyPagesViewController.view setNeedsLayout]; @@ -2353,7 +2352,7 @@ - (void)showInAppBrowser:(NSURL *)url withCustomTitle:(NSString *)customTitle fr self.activeOriginalStoryURL = url; originalStoryViewController.customPageTitle = customTitle; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { if ([sender isKindOfClass:[UIBarButtonItem class]]) { [originalStoryViewController view]; // Force viewDidLoad [originalStoryViewController loadInitialStory]; @@ -2408,7 +2407,7 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller { } - (void)deferredSafariCleanup { -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // self.navigationController.view.frame = CGRectMake(self.navigationController.view.frame.origin.x, self.navigationController.view.frame.origin.y, self.isPortrait ? 270.0 : 370.0, self.navigationController.view.frame.size.height); // } @@ -2442,7 +2441,7 @@ - (UINavigationController *)fontSettingsNavigationController { } - (void)closeOriginalStory { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { // [self.masterContainerViewController transitionFromOriginalView]; } else { if ([[feedsNavigationController viewControllers] containsObject:originalStoryViewController]) { diff --git a/clients/ios/Classes/NotificationsViewController.m b/clients/ios/Classes/NotificationsViewController.m index 709581ce21..409f1be211 100644 --- a/clients/ios/Classes/NotificationsViewController.m +++ b/clients/ios/Classes/NotificationsViewController.m @@ -85,7 +85,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { int headerLabelHeight, folderImageViewY; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { headerLabelHeight = 36; folderImageViewY = 8; } else { diff --git a/clients/ios/Classes/OriginalStoryViewController.m b/clients/ios/Classes/OriginalStoryViewController.m index 8e31db3da5..6a3879ea2c 100644 --- a/clients/ios/Classes/OriginalStoryViewController.m +++ b/clients/ios/Classes/OriginalStoryViewController.m @@ -32,7 +32,7 @@ - (void)viewDidLoad { self.view.layer.shadowOpacity = 0.5; self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { closeButton = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"ios7_back_button"] target:self action:@selector(closeOriginalView)]; @@ -70,7 +70,7 @@ - (void)viewDidLoad { // UIGestureRecognizer *themeGesture = [[ThemeManager themeManager] addThemeGestureRecognizerToView:self.webView]; // [self.webView.scrollView.panGestureRecognizer requireGestureRecognizerToFail:themeGesture]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]; gesture.delegate = self; @@ -215,7 +215,7 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)recognizer { center.y); self.view.center = center; [recognizer setTranslation:CGPointZero inView:self.view]; -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // [appDelegate.masterContainerViewController interactiveTransitionFromOriginalView:percentage]; // } else { // @@ -231,7 +231,7 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)recognizer { [self transitionToFeedDetail:recognizer]; } else { // NSLog(@"Original velocity: %f (at %.2f%%)", velocity, percentage*100); -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // [appDelegate.masterContainerViewController transitionToOriginalView:NO]; // } else { // @@ -241,7 +241,7 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)recognizer { } - (void)transitionToFeedDetail:(UIGestureRecognizer *)recognizer { -// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { +// if (!self.isPhone) { // [appDelegate.masterContainerViewController transitionFromOriginalView]; // } else { // diff --git a/clients/ios/Classes/ShareViewController.m b/clients/ios/Classes/ShareViewController.m index eded2e0f66..c6027a0062 100644 --- a/clients/ios/Classes/ShareViewController.m +++ b/clients/ios/Classes/ShareViewController.m @@ -202,7 +202,7 @@ - (void)adjustCommentField:(CGSize)kbSize { self.storyTitle.frame = CGRectMake(20, 8, v.width - 20*2, 24); stOffset = self.storyTitle.frame.origin.y + self.storyTitle.frame.size.height; stHeight = self.storyTitle.frame.size.height; - } else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + } else if (!self.isPhone) { k = 0; } NSLog(@"Share type: %@", self.currentType); diff --git a/clients/ios/Classes/SmallActivityCell.m b/clients/ios/Classes/SmallActivityCell.m index c2ffa2f69c..0e4126d675 100644 --- a/clients/ios/Classes/SmallActivityCell.m +++ b/clients/ios/Classes/SmallActivityCell.m @@ -9,6 +9,7 @@ #import "SmallActivityCell.h" #import "UIImageView+AFNetworking.h" #import +#import "NewsBlurAppDelegate.h" @implementation SmallActivityCell @@ -62,7 +63,7 @@ - (void)layoutSubviews { labelFrame.size.height = contentRect.size.height; self.activityLabel.frame = labelFrame; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!((NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate]).isPhone) { self.activityLabel.backgroundColor = UIColorFromRGB(0xd7dadf); } else { self.activityLabel.backgroundColor = UIColorFromRGB(0xf6f6f6); diff --git a/clients/ios/Classes/SmallInteractionCell.m b/clients/ios/Classes/SmallInteractionCell.m index 6d346fe82e..23a7d15fd1 100644 --- a/clients/ios/Classes/SmallInteractionCell.m +++ b/clients/ios/Classes/SmallInteractionCell.m @@ -9,6 +9,7 @@ #import "SmallInteractionCell.h" #import "UIImageView+AFNetworking.h" #import +#import "NewsBlurAppDelegate.h" @implementation SmallInteractionCell @@ -57,8 +58,8 @@ - (void)layoutSubviews { labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20; labelFrame.size.height = contentRect.size.height; self.interactionLabel.frame = labelFrame; - - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + + if (!((NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate]).isPhone) { self.interactionLabel.backgroundColor = UIColorFromRGB(0xd7dadf); } else { self.interactionLabel.backgroundColor = UIColorFromRGB(0xf6f6f6); diff --git a/clients/ios/Classes/Story.swift b/clients/ios/Classes/Story.swift index 83b4f8b3e8..a4908f93e8 100644 --- a/clients/ios/Classes/Story.swift +++ b/clients/ios/Classes/Story.swift @@ -335,14 +335,14 @@ class StorySettings { guard let pref = UserDefaults.standard.string(forKey: "grid_columns"), let columns = Int(pref) else { if NewsBlurAppDelegate.shared.isCompactWidth { return 1 - } else if NewsBlurAppDelegate.shared.isPortrait() { + } else if NewsBlurAppDelegate.shared.isPortrait { return 2 } else { return 4 } } - if NewsBlurAppDelegate.shared.isPortrait(), columns > 3 { + if NewsBlurAppDelegate.shared.isPortrait, columns > 3 { return 3 } diff --git a/clients/ios/Classes/StoryDetailObjCViewController.m b/clients/ios/Classes/StoryDetailObjCViewController.m index 865369ffff..8fd36154b9 100644 --- a/clients/ios/Classes/StoryDetailObjCViewController.m +++ b/clients/ios/Classes/StoryDetailObjCViewController.m @@ -24,8 +24,8 @@ #import "JNWThrottledBlock.h" #import "NewsBlur-Swift.h" -#define iPadPro12 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && ([UIScreen mainScreen].bounds.size.height == 1366 || [UIScreen mainScreen].bounds.size.width == 1366)) -#define iPadPro10 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && ([UIScreen mainScreen].bounds.size.height == 1112 || [UIScreen mainScreen].bounds.size.width == 1112)) +#define iPadPro12 (!self.isPhone && ([UIScreen mainScreen].bounds.size.height == 1366 || [UIScreen mainScreen].bounds.size.width == 1366)) +#define iPadPro10 (!self.isPhone && ([UIScreen mainScreen].bounds.size.height == 1112 || [UIScreen mainScreen].bounds.size.width == 1112)) @interface StoryDetailObjCViewController () @@ -99,7 +99,7 @@ - (void)viewDidLoad { [self.webView.scrollView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } @@ -401,9 +401,13 @@ - (void)loadHTMLString:(NSString *)html { static NSURL *baseURL; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ +#if TARGET_OS_MACCATALYST + baseURL = [NSBundle mainBundle].resourceURL; +#else baseURL = [NSBundle mainBundle].bundleURL; +#endif }); - + [self.webView loadHTMLString:html baseURL:baseURL]; } @@ -480,7 +484,7 @@ - (void)drawStory:(BOOL)force withOrientation:(UIInterfaceOrientation)orientatio #if TARGET_OS_MACCATALYST // CATALYST: probably will want to add custom CSS for Macs. - contentWidthClass = @"NB-ipad-wide NB-ipad-pro-12-wide NB-width-768"; + contentWidthClass = @"NB-ipad-wide NB-ipad-pro-12-wide"; #else if (UIInterfaceOrientationIsLandscape(orientation) && !self.isPhoneOrCompact) { if (iPadPro12) { @@ -503,10 +507,10 @@ - (void)drawStory:(BOOL)force withOrientation:(UIInterfaceOrientation)orientatio } else { contentWidthClass = @"NB-iphone"; } +#endif contentWidthClass = [NSString stringWithFormat:@"%@ NB-width-%d", contentWidthClass, (int)floorf(CGRectGetWidth(self.view.frame))]; -#endif if (appDelegate.feedsViewController.isOffline) { NSString *storyHash = [self.activeStory objectForKey:@"story_hash"]; @@ -2399,7 +2403,7 @@ - (void)changeWebViewWidth { #if TARGET_OS_MACCATALYST // CATALYST: probably will want to add custom CSS for Macs. - contentWidthClass = @"NB-ipad-wide NB-ipad-pro-12-wide NB-width-768"; + contentWidthClass = @"NB-ipad-wide NB-ipad-pro-12-wide"; #else UIInterfaceOrientation orientation = self.view.window.windowScene.interfaceOrientation; @@ -2424,10 +2428,10 @@ - (void)changeWebViewWidth { } else { contentWidthClass = @"NB-iphone"; } +#endif contentWidthClass = [NSString stringWithFormat:@"%@ NB-width-%d", contentWidthClass, (int)floorf(CGRectGetWidth(webView.scrollView.bounds))]; -#endif NSString *alternateViewClass = @""; if (!self.isPhoneOrCompact) { diff --git a/clients/ios/Classes/StoryPagesObjCViewController.m b/clients/ios/Classes/StoryPagesObjCViewController.m index 505cd1e3d6..7e973d0341 100644 --- a/clients/ios/Classes/StoryPagesObjCViewController.m +++ b/clients/ios/Classes/StoryPagesObjCViewController.m @@ -108,7 +108,7 @@ - (void)viewDidLoad { [self.scrollView setAlwaysBounceHorizontal:self.isHorizontal]; [self.scrollView setAlwaysBounceVertical:!self.isHorizontal]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } @@ -663,7 +663,7 @@ - (void)reorientPages { [MBProgressHUD hideHUDForView:self.view animated:YES]; [self hideNotifier]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [currentPage realignScroll]; } } @@ -772,7 +772,7 @@ - (void)restorePage { if (pageIndex >= 0) { [self changePage:pageIndex animated:NO]; - } else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + } else if (!self.isPhone) { // If the story can't be found, don't show anything; uncomment this to instead show the first unread story: // [self doNextUnreadStory:nil]; } else { @@ -1218,7 +1218,7 @@ - (void)updatePageWithActiveStory:(NSInteger)location updateFeedDetail:(BOOL)upd [appDelegate.storiesCollection pushReadStory:[appDelegate.activeStory objectForKey:@"story_hash"]]; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { if (appDelegate.detailViewController.storyTitlesOnLeft) { appDelegate.detailViewController.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects: originalStoryButton, diff --git a/clients/ios/Classes/TrainerViewController.m b/clients/ios/Classes/TrainerViewController.m index ce7c7b9d5c..76d7c682e2 100644 --- a/clients/ios/Classes/TrainerViewController.m +++ b/clients/ios/Classes/TrainerViewController.m @@ -99,7 +99,7 @@ - (void)viewWillAppear:(BOOL)animated { [self informError:@"Could not load trainer"]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^() { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!self.isPhone) { [self.appDelegate hidePopover]; } else { [self.appDelegate.feedsNavigationController dismissViewControllerAnimated:YES completion:nil]; diff --git a/clients/ios/Classes/UnreadCountView.m b/clients/ios/Classes/UnreadCountView.m index 5d6c9c6946..abcab54181 100644 --- a/clients/ios/Classes/UnreadCountView.m +++ b/clients/ios/Classes/UnreadCountView.m @@ -54,7 +54,7 @@ - (void)drawInRect:(CGRect)r ps:(NSInteger)ps nt:(NSInteger)nt listType:(NBFeedL CGRect rr; if (listType == NBFeedListSocial) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { rr = CGRectMake(rect.size.width + rect.origin.x - psOffset, CGRectGetMidY(r)-COUNT_HEIGHT/2, psWidth, COUNT_HEIGHT); } else { rr = CGRectMake(rect.size.width + rect.origin.x - psOffset, CGRectGetMidY(r)-COUNT_HEIGHT/2, psWidth, COUNT_HEIGHT); @@ -98,7 +98,7 @@ - (void)drawInRect:(CGRect)r ps:(NSInteger)ps nt:(NSInteger)nt listType:(NBFeedL if (nt > 0 && appDelegate.selectedIntelligence <= 0) { CGRect rr; if (listType == NBFeedListSocial) { - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if (!appDelegate.isPhone) { rr = CGRectMake(rect.size.width + rect.origin.x - psWidth - psPadding - ntOffset, CGRectGetMidY(r)-COUNT_HEIGHT/2, ntWidth, COUNT_HEIGHT); } else { rr = CGRectMake(rect.size.width + rect.origin.x - psWidth - psPadding - ntOffset, CGRectGetMidY(r)-COUNT_HEIGHT/2, ntWidth, COUNT_HEIGHT); diff --git a/clients/ios/NewsBlur.xcodeproj/project.pbxproj b/clients/ios/NewsBlur.xcodeproj/project.pbxproj index 6595bdd5b8..27ceae4c3f 100755 --- a/clients/ios/NewsBlur.xcodeproj/project.pbxproj +++ b/clients/ios/NewsBlur.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -5539,7 +5539,9 @@ PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_INSTALLED_PRODUCT = NO; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = YES; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_OBJC_BRIDGING_HEADER = "Other Sources/BridgingHeader.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "NewsBlur-Swift.h"; TARGETED_DEVICE_FAMILY = "1,2,6"; @@ -5586,7 +5588,9 @@ PRODUCT_NAME = "NB Alpha"; PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = YES; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_OBJC_BRIDGING_HEADER = "Other Sources/BridgingHeader.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "NewsBlur-Swift.h"; TARGETED_DEVICE_FAMILY = "1,2,6"; diff --git a/clients/ios/Other Sources/AFNetworking/AFURLRequestSerialization.m b/clients/ios/Other Sources/AFNetworking/AFURLRequestSerialization.m index a4d5d9dfee..7043807cb9 100755 --- a/clients/ios/Other Sources/AFNetworking/AFURLRequestSerialization.m +++ b/clients/ios/Other Sources/AFNetworking/AFURLRequestSerialization.m @@ -171,7 +171,7 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData; #pragma mark - -static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { +static NSArray * AFHTTPRequestSerializerObservedKeyPaths(void) { static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -591,7 +591,7 @@ - (instancetype)copyWithZone:(NSZone *)zone { #pragma mark - -static NSString * AFCreateMultipartFormBoundary() { +static NSString * AFCreateMultipartFormBoundary(void) { return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; } diff --git a/clients/ios/Other Sources/AFNetworking/AFURLSessionManager.m b/clients/ios/Other Sources/AFNetworking/AFURLSessionManager.m index e96b8e2bbf..357659e485 100755 --- a/clients/ios/Other Sources/AFNetworking/AFURLSessionManager.m +++ b/clients/ios/Other Sources/AFNetworking/AFURLSessionManager.m @@ -28,7 +28,7 @@ #define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug NSFoundationVersionNumber_iOS_8_0 #endif -static dispatch_queue_t url_session_manager_creation_queue() { +static dispatch_queue_t url_session_manager_creation_queue(void) { static dispatch_queue_t af_url_session_manager_creation_queue; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -49,7 +49,7 @@ static void url_session_manager_create_task_safely(dispatch_block_t block) { } } -static dispatch_queue_t url_session_manager_processing_queue() { +static dispatch_queue_t url_session_manager_processing_queue(void) { static dispatch_queue_t af_url_session_manager_processing_queue; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -59,7 +59,7 @@ static dispatch_queue_t url_session_manager_processing_queue() { return af_url_session_manager_processing_queue; } -static dispatch_group_t url_session_manager_completion_group() { +static dispatch_group_t url_session_manager_completion_group(void) { static dispatch_group_t af_url_session_manager_completion_group; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ diff --git a/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.h b/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.h index 215eafcf74..e9101efaa6 100755 --- a/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.h +++ b/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.h @@ -24,7 +24,7 @@ #import -#if TARGET_OS_IOS +#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST #import diff --git a/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.m b/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.m index cd46916a10..4c5efaacfe 100755 --- a/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.m +++ b/clients/ios/Other Sources/AFNetworking/UIRefreshControl+AFNetworking.m @@ -23,7 +23,7 @@ #import "UIRefreshControl+AFNetworking.h" #import -#if TARGET_OS_IOS +#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST #import "AFURLSessionManager.h" diff --git a/clients/ios/Other Sources/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m b/clients/ios/Other Sources/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m index 0e49853a88..9ffc120fab 100755 --- a/clients/ios/Other Sources/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m +++ b/clients/ios/Other Sources/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m @@ -123,7 +123,7 @@ - (void)createSelections { - (BOOL)isPad { BOOL isPad = NO; #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 30200) - isPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad; + isPad = [[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPhone; #endif return isPad; } diff --git a/clients/ios/Other Sources/InAppSettingsKit/Models/IASKSettingsReader.m b/clients/ios/Other Sources/InAppSettingsKit/Models/IASKSettingsReader.m index 789bd9348e..2a511f7f93 100755 --- a/clients/ios/Other Sources/InAppSettingsKit/Models/IASKSettingsReader.m +++ b/clients/ios/Other Sources/InAppSettingsKit/Models/IASKSettingsReader.m @@ -279,7 +279,7 @@ - (NSString *)platformSuffixForInterfaceIdiom:(UIUserInterfaceIdiom) interfaceId switch (interfaceIdiom) { case UIUserInterfaceIdiomPad: return @"~ipad"; case UIUserInterfaceIdiomPhone: return @"~iphone"; - default: return @"~iphone"; + default: return @"~ipad"; } } diff --git a/clients/ios/Other Sources/OnePasswordExtension/OnePasswordExtension.m b/clients/ios/Other Sources/OnePasswordExtension/OnePasswordExtension.m index 3988ffb41e..c5840dae60 100644 --- a/clients/ios/Other Sources/OnePasswordExtension/OnePasswordExtension.m +++ b/clients/ios/Other Sources/OnePasswordExtension/OnePasswordExtension.m @@ -466,7 +466,7 @@ - (void)processExtensionItem:(nullable NSExtensionItem *)extensionItem completio } - (UIActivityViewController *)activityViewControllerForItem:(nonnull NSDictionary *)item viewController:(nonnull UIViewController*)viewController sender:(nullable id)sender typeIdentifier:(nonnull NSString *)typeIdentifier { - NSAssert(NO == ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && sender == nil), @"sender must not be nil on iPad."); + NSAssert(NO == ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPhone && sender == nil), @"sender must not be nil on iPad."); NSItemProvider *itemProvider = [[NSItemProvider alloc] initWithItem:item typeIdentifier:typeIdentifier]; diff --git a/clients/ios/Resources/MainInterface.storyboard b/clients/ios/Resources/MainInterface.storyboard index 6361ca2c57..5c97a96af6 100644 --- a/clients/ios/Resources/MainInterface.storyboard +++ b/clients/ios/Resources/MainInterface.storyboard @@ -1,11 +1,12 @@ - + + @@ -14,7 +15,7 @@ - + @@ -110,7 +111,7 @@ - + @@ -239,12 +240,23 @@ + + + + + + + + + + + + - @@ -276,7 +288,6 @@ - @@ -292,7 +303,6 @@ - @@ -336,7 +346,7 @@ - + @@ -405,7 +415,7 @@ - + @@ -420,7 +430,7 @@ - +