Commit bf16f728 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Media Notification] Use summary text for artist

Use the summary text for the artist as per the mocks.

Also makes the summary text customisable outside of
NotificationHeaderView.

BUG=897836

Change-Id: I6b3ad378e2809844014b4b3757d16b8600e78a1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1554189Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649734}
parent 4144c3af
......@@ -279,6 +279,7 @@ void MediaNotificationView::UpdateWithMediaMetadata(
title_label_->SetText(metadata.title);
artist_label_->SetText(metadata.artist);
header_row_->SetSummaryText(metadata.album);
if (!metadata.title.empty())
RecordMetadataHistogram(Metadata::kTitle);
......
......@@ -535,6 +535,8 @@ TEST_F(MediaNotificationViewTest, UpdateMetadata_FromObserver) {
ExpectHistogramMetadataRecorded(MediaNotificationView::Metadata::kAlbum, 0);
ExpectHistogramMetadataRecorded(MediaNotificationView::Metadata::kCount, 1);
EXPECT_FALSE(header_row()->summary_text_for_testing()->visible());
media_session::MediaMetadata metadata;
metadata.title = base::ASCIIToUTF16("title2");
metadata.artist = base::ASCIIToUTF16("artist2");
......@@ -545,9 +547,11 @@ TEST_F(MediaNotificationViewTest, UpdateMetadata_FromObserver) {
EXPECT_TRUE(title_artist_row()->visible());
EXPECT_TRUE(title_label()->visible());
EXPECT_TRUE(artist_label()->visible());
EXPECT_TRUE(header_row()->summary_text_for_testing()->visible());
EXPECT_EQ(metadata.title, title_label()->text());
EXPECT_EQ(metadata.artist, artist_label()->text());
EXPECT_EQ(metadata.album, header_row()->summary_text_for_testing()->text());
EXPECT_EQ(kMediaTitleArtistRowExpectedHeight, title_artist_row()->height());
......
......@@ -202,6 +202,7 @@ NotificationHeaderView::NotificationHeaderView(
summary_text_divider_->SetLineHeight(font_list_height);
summary_text_divider_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
summary_text_divider_->SetBorder(views::CreateEmptyBorder(text_view_padding));
summary_text_divider_->SetEnabledColor(accent_color_);
summary_text_divider_->SetVisible(false);
DCHECK_EQ(kInnerHeaderHeight,
summary_text_divider_->GetPreferredSize().height());
......@@ -213,6 +214,7 @@ NotificationHeaderView::NotificationHeaderView(
summary_text_view_->SetLineHeight(font_list_height);
summary_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
summary_text_view_->SetBorder(views::CreateEmptyBorder(text_view_padding));
summary_text_view_->SetEnabledColor(accent_color_);
summary_text_view_->SetVisible(false);
DCHECK_EQ(kInnerHeaderHeight,
summary_text_view_->GetPreferredSize().height());
......@@ -287,7 +289,14 @@ void NotificationHeaderView::SetProgress(int progress) {
UpdateSummaryTextVisibility();
}
void NotificationHeaderView::SetSummaryText(const base::string16& text) {
DCHECK(!has_progress_);
summary_text_view_->SetText(text);
UpdateSummaryTextVisibility();
}
void NotificationHeaderView::ClearProgress() {
summary_text_view_->SetText(base::string16());
has_progress_ = false;
UpdateSummaryTextVisibility();
}
......@@ -296,15 +305,10 @@ void NotificationHeaderView::SetOverflowIndicator(int count) {
if (count > 0) {
summary_text_view_->SetText(l10n_util::GetStringFUTF16Int(
IDS_MESSAGE_CENTER_LIST_NOTIFICATION_HEADER_OVERFLOW_INDICATOR, count));
has_overflow_indicator_ = true;
} else {
has_overflow_indicator_ = false;
summary_text_view_->SetText(base::string16());
}
UpdateSummaryTextVisibility();
}
void NotificationHeaderView::ClearOverflowIndicator() {
has_overflow_indicator_ = false;
UpdateSummaryTextVisibility();
}
......@@ -353,6 +357,8 @@ void NotificationHeaderView::SetExpanded(bool expanded) {
void NotificationHeaderView::SetAccentColor(SkColor color) {
accent_color_ = color;
app_name_view_->SetEnabledColor(accent_color_);
summary_text_view_->SetEnabledColor(accent_color_);
summary_text_divider_->SetEnabledColor(accent_color_);
SetExpanded(is_expanded_);
}
......@@ -381,7 +387,7 @@ const gfx::ImageSkia& NotificationHeaderView::app_icon_for_testing() const {
}
void NotificationHeaderView::UpdateSummaryTextVisibility() {
const bool visible = has_progress_ || has_overflow_indicator_;
const bool visible = !summary_text_view_->text().empty();
summary_text_divider_->SetVisible(visible);
summary_text_view_->SetVisible(visible);
timestamp_divider_->SetVisible(!has_progress_ && has_timestamp_);
......
......@@ -28,8 +28,13 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button {
void SetAppIcon(const gfx::ImageSkia& img);
void SetAppName(const base::string16& name);
void SetAppNameElideBehavior(gfx::ElideBehavior elide_behavior);
// Progress, summary and overflow indicator are all the same UI element so are
// mutually exclusive.
void SetProgress(int progress);
void SetSummaryText(const base::string16& text);
void SetOverflowIndicator(int count);
void SetTimestamp(base::Time timestamp);
void SetExpandButtonEnabled(bool enabled);
void SetExpanded(bool expanded);
......@@ -41,7 +46,6 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button {
void SetAccentColor(SkColor color);
void ClearAppIcon();
void ClearProgress();
void ClearOverflowIndicator();
void ClearTimestamp();
bool IsExpandButtonEnabled();
void SetSubpixelRenderingEnabled(bool enabled);
......@@ -56,6 +60,10 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button {
SkColor accent_color_for_testing() { return accent_color_; }
const views::Label* summary_text_for_testing() const {
return summary_text_view_;
}
const base::string16& app_name_for_testing() const;
const gfx::ImageSkia& app_icon_for_testing() const;
......@@ -76,7 +84,6 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button {
bool settings_button_enabled_ = false;
bool has_progress_ = false;
bool has_overflow_indicator_ = false;
bool has_timestamp_ = false;
bool is_expanded_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment