Merge branch 'dejal'

* dejal:
  #1340 (Open in Edge)
  #1357 (pull-to-refresh in feed detail)
  #1350 (fullscreen vertical scrolling) & #1338 (fullscreen improvements)
  #1342 (story selection fade)
  #1341 (back button color)
This commit is contained in:
Samuel Clay 2020-09-16 10:12:30 -04:00
commit e3f66b72ce
14 changed files with 128 additions and 59 deletions

View file

@ -50,6 +50,7 @@
@property (nonatomic) IBOutlet UIBarButtonItem * titleImageBarButton;
@property (nonatomic, retain) NBNotifier *notifier;
@property (nonatomic, retain) StoriesCollection *storiesCollection;
@property (nonatomic) UIRefreshControl *refreshControl;
@property (nonatomic) UISearchBar *searchBar;
@property (nonatomic) IBOutlet UIView *messageView;
@property (nonatomic) IBOutlet UILabel *messageLabel;

View file

@ -44,6 +44,8 @@
@property (nonatomic) NSUInteger scrollingMarkReadRow;
@property (nonatomic, readonly) BOOL isMarkReadOnScroll;
@property (nonatomic, readonly) BOOL canPullToRefresh;
@property (readwrite) BOOL inPullToRefresh_;
@property (nonatomic, strong) NSString *restoringFolder;
@property (nonatomic, strong) NSString *restoringFeedID;
@ -104,6 +106,11 @@
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
spacer2BarButton.width = 0;
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.searchBar = [[UISearchBar alloc]
initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.storyTitlesTable.frame), 44.)];
self.searchBar.delegate = self;
@ -402,10 +409,6 @@
} else {
feedMarkReadButton.enabled = YES;
}
if (self.isPhoneOrCompact) {
[self fadeSelectedCell:NO];
}
[self.notifier setNeedsLayout];
[appDelegate hideShareView:YES];
@ -437,8 +440,18 @@
[self.searchBar setShowsCancelButton:NO animated:YES];
}
if (self.canPullToRefresh) {
self.storyTitlesTable.refreshControl = self.refreshControl;
} else {
self.storyTitlesTable.refreshControl = nil;
}
[self updateTheme];
if (self.isPhoneOrCompact) {
[self fadeSelectedCell:NO];
}
if (storiesCollection.activeFeed != nil) {
[appDelegate donateFeed];
} else if (storiesCollection.activeFolder != nil) {
@ -2737,10 +2750,13 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[super updateTheme];
self.navigationController.navigationBar.tintColor = [UINavigationBar appearance].tintColor;
self.navigationController.navigationBar.backItem.backBarButtonItem.tintColor = UIColorFromRGB(0x8F918B);
// self.navigationController.navigationBar.backItem.backBarButtonItem.tintColor = UIColorFromRGB(0x8F918B);
self.navigationController.navigationBar.barTintColor = [UINavigationBar appearance].barTintColor;
self.navigationController.toolbar.barTintColor = [UINavigationBar appearance].barTintColor;
self.refreshControl.tintColor = UIColorFromLightDarkRGB(0x0, 0xffffff);
self.refreshControl.backgroundColor = UIColorFromRGB(0xE3E6E0);
self.searchBar.backgroundColor = UIColorFromRGB(0xE3E6E0);
self.searchBar.tintColor = UIColorFromRGB(0xffffff);
self.searchBar.nb_searchField.textColor = UIColorFromRGB(NEWSBLUR_BLACK_COLOR);
@ -2806,10 +2822,12 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
// [self cancelRequests];
[appDelegate GET:urlString parameters:nil success:^(NSURLSessionTask *task, id responseObject) {
[self renderStories:[responseObject objectForKey:@"stories"]];
[self finishRefresh];
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Fail: %@", error);
[self informError:[operation error]];
[self fetchFeedDetail:1 withCallback:nil];
[self finishRefresh];
}];
[storiesCollection setStories:nil];
@ -2819,6 +2837,32 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[storyTitlesTable scrollRectToVisible:CGRectMake(0, CGRectGetHeight(self.searchBar.frame), 1, 1) animated:YES];
}
#pragma mark -
#pragma mark PullToRefresh
- (BOOL)canPullToRefresh {
BOOL river = appDelegate.storiesCollection.isRiverView;
BOOL infrequent = [self isInfrequent];
BOOL read = appDelegate.storiesCollection.isReadView;
BOOL saved = appDelegate.storiesCollection.isSavedView;
return appDelegate.storiesCollection.activeFeed != nil && !river && !infrequent && !saved && !read;
}
- (void)refresh:(UIRefreshControl *)refreshControl {
if (self.canPullToRefresh) {
self.inPullToRefresh_ = YES;
[self instafetchFeed];
} else {
[self finishRefresh];
}
}
- (void)finishRefresh {
self.inPullToRefresh_ = NO;
[self.refreshControl endRefreshing];
}
#pragma mark -
#pragma mark loadSocial Feeds

View file

@ -2124,6 +2124,10 @@
}
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:edgeURL] options:@{} completionHandler:nil];
} else if ([storyBrowser isEqualToString:@"brave"]){
NSString *encodedURL = [url.absoluteString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *braveURL = [NSString stringWithFormat:@"%@%@", @"brave://open-url?url=", encodedURL];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:braveURL] options:@{} completionHandler:nil];
} else if ([storyBrowser isEqualToString:@"inappsafari"]) {
[self showSafariViewControllerWithURL:url useReader:NO];
} else if ([storyBrowser isEqualToString:@"inappsafarireader"]) {

View file

@ -33,7 +33,6 @@
@interface StoryDetailViewController ()
@property (nonatomic, strong) NSString *fullStoryHTML;
@property (nonatomic) BOOL isBarHideSwiping;
@end
@ -297,8 +296,6 @@
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.navigationController.barHideOnSwipeGestureRecognizer removeTarget:self action:@selector(barHideSwipe:)];
if (!appDelegate.showingSafariViewController &&
appDelegate.navigationController.visibleViewController != (UIViewController *)appDelegate.shareViewController &&
appDelegate.navigationController.visibleViewController != (UIViewController *)appDelegate.trainerViewController &&
@ -320,8 +317,6 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController.barHideOnSwipeGestureRecognizer addTarget:self action:@selector(barHideSwipe:)];
if (!self.isPhoneOrCompact) {
[appDelegate.feedDetailViewController.view endEditing:YES];
}
@ -628,23 +623,17 @@
}
- (void)drawFeedGradient {
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL navigationBarHidden = self.navigationController.navigationBarHidden;
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL shouldOffsetFeedGradient = !self.isBarHideSwiping && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && !UIInterfaceOrientationIsLandscape(orientation) && navigationBarHidden && !shouldHideStatusBar;
CGFloat offset = 0;
if (shouldOffsetFeedGradient) {
offset = appDelegate.storyPageControl.statusBarBackgroundView.bounds.size.height;
}
CGFloat yOffset = offset - 1;
BOOL shouldHideStatusBar = appDelegate.storyPageControl.shouldHideStatusBar;
CGFloat yOffset = -1;
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
[self.activeStory
objectForKey:@"story_feed_id"]];
NSDictionary *feed = [appDelegate getFeed:feedIdStr];
if (appDelegate.storyPageControl.currentlyTogglingNavigationBar && !appDelegate.storyPageControl.isNavigationBarHidden) {
yOffset -= 25;
}
if (self.feedTitleGradient) {
[self.feedTitleGradient removeFromSuperview];
self.feedTitleGradient = nil;
@ -673,11 +662,11 @@
[self.webView insertSubview:feedTitleGradient aboveSubview:self.webView.scrollView];
if (@available(iOS 11.0, *)) {
if (self.view.safeAreaInsets.top > 0.0 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && shouldHideStatusBar) {
feedTitleGradient.alpha = self.navigationController.navigationBarHidden ? 1 : 0;
if (appDelegate.storyPageControl.view.safeAreaInsets.top > 0.0 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && shouldHideStatusBar) {
feedTitleGradient.alpha = appDelegate.storyPageControl.isNavigationBarHidden ? 1 : 0;
[UIView animateWithDuration:0.3 animations:^{
feedTitleGradient.alpha = self.navigationController.navigationBarHidden ? 0 : 1;
feedTitleGradient.alpha = appDelegate.storyPageControl.isNavigationBarHidden ? 0 : 1;
}];
}
}
@ -1339,7 +1328,7 @@
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqual:@"contentOffset"]) {
BOOL isHorizontal = appDelegate.storyPageControl.isHorizontal;
BOOL isNavBarHidden = self.navigationController.navigationBarHidden;
BOOL isNavBarHidden = appDelegate.storyPageControl.isNavigationBarHidden;
if (self.webView.scrollView.contentOffset.y < (-1 * self.feedTitleGradient.frame.size.height + 1 + self.webView.scrollView.scrollIndicatorInsets.top)) {
// Pulling
@ -2237,21 +2226,6 @@
return [super canPerformAction:action withSender:sender];
}
- (void)barHideSwipe:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
self.isBarHideSwiping = NO;
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
if (!shouldHideStatusBar) {
[self drawFeedGradient];
}
} else {
self.isBarHideSwiping = YES;
}
}
# pragma mark -
# pragma mark Subscribing to blurblog

View file

@ -40,6 +40,7 @@
@property (nonatomic) StoryDetailViewController *previousPage;
@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIPageControl *pageControl;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewTopConstraint;
@property (weak, nonatomic) IBOutlet UIView *autoscrollView;
@property (weak, nonatomic) IBOutlet UIImageView *autoscrollBackgroundImageView;
@ -88,6 +89,8 @@
@property (nonatomic, strong) NBNotifier *notifier;
@property (nonatomic) NSInteger scrollingToPage;
@property (nonatomic, strong) id standardInteractivePopGestureDelegate;
@property (nonatomic, readonly) BOOL shouldHideStatusBar;
@property (nonatomic, readonly) BOOL isNavigationBarHidden;
@property (nonatomic, readonly) BOOL allowFullscreen;
@property (nonatomic) BOOL forceNavigationBarShown;
@property (nonatomic) BOOL currentlyTogglingNavigationBar;

View file

@ -28,6 +28,7 @@
@interface StoryPageControl ()
@property (nonatomic) CGFloat statusBarHeight;
@property (nonatomic) BOOL wasNavigationBarHidden;
@property (nonatomic, strong) NSTimer *autoscrollTimer;
@property (nonatomic, strong) NSTimer *autoscrollViewTimer;
@property (nonatomic, strong) NSString *restoringStoryId;
@ -284,6 +285,8 @@
BOOL swipeEnabled = [[userPreferences stringForKey:@"story_detail_swipe_left_edge"]
isEqualToString:@"pop_to_story_list"];;
self.navigationController.hidesBarsOnSwipe = self.allowFullscreen;
[self.navigationController.barHideOnSwipeGestureRecognizer addTarget:self action:@selector(barHideSwipe:)];
self.navigationController.interactivePopGestureRecognizer.enabled = swipeEnabled;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
@ -398,6 +401,8 @@
[super viewDidDisappear:animated];
self.navigationItem.leftBarButtonItem = nil;
[self.navigationController.barHideOnSwipeGestureRecognizer removeTarget:self action:@selector(barHideSwipe:)];
}
- (void)viewWillDisappear:(BOOL)animated {
@ -468,27 +473,38 @@
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
if (self.isNavigationBarHidden && !self.shouldHideStatusBar) {
self.scrollViewTopConstraint.constant = self.statusBarHeight;
} else {
self.scrollViewTopConstraint.constant = 0;
}
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
[self layoutForInterfaceOrientation:orientation];
[self adjustDragBar:orientation];
}
- (void)updateStatusBarState {
- (BOOL)shouldHideStatusBar {
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
BOOL isNavBarHidden = self.navigationController.navigationBarHidden;
self.statusBarBackgroundView.hidden = shouldHideStatusBar || !isNavBarHidden || !appDelegate.isPortrait;
return [preferences boolForKey:@"story_hide_status_bar"];
}
- (BOOL)isNavigationBarHidden {
return self.navigationController.navigationBarHidden;
}
- (void)updateStatusBarState {
BOOL isNavBarHidden = self.isNavigationBarHidden;
self.statusBarBackgroundView.hidden = self.shouldHideStatusBar || !isNavBarHidden || !appDelegate.isPortrait;
}
- (BOOL)prefersStatusBarHidden {
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
BOOL isNavBarHidden = self.navigationController.navigationBarHidden;
[self updateStatusBarState];
return shouldHideStatusBar && isNavBarHidden;
return self.shouldHideStatusBar && self.isNavigationBarHidden;
}
- (BOOL)allowFullscreen {
@ -511,6 +527,7 @@
}
self.currentlyTogglingNavigationBar = YES;
self.wasNavigationBarHidden = hide;
[self.navigationController setNavigationBarHidden:hide animated:YES];
@ -640,6 +657,22 @@
return [[[NSUserDefaults standardUserDefaults] objectForKey:@"scroll_stories_horizontally"] boolValue];
}
- (void)barHideSwipe:(UIPanGestureRecognizer *)recognizer {
BOOL isBarHidden = self.isNavigationBarHidden;
if (recognizer.state == UIGestureRecognizerStateEnded && isBarHidden != self.wasNavigationBarHidden) {
self.wasNavigationBarHidden = isBarHidden;
if (!appDelegate.storyPageControl.shouldHideStatusBar) {
[currentPage drawFeedGradient];
}
if (!self.isHorizontal) {
[self reorientPages];
}
}
}
- (void)resetPages {
self.navigationItem.titleView = nil;
@ -890,6 +923,11 @@
}
pageFrame.size.height = CGRectGetHeight(self.scrollView.bounds);
pageFrame.size.width = CGRectGetWidth(self.scrollView.bounds);
if (self.currentlyTogglingNavigationBar && !self.isNavigationBarHidden) {
pageFrame.size.height -= 20.0;
}
pageController.view.hidden = NO;
pageController.view.frame = pageFrame;
} else {
@ -1697,8 +1735,8 @@
- (void)tappedStory {
if (self.autoscrollAvailable) {
[self showAutoscrollBriefly:YES];
} else {
[self setNavigationBarHidden: !self.navigationController.navigationBarHidden];
} else if (self.allowFullscreen) {
[self setNavigationBarHidden: !self.isNavigationBarHidden];
}
}

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -28,6 +28,7 @@
<outlet property="prevNextBackgroundImageView" destination="71" id="S3e-tC-Pbu"/>
<outlet property="scrollBottomConstraint" destination="AOS-qV-fjZ" id="JD4-zE-OTv"/>
<outlet property="scrollView" destination="5" id="15"/>
<outlet property="scrollViewTopConstraint" destination="sgh-qa-2V3" id="Z8v-Gi-IqF"/>
<outlet property="textStorySendBackgroundImageView" destination="80" id="1hz-Zr-85e"/>
<outlet property="traverseBottomConstraint" destination="rgF-mh-lia" id="ucW-KZ-fN6"/>
<outlet property="traverseView" destination="75" id="76"/>

View file

@ -2799,7 +2799,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1120;
LastUpgradeCheck = 1150;
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = NewsBlur;
TargetAttributes = {
1749390F1C251BFE003D98AA = {

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1160"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1160"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1160"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1160"
wasCreatedForAppExtension = "YES"
version = "1.3">
<BuildAction

View file

@ -737,6 +737,7 @@
<string>Opera Mini</string>
<string>Firefox</string>
<string>Edge</string>
<string>Brave</string>
</array>
<key>DefaultValue</key>
<string>inappsafari</string>
@ -750,6 +751,7 @@
<string>opera_mini</string>
<string>firefox</string>
<string>edge</string>
<string>brave</string>
</array>
<key>Key</key>
<string>story_browser</string>

View file

@ -757,6 +757,7 @@
<string>Opera Mini</string>
<string>Firefox</string>
<string>Edge</string>
<string>Brave</string>
</array>
<key>DefaultValue</key>
<string>inappsafari</string>
@ -770,6 +771,7 @@
<string>opera_mini</string>
<string>firefox</string>
<string>edge</string>
<string>brave</string>
</array>
<key>Key</key>
<string>story_browser</string>