#1238 (statistics)

- Added Statistics to the preferences for the left swipe in the feeds list.
- A bit of refactoring to support displaying the popover from a cell on iPad.
This commit is contained in:
David Sinclair 2020-01-31 15:50:03 -08:00
parent 617ec8e45c
commit ed30ad75e2
7 changed files with 54 additions and 23 deletions

View file

@ -2500,11 +2500,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
}
- (void)openStatisticsWithFeed:(NSString *)feedId {
NSString *urlString = [NSString stringWithFormat:@"%@/rss_feeds/statistics_embedded/%@", appDelegate.url, feedId];
NSURL *url = [NSURL URLWithString:urlString];
NSString *title = appDelegate.storiesCollection.activeFeed[@"feed_title"];
[appDelegate showInAppBrowser:url withCustomTitle:title fromBarButtonItem:settingsBarButton];
[appDelegate openStatisticsWithFeed:feedId sender:settingsBarButton];
}
- (void)openRenameSite {

View file

@ -90,12 +90,21 @@ static UIFont *textFont = nil;
}
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL isNotifications = [[preferences stringForKey:@"feed_swipe_left"]
isEqualToString:@"notifications"];
NSString *swipe = [preferences stringForKey:@"feed_swipe_left"];
NSString *iconName;
if (self.isSocial) {
iconName = @"menu_icn_fetch_subscribers.png";
} else if ([swipe isEqualToString:@"notifications"]) {
iconName = @"menu_icn_notifications.png";
} else if ([swipe isEqualToString:@"statistics"]) {
iconName = @"menu_icn_statistics.png";
} else {
iconName = @"train.png";
}
[self setDelegate:(NewsBlurViewController <MCSwipeTableViewCellDelegate> *)appDelegate.feedsViewController];
[self setFirstStateIconName:(self.isSocial ? @"menu_icn_fetch_subscribers.png" :
isNotifications ? @"menu_icn_notifications.png" :
@"train.png")
[self setFirstStateIconName:(iconName)
firstColor:UIColorFromRGB(0xA4D97B)
secondStateIconName:nil
secondColor:nil

View file

@ -321,6 +321,7 @@ SFSafariViewControllerDelegate> {
- (void)openNotificationsWithFeed:(NSString *)feedId sender:(id)sender;
- (void)updateNotifications:(NSDictionary *)params feed:(NSString *)feedId;
- (void)checkForFeedNotifications;
- (void)openStatisticsWithFeed:(NSString *)feedId sender:(id)sender;
- (void)openTrainSiteWithFeedLoaded:(BOOL)feedLoaded from:(id)sender;
- (void)openTrainStory:(id)sender;
- (void)openUserTagsStory:(id)sender;
@ -357,7 +358,7 @@ SFSafariViewControllerDelegate> {
- (void)reloadFeedsView:(BOOL)showLoader;
- (void)setTitle:(NSString *)title;
- (void)showOriginalStory:(NSURL *)url;
- (void)showInAppBrowser:(NSURL *)url withCustomTitle:(NSString *)customTitle fromBarButtonItem:(UIBarButtonItem *)barButtonItem;
- (void)showInAppBrowser:(NSURL *)url withCustomTitle:(NSString *)customTitle fromSender:(id)sender;
- (void)showSafariViewControllerWithURL:(NSURL *)url useReader:(BOOL)useReader;
- (void)closeOriginalStory;
- (void)hideStoryDetailView;

View file

@ -1272,6 +1272,15 @@
}];
}
- (void)openStatisticsWithFeed:(NSString *)feedId sender:(id)sender {
NSString *urlString = [NSString stringWithFormat:@"%@/rss_feeds/statistics_embedded/%@", self.url, feedId];
NSURL *url = [NSURL URLWithString:urlString];
NSDictionary *feed = self.dictFeeds[feedId];
NSString *title = feed[@"feed_title"];
[self showInAppBrowser:url withCustomTitle:title fromSender:sender];
}
- (void)openUserTagsStory:(id)sender {
if (!self.userTagsViewController) {
self.userTagsViewController = [[UserTagsViewController alloc] init];
@ -2066,11 +2075,11 @@
} else if ([storyBrowser isEqualToString:@"inappsafarireader"]) {
[self showSafariViewControllerWithURL:url useReader:YES];
} else {
[self showInAppBrowser:url withCustomTitle:nil fromBarButtonItem:nil];
[self showInAppBrowser:url withCustomTitle:nil fromSender:nil];
}
}
- (void)showInAppBrowser:(NSURL *)url withCustomTitle:(NSString *)customTitle fromBarButtonItem:(UIBarButtonItem *)barButtonItem {
- (void)showInAppBrowser:(NSURL *)url withCustomTitle:(NSString *)customTitle fromSender:(id)sender {
if (!originalStoryViewController) {
originalStoryViewController = [[OriginalStoryViewController alloc] init];
}
@ -2079,10 +2088,16 @@
originalStoryViewController.customPageTitle = customTitle;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if (barButtonItem) {
if ([sender isKindOfClass:[UIBarButtonItem class]]) {
[originalStoryViewController view]; // Force viewDidLoad
[originalStoryViewController loadInitialStory];
[self showPopoverWithViewController:originalStoryViewController contentSize:CGSizeMake(600.0, 1000.0) barButtonItem:barButtonItem];
[self showPopoverWithViewController:originalStoryViewController contentSize:CGSizeMake(600.0, 1000.0) barButtonItem:sender];
} else if ([sender isKindOfClass:[UITableViewCell class]]) {
UITableViewCell *cell = (UITableViewCell *)sender;
[originalStoryViewController view]; // Force viewDidLoad
[originalStoryViewController loadInitialStory];
[self showPopoverWithViewController:originalStoryViewController contentSize:CGSizeMake(600.0, 1000.0) sourceView:cell sourceRect:cell.bounds];
} else {
[self.masterContainerViewController transitionToOriginalView];
}

View file

@ -1553,12 +1553,18 @@ heightForHeaderInSection:(NSInteger)section {
appDelegate.activeUserProfileId = [NSString stringWithFormat:@"%@", [feed objectForKey:@"user_id"]];
appDelegate.activeUserProfileName = [NSString stringWithFormat:@"%@", [feed objectForKey:@"username"]];
[appDelegate showUserProfileModal:cell];
} else if ([[preferences stringForKey:@"feed_swipe_left"] isEqualToString:@"notifications"]) {
[appDelegate openNotificationsWithFeed:feedId sender:cell];
} else {
// Train
appDelegate.storiesCollection.activeFeed = [appDelegate.dictFeeds objectForKey:feedId];
[appDelegate openTrainSiteWithFeedLoaded:NO from:cell];
NSString *swipe = [preferences stringForKey:@"feed_swipe_left"];
if ([swipe isEqualToString:@"notifications"]) {
[appDelegate openNotificationsWithFeed:feedId sender:cell];
} else if ([swipe isEqualToString:@"statistics"]) {
[appDelegate openStatisticsWithFeed:feedId sender:cell];
} else {
// Train
appDelegate.storiesCollection.activeFeed = [appDelegate.dictFeeds objectForKey:feedId];
[appDelegate openTrainSiteWithFeedLoaded:NO from:cell];
}
}
} else if (state == MCSwipeTableViewCellState3) {
// Mark read

View file

@ -672,14 +672,16 @@
<key>Titles</key>
<array>
<string>Train intelligence</string>
<string>Notifications</string>
<string>Notifications</string>
<string>Statistics</string>
</array>
<key>DefaultValue</key>
<string>notifications</string>
<key>Values</key>
<array>
<string>trainer</string>
<string>notifications</string>
<string>notifications</string>
<string>statistics</string>
</array>
<key>Key</key>
<string>feed_swipe_left</string>

View file

@ -693,13 +693,15 @@
<array>
<string>Train intelligence</string>
<string>Notifications</string>
<string>Statistics</string>
</array>
<key>DefaultValue</key>
<string>notifications</string>
<key>Values</key>
<array>
<string>trainer</string>
<string>notifications</string>
<string>notifications</string>
<string>statistics</string>
</array>
<key>Key</key>
<string>feed_swipe_left</string>