Chromium Code Reviews| Index: ui/message_center/views/notification_view_md.cc |
| diff --git a/ui/message_center/views/notification_view_md.cc b/ui/message_center/views/notification_view_md.cc |
| index 2f9e2c54fd3867cc1128fe72d7664471bc5c9b29..7ed206b2c98873c5e7cf7d9172c33c2d65817b27 100644 |
| --- a/ui/message_center/views/notification_view_md.cc |
| +++ b/ui/message_center/views/notification_view_md.cc |
| @@ -72,7 +72,6 @@ const SkColor kActionButtonTextColor = SkColorSetRGB(0x33, 0x67, 0xD6); |
| constexpr int kMaxLinesForMessageView = 1; |
| constexpr int kMaxLinesForExpandedMessageView = 4; |
| -constexpr int kListNotificationOverflowIndicatorSpacing = 4; |
| constexpr int kCompactTitleMessageViewSpacing = 12; |
| constexpr int kProgressBarHeight = 4; |
| @@ -117,85 +116,31 @@ class ItemView : public views::View { |
| explicit ItemView(const message_center::NotificationItem& item); |
| ~ItemView() override; |
| - void SetRemainingCount(int num_remaining); |
| - void SetRemainingCountVisible(bool visible); |
| - |
| private: |
| - class LayoutManager : public views::FillLayout { |
| - public: |
| - LayoutManager(ItemView* item_view) |
| - : views::FillLayout(), item_view_(item_view) {} |
| - |
| - void Layout(View* host) override { |
| - gfx::Rect container_bounds = host->GetContentsBounds(); |
| - if (item_view_->remaining_count_->visible()) { |
| - // Show the full content of the overflow indicator and collapse the |
| - // message container. |
| - container_bounds.set_width( |
| - container_bounds.width() - |
| - item_view_->remaining_count_->GetPreferredSize().width() - |
| - kListNotificationOverflowIndicatorSpacing); |
| - } |
| - item_view_->container_->SetBoundsRect(container_bounds); |
| - item_view_->remaining_count_->SetBoundsRect(host->GetContentsBounds()); |
| - } |
| - |
| - private: |
| - ItemView* item_view_; |
| - }; |
| - |
| - // Container of the title and the message. |
| - views::View* container_; |
| - // Overflow indicator e.g. "+3" shown on the right bottom. |
| - views::Label* remaining_count_; |
| - |
| DISALLOW_COPY_AND_ASSIGN(ItemView); |
| }; |
| ItemView::ItemView(const message_center::NotificationItem& item) { |
| - SetLayoutManager(new ItemView::LayoutManager(this)); |
| - |
| - container_ = new views::View; |
| - AddChildView(container_); |
| - container_->SetLayoutManager( |
| - new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(), |
| - message_center::kItemTitleToMessagePadding)); |
| + SetLayoutManager( |
| + new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(), 0)); |
| views::Label* title = new views::Label(item.title); |
| title->set_collapse_when_hidden(true); |
| title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| title->SetEnabledColor(message_center::kRegularTextColor); |
| title->SetBackgroundColor(message_center::kDimTextBackgroundColor); |
| - container_->AddChildView(title); |
| + AddChildView(title); |
| - views::Label* message = new views::Label(item.message); |
| + views::Label* message = new views::Label(l10n_util::GetStringFUTF16( |
| + IDS_MESSAGE_CENTER_LIST_NOTIFICATION_MESSAGE_WITH_DIVIDER, item.message)); |
| message->set_collapse_when_hidden(true); |
| message->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| message->SetEnabledColor(message_center::kDimTextColor); |
| message->SetBackgroundColor(message_center::kDimTextBackgroundColor); |
| - container_->AddChildView(message); |
| - |
| - remaining_count_ = new views::Label(); |
| - remaining_count_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
| - remaining_count_->SetEnabledColor(message_center::kDimTextColor); |
| - remaining_count_->SetBackgroundColor(message_center::kDimTextBackgroundColor); |
| - remaining_count_->SetVisible(false); |
| - AddChildView(remaining_count_); |
| + AddChildView(message); |
| } |
| -ItemView::~ItemView() {} |
| - |
| -void ItemView::SetRemainingCount(int num_remaining) { |
| - if (num_remaining > 0) { |
| - remaining_count_->SetText(l10n_util::GetStringFUTF16Int( |
| - IDS_MESSAGE_CENTER_LIST_NOTIFICATION_OVERFLOW_INDICATOR, |
| - num_remaining)); |
| - } |
| -} |
| - |
| -void ItemView::SetRemainingCountVisible(bool visible) { |
| - remaining_count_->SetVisible(visible); |
| -} |
| +ItemView::~ItemView() = default; |
| // CompactTitleMessageView ///////////////////////////////////////////////////// |
| @@ -637,13 +582,11 @@ void NotificationViewMD::CreateOrUpdateListItemViews( |
| left_content_->AddChildView(item_view); |
| } |
| - if (!item_views_.empty()) { |
| - item_views_.front()->SetRemainingCount(items.size() - 1); |
| - item_views_.back()->SetRemainingCount(items.size() - item_views_.size()); |
| + list_items_count_ = items.size(); |
| - // Needed when CreateOrUpdateViews is called for update. |
| + // Needed when CreateOrUpdateViews is called for update. |
| + if (!item_views_.empty()) |
| left_content_->InvalidateLayout(); |
| - } |
| } |
| void NotificationViewMD::CreateOrUpdateIconView( |
| @@ -811,13 +754,12 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) { |
| if (image_container_) |
| image_container_->SetVisible(expanded); |
| actions_row_->SetVisible(expanded && actions_row_->has_children()); |
| - for (size_t i = 1; i < item_views_.size(); ++i) { |
| + for (size_t i = kMaxLinesForMessageView; i < item_views_.size(); ++i) { |
| item_views_[i]->SetVisible(expanded); |
| } |
| - if (!item_views_.empty()) { |
| - item_views_.front()->SetRemainingCountVisible(!expanded); |
| - item_views_.back()->SetRemainingCountVisible(expanded); |
| - } |
| + header_row_->SetOverflowIndicator( |
| + expanded ? list_items_count_ - item_views_.size() |
| + : list_items_count_ - kMaxLinesForMessageView); |
|
yoshiki
2017/07/03 07:27:20
nit: "list_items_count_ - (expanded ? item_views_.
tetsui
2017/07/03 07:36:00
Done.
|
| } |
| void NotificationViewMD::UpdateControlButtonsVisibility() { |