diff --git a/clients/ios/Classes/NewsBlurAppDelegate.h b/clients/ios/Classes/NewsBlurAppDelegate.h index 3373aa315..2a8918e5b 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.h +++ b/clients/ios/Classes/NewsBlurAppDelegate.h @@ -421,6 +421,7 @@ SFSafariViewControllerDelegate> { - (NSString *)extractFolderName:(NSString *)folderName; - (NSString *)extractParentFolderName:(NSString *)folderName; - (NSArray *)parentFoldersForFeed:(NSString *)feedId; +- (NSDictionary *)getFeedWithId:(id)feedId; - (NSDictionary *)getFeed:(NSString *)feedId; - (NSDictionary *)getStory:(NSString *)storyHash; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index 0d427e8c9..721fbd2f9 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -3001,6 +3001,12 @@ return uniqueFolderNames; } +- (NSDictionary *)getFeedWithId:(id)feedId { + NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId]; + + return [self getFeed:feedIdStr]; +} + - (NSDictionary *)getFeed:(NSString *)feedId { NSDictionary *feed; if (storiesCollection.isSocialView || diff --git a/clients/ios/Classes/NewsBlurViewController.m b/clients/ios/Classes/NewsBlurViewController.m index 75d8dbb8c..c05564bd3 100644 --- a/clients/ios/Classes/NewsBlurViewController.m +++ b/clients/ios/Classes/NewsBlurViewController.m @@ -723,6 +723,17 @@ static NSArray *NewsBlurTopSectionNames; [appDelegate populateDictUnreadCounts]; [appDelegate populateDictTextFeeds]; + NSString *sortOrder = [userPreferences stringForKey:@"feed_list_sort_order"]; + BOOL sortByMostUsed = [sortOrder isEqualToString:@"usage"]; + + NSMutableArray *sortDescriptors = [NSMutableArray array]; + + if (sortByMostUsed) { + [sortDescriptors addObject:[NSSortDescriptor sortDescriptorWithKey:@"feed_opens" ascending:NO]]; + } + + [sortDescriptors addObject:[NSSortDescriptor sortDescriptorWithKey:@"feed_title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]]; + // sort all the folders appDelegate.dictFoldersArray = [NSMutableArray array]; for (id f in appDelegate.dictFolders) { @@ -734,27 +745,30 @@ static NSArray *NewsBlurTopSectionNames; folderTitle = f; } [appDelegate.dictFoldersArray addObject:folderTitle]; - sortedArray = [folder sortedArrayUsingComparator:^NSComparisonResult(id id1, id id2) { - NSString *feedTitleA; - NSString *feedTitleB; + + NSMutableArray *feeds = [NSMutableArray array]; + + for (id feedId in folder) { + NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId]; + NSDictionary *feed; - if ([appDelegate isSocialFeed:[NSString stringWithFormat:@"%@", id1]]) { - feedTitleA = [[appDelegate.dictSocialFeeds - objectForKey:[NSString stringWithFormat:@"%@", id1]] - objectForKey:@"feed_title"]; - feedTitleB = [[appDelegate.dictSocialFeeds - objectForKey:[NSString stringWithFormat:@"%@", id2]] - objectForKey:@"feed_title"]; + if ([appDelegate isSavedFeed:feedIdStr]) { + feed = @{@"id" : feedId}; + } else if ([appDelegate isSocialFeed:feedIdStr]) { + feed = appDelegate.dictSocialFeeds[feedIdStr]; } else { - feedTitleA = [[appDelegate.dictFeeds - objectForKey:[NSString stringWithFormat:@"%@", id1]] - objectForKey:@"feed_title"]; - feedTitleB = [[appDelegate.dictFeeds - objectForKey:[NSString stringWithFormat:@"%@", id2]] - objectForKey:@"feed_title"]; + feed = appDelegate.dictFeeds[feedIdStr]; } - return [feedTitleA caseInsensitiveCompare:feedTitleB]; - }]; + + if (feed != nil) { + [feeds addObject:feed]; + } + } + + NSArray *sortedFeeds = [feeds sortedArrayUsingDescriptors:sortDescriptors]; + + sortedArray = [sortedFeeds valueForKey:@"id"]; + [sortedFolders setValue:sortedArray forKey:folderTitle]; } appDelegate.dictFolders = sortedFolders; diff --git a/clients/ios/Resources/Settings.bundle/Root.plist b/clients/ios/Resources/Settings.bundle/Root.plist index c87ff2430..550d5c70b 100644 --- a/clients/ios/Resources/Settings.bundle/Root.plist +++ b/clients/ios/Resources/Settings.bundle/Root.plist @@ -204,6 +204,26 @@ Type PSGroupSpecifier + + Type + PSMultiValueSpecifier + Title + Feed list order + Titles + + Alphabetical + Most used then alphabetical + + DefaultValue + title + Values + + title + usage + + Key + feed_list_sort_order + Type PSToggleSwitchSpecifier diff --git a/clients/ios/Resources/Settings.bundle/Root~ipad.plist b/clients/ios/Resources/Settings.bundle/Root~ipad.plist index 3f5f680a2..dfacef92e 100644 --- a/clients/ios/Resources/Settings.bundle/Root~ipad.plist +++ b/clients/ios/Resources/Settings.bundle/Root~ipad.plist @@ -224,6 +224,26 @@ Type PSGroupSpecifier + + Type + PSMultiValueSpecifier + Title + Feed list order + Titles + + Alphabetical + Most used then alphabetical + + DefaultValue + title + Values + + title + usage + + Key + feed_list_sort_order + Type PSToggleSwitchSpecifier