mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Major improvements to activities/interactions. Adding saved story cells. Fixing loading/finding story HUDs for both ipad and iphone.
This commit is contained in:
parent
3dd75dd8c8
commit
a641bfdff8
8 changed files with 69 additions and 64 deletions
|
@ -66,6 +66,7 @@
|
|||
// must set the height again for dynamic height in heightForRowAtIndexPath in
|
||||
CGRect activityLabelRect = self.activityLabel.bounds;
|
||||
activityLabelRect.size.width = width - leftMargin - avatarSize - leftMargin - rightMargin;
|
||||
|
||||
self.activityLabel.frame = activityLabelRect;
|
||||
self.activityLabel.numberOfLines = 0;
|
||||
self.faviconView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
|
||||
|
@ -168,11 +169,14 @@
|
|||
|
||||
NSRange commentRange = [txtWithTime rangeOfString:comment];
|
||||
if (commentRange.location != NSNotFound) {
|
||||
NSLog(@"Spacing: %@", comment);
|
||||
commentRange.location -= 2;
|
||||
commentRange.length = 1;
|
||||
[attrStr addAttribute:NSFontAttributeName
|
||||
value:[UIFont systemFontOfSize:4.0f]
|
||||
range:commentRange];
|
||||
if ([[txtWithTime substringWithRange:commentRange] isEqualToString:@" "]) {
|
||||
[attrStr addAttribute:NSFontAttributeName
|
||||
value:[UIFont systemFontOfSize:4.0f]
|
||||
range:commentRange];
|
||||
}
|
||||
}
|
||||
|
||||
NSRange dateRange = [txtWithTime rangeOfString:time];
|
||||
|
@ -189,7 +193,7 @@
|
|||
|
||||
int height = self.activityLabel.frame.size.height;
|
||||
|
||||
return MAX(height, self.faviconView.frame.size.height);
|
||||
return MAX(height + topMargin + bottomMargin, self.faviconView.frame.size.height);
|
||||
}
|
||||
|
||||
- (NSString *)stripFormatting:(NSString *)str {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
@synthesize activitiesPage;
|
||||
|
||||
#define MINIMUM_ACTIVITY_HEIGHT_IPAD 78
|
||||
#define MINIMUM_ACTIVITY_HEIGHT_IPHONE 48
|
||||
#define MINIMUM_ACTIVITY_HEIGHT_IPHONE 54
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
|
@ -194,7 +194,7 @@
|
|||
int height = [activityCell setActivity:[appDelegate.userActivitiesArray
|
||||
objectAtIndex:(indexPath.row)]
|
||||
withUserProfile:userProfile
|
||||
withWidth:self.frame.size.width - 20] + 30;
|
||||
withWidth:self.frame.size.width - 20];
|
||||
|
||||
return height;
|
||||
|
||||
|
@ -228,8 +228,7 @@
|
|||
NSString *category = [activitiy objectForKey:@"category"];
|
||||
if ([category isEqualToString:@"follow"]) {
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
} else if ([category isEqualToString:@"star"] ||
|
||||
[category isEqualToString:@"signup"]){
|
||||
} else if ([category isEqualToString:@"signup"]){
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
} else {
|
||||
|
@ -288,6 +287,12 @@
|
|||
withUser:[activity objectForKey:@"with_user"]
|
||||
showFindingStory:YES];
|
||||
appDelegate.tryFeedCategory = category;
|
||||
} else if ([category isEqualToString:@"star"]) {
|
||||
NSString *contentIdStr = [NSString stringWithFormat:@"%@",
|
||||
[activity objectForKey:@"content_id"]];
|
||||
[appDelegate loadStarredDetailViewWithStory:contentIdStr
|
||||
showFindingStory:YES];
|
||||
appDelegate.tryFeedCategory = category;
|
||||
} else if ([category isEqualToString:@"feedsub"]) {
|
||||
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
|
||||
[activity objectForKey:@"feed_id"]];
|
||||
|
|
|
@ -787,6 +787,7 @@
|
|||
FeedDetailTableCell *cell = (FeedDetailTableCell *)[self.storyTitlesTable cellForRowAtIndexPath:indexPath];
|
||||
[self loadStory:cell atRow:indexPath.row];
|
||||
|
||||
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
||||
// found the story, reset the two flags.
|
||||
// appDelegate.tryFeedStoryId = nil;
|
||||
appDelegate.inFindingStoryMode = NO;
|
||||
|
@ -1070,48 +1071,7 @@
|
|||
[appDelegate calculateStoryLocations];
|
||||
}
|
||||
|
||||
for (int i=0; i < appDelegate.storyLocationsCount; i++) {
|
||||
int location = [[[appDelegate activeFeedStoryLocations] objectAtIndex:i] intValue];
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||||
NSDictionary *story = [appDelegate.activeFeedStories objectAtIndex:location];
|
||||
int score = [NewsBlurAppDelegate computeStoryScore:[story objectForKey:@"intelligence"]];
|
||||
|
||||
if (previousLevel == -1) {
|
||||
if (newLevel == 0 && score == -1) {
|
||||
[deleteIndexPaths addObject:indexPath];
|
||||
} else if (newLevel == 1 && score < 1) {
|
||||
[deleteIndexPaths addObject:indexPath];
|
||||
}
|
||||
} else if (previousLevel == 0) {
|
||||
if (newLevel == -1 && score == -1) {
|
||||
[insertIndexPaths addObject:indexPath];
|
||||
} else if (newLevel == 1 && score == 0) {
|
||||
[deleteIndexPaths addObject:indexPath];
|
||||
}
|
||||
} else if (previousLevel == 1) {
|
||||
if (newLevel == 0 && score == 0) {
|
||||
[insertIndexPaths addObject:indexPath];
|
||||
} else if (newLevel == -1 && score < 1) {
|
||||
[insertIndexPaths addObject:indexPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newLevel > previousLevel) {
|
||||
[appDelegate setSelectedIntelligence:newLevel];
|
||||
[appDelegate calculateStoryLocations];
|
||||
}
|
||||
|
||||
[self.storyTitlesTable beginUpdates];
|
||||
if ([deleteIndexPaths count] > 0) {
|
||||
[self.storyTitlesTable deleteRowsAtIndexPaths:deleteIndexPaths
|
||||
withRowAnimation:UITableViewRowAnimationNone];
|
||||
}
|
||||
if ([insertIndexPaths count] > 0) {
|
||||
[self.storyTitlesTable insertRowsAtIndexPaths:insertIndexPaths
|
||||
withRowAnimation:UITableViewRowAnimationNone];
|
||||
}
|
||||
[self.storyTitlesTable endUpdates];
|
||||
[self.storyTitlesTable reloadData];
|
||||
}
|
||||
|
||||
- (NSDictionary *)getStoryAtRow:(NSInteger)indexPathRow {
|
||||
|
|
|
@ -75,9 +75,8 @@
|
|||
interactionLabelRect.size.height = 300;
|
||||
|
||||
self.interactionLabel.frame = interactionLabelRect;
|
||||
self.avatarView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
|
||||
self.interactionLabel.numberOfLines = 0;
|
||||
// UIImage *placeholder = [UIImage imageNamed:@"user_light"];
|
||||
self.avatarView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
|
||||
|
||||
// this is for the rare instance when the with_user doesn't return anything
|
||||
if ([[interaction objectForKey:@"with_user"] class] == [NSNull class]) {
|
||||
|
@ -142,9 +141,11 @@
|
|||
if (commentRange.location != NSNotFound) {
|
||||
commentRange.location -= 2;
|
||||
commentRange.length = 1;
|
||||
[attrStr addAttribute:NSFontAttributeName
|
||||
value:[UIFont systemFontOfSize:4.0f]
|
||||
range:commentRange];
|
||||
if ([[txtWithTime substringWithRange:commentRange] isEqualToString:@" "]) {
|
||||
[attrStr addAttribute:NSFontAttributeName
|
||||
value:[UIFont systemFontOfSize:6.0f]
|
||||
range:commentRange];
|
||||
}
|
||||
}
|
||||
|
||||
NSRange dateRange = [txtWithTime rangeOfString:time];
|
||||
|
@ -152,18 +153,16 @@
|
|||
dateRange.location -= 2;
|
||||
dateRange.length = 1;
|
||||
[attrStr addAttribute:NSFontAttributeName
|
||||
value:[UIFont systemFontOfSize:4.0f]
|
||||
value:[UIFont systemFontOfSize:6.0f]
|
||||
range:dateRange];
|
||||
}
|
||||
|
||||
self.interactionLabel.attributedText = attrStr;
|
||||
NSLog(@"Frame: %@", NSStringFromCGRect(self.interactionLabel.frame));
|
||||
[self.interactionLabel sizeToFit];
|
||||
NSLog(@"Frame after: %@", NSStringFromCGRect(self.interactionLabel.frame));
|
||||
|
||||
int height = self.interactionLabel.frame.size.height;
|
||||
|
||||
return height;
|
||||
return height + topMargin + bottomMargin;
|
||||
}
|
||||
|
||||
- (NSString *)stripFormatting:(NSString *)str {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#import "UserProfileViewController.h"
|
||||
|
||||
#define MINIMUM_INTERACTION_HEIGHT_IPAD 78
|
||||
#define MINIMUM_INTERACTION_HEIGHT_IPHONE 48
|
||||
#define MINIMUM_INTERACTION_HEIGHT_IPHONE 54
|
||||
|
||||
@implementation InteractionsModule
|
||||
|
||||
|
@ -193,7 +193,7 @@
|
|||
} else {
|
||||
interactionCell = [[SmallInteractionCell alloc] init];
|
||||
}
|
||||
int height = [interactionCell setInteraction:[appDelegate.userInteractionsArray objectAtIndex:(indexPath.row)] withWidth:self.frame.size.width - 20] + 30;
|
||||
int height = [interactionCell setInteraction:[appDelegate.userInteractionsArray objectAtIndex:(indexPath.row)] withWidth:self.frame.size.width - 20];
|
||||
if (height < minimumHeight) {
|
||||
return minimumHeight;
|
||||
} else {
|
||||
|
|
|
@ -270,6 +270,7 @@
|
|||
- (void)openTrainStory:(id)sender;
|
||||
- (void)loadFeedDetailView;
|
||||
- (void)loadTryFeedDetailView:(NSString *)feedId withStory:(NSString *)contentId isSocial:(BOOL)social withUser:(NSDictionary *)user showFindingStory:(BOOL)showHUD;
|
||||
- (void)loadStarredDetailViewWithStory:(NSString *)contentId showFindingStory:(BOOL)showHUD;
|
||||
- (void)loadRiverFeedDetailView;
|
||||
- (void)loadStoryDetailView;
|
||||
- (void)adjustStoryDetailWebView;
|
||||
|
|
|
@ -676,7 +676,43 @@
|
|||
[self loadFeedDetailView];
|
||||
|
||||
if (showHUD) {
|
||||
[self.storyPageControl showShareHUD:@"Finding story..."];
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[self.storyPageControl showShareHUD:@"Finding story..."];
|
||||
} else {
|
||||
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.feedDetailViewController.view animated:YES];
|
||||
HUD.labelText = @"Finding story...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadStarredDetailViewWithStory:(NSString *)contentId
|
||||
showFindingStory:(BOOL)showHUD {
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
if (self.feedsViewController.popoverController) {
|
||||
[self.feedsViewController.popoverController dismissPopoverAnimated:NO];
|
||||
}
|
||||
}
|
||||
|
||||
self.isSocialRiverView = NO;
|
||||
self.isRiverView = YES;
|
||||
self.inFindingStoryMode = YES;
|
||||
self.isSocialView = NO;
|
||||
|
||||
self.tryFeedStoryId = contentId;
|
||||
self.activeFeed = nil;
|
||||
self.activeFolder = @"saved_stories";
|
||||
|
||||
[self loadRiverFeedDetailView];
|
||||
|
||||
if (showHUD) {
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[self.storyPageControl showShareHUD:@"Finding story..."];
|
||||
} else {
|
||||
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.feedDetailViewController.view animated:YES];
|
||||
HUD.labelText = @"Finding story...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -968,6 +1004,7 @@
|
|||
navController.navigationItem.hidesBackButton = YES;
|
||||
}
|
||||
|
||||
[MBProgressHUD hideHUDForView:self.storyPageControl.view animated:YES];
|
||||
}
|
||||
|
||||
- (void)navigationController:(UINavigationController *)navController
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
[self.contentView addSubview:interaction];
|
||||
|
||||
topMargin = 10;
|
||||
bottomMargin = 0;
|
||||
bottomMargin = 10;
|
||||
leftMargin = 10;
|
||||
rightMargin = 10;
|
||||
avatarSize = 32;
|
||||
|
@ -48,7 +48,6 @@
|
|||
self.avatarView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
|
||||
|
||||
// position label to bounds
|
||||
NSLog(@"Frame of cell: %@ / %@", NSStringFromCGRect(contentRect), NSStringFromCGRect(self.interactionLabel.frame));
|
||||
CGRect labelRect = contentRect;
|
||||
labelRect.origin.x = labelRect.origin.x + leftMargin + avatarSize + leftMargin;
|
||||
labelRect.origin.y = labelRect.origin.y + topMargin - 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue