Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm

Issue 2751833005: Add Distillation info to Reading List view. (Closed)
Patch Set: fix test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm
index 0e88517c87dff8fab7ce7d6d3e19a27f7eac1d28..c869899832370f093ca2b9110579eb5410fd4c0c 100644
--- a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm
+++ b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm
@@ -53,10 +53,8 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
};
typedef NS_ENUM(NSInteger, ItemType) {
- ItemTypeUnreadHeader = kItemTypeEnumZero,
- ItemTypeUnread,
- ItemTypeReadHeader,
- ItemTypeRead,
+ ItemTypeHeader = kItemTypeEnumZero,
+ ItemTypeItem,
};
// Typedef for a block taking a GURL as parameter and returning nothing.
@@ -319,7 +317,7 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>;
- (CGFloat)collectionView:(UICollectionView*)collectionView
cellHeightAtIndexPath:(NSIndexPath*)indexPath {
NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
- if (type == ItemTypeUnread || type == ItemTypeRead)
+ if (type == ItemTypeItem)
return MDCCellDefaultTwoLineHeight;
else
return MDCCellDefaultOneLineHeight;
@@ -593,9 +591,11 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>;
ReadingListCollectionViewItem* newItem = iterator->second;
if (oldItem.url == newItem.url) {
if (![oldItem isEqual:newItem]) {
- oldItem.text = newItem.text;
- oldItem.detailText = newItem.detailText;
+ oldItem.title = newItem.title;
+ oldItem.subtitle = newItem.subtitle;
oldItem.distillationState = newItem.distillationState;
+ oldItem.distillationDate = newItem.distillationDate;
+ oldItem.distillationSize = newItem.distillationSize;
[itemsToReconfigure addObject:oldItem];
}
if (oldItem.faviconPageURL != newItem.faviconPageURL) {
@@ -616,20 +616,27 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>;
(const ReadingListEntry&)entry {
GURL url = entry.URL();
ReadingListCollectionViewItem* item = [[ReadingListCollectionViewItem alloc]
- initWithType:entry.IsRead() ? ItemTypeRead : ItemTypeUnread
- url:url
- distillationState:entry.DistilledState()];
+ initWithType:ItemTypeItem
+ url:url
+ distillationState:entry.DistilledState()];
[self setItem:item
faviconURL:entry.DistilledURL().is_valid() ? entry.DistilledURL() : url];
+ BOOL has_distillation_details =
+ entry.DistilledState() == ReadingListEntry::PROCESSED &&
+ entry.DistillationSize() != 0 && entry.DistillationTime() != 0;
NSString* fullUrlString =
base::SysUTF16ToNSString(url_formatter::FormatUrl(url));
NSString* urlString =
base::SysUTF16ToNSString(url_formatter::FormatUrl(url.GetOrigin()));
NSString* title = base::SysUTF8ToNSString(entry.Title());
- item.text = [title length] ? title : fullUrlString;
- item.detailText = urlString;
+ item.title = [title length] ? title : fullUrlString;
+ item.subtitle = urlString;
+ item.distillationDate =
+ has_distillation_details ? entry.DistillationTime() : 0;
+ item.distillationSize =
+ has_distillation_details ? entry.DistillationSize() : 0;
return item;
}
@@ -1165,17 +1172,14 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>;
- (CollectionViewTextItem*)headerForSection:
(SectionIdentifier)sectionIdentifier {
- CollectionViewTextItem* header = nil;
+ CollectionViewTextItem* header =
+ [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader];
switch (sectionIdentifier) {
case SectionIdentifierRead:
- header = [[CollectionViewTextItem alloc] initWithType:ItemTypeReadHeader];
header.text = l10n_util::GetNSString(IDS_IOS_READING_LIST_READ_HEADER);
break;
-
case SectionIdentifierUnread:
- header =
- [[CollectionViewTextItem alloc] initWithType:ItemTypeUnreadHeader];
header.text = l10n_util::GetNSString(IDS_IOS_READING_LIST_UNREAD_HEADER);
break;
}

Powered by Google App Engine
This is Rietveld 408576698