Skip to content

Commit

Permalink
NtRefresh: Use D/L mode-aware color provider for background
Browse files Browse the repository at this point in the history
This CL changes to use AshColorProvider to set the background color of
the refreshed notifications to correctly support the ash’s Dark/Light
mode.
Also, this CL splits out the ARC/ash-related code from
//ui/message_center to //ash/p/c/external_arc.

BUG=b:211336495
TEST=manual

Change-Id: I7eefd2130e508689585d9be6b9c0e51c3685f090
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3565523
Reviewed-by: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: Yoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Toshiki Kikuchi <toshikikikuchi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988412}
  • Loading branch information
Toshiki Kikuchi authored and Chromium LUCI CQ committed Apr 4, 2022
1 parent f858b31 commit f9a0bbe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ void ArcNotificationView::UpdateCornerRadius(int top_radius,
content_view_->UpdateCornerRadius(top_radius, bottom_radius);
}

void ArcNotificationView::UpdateBackgroundPainter() {
if (features::IsNotificationsRefreshEnabled()) {
SetBackground(views::CreateSolidBackground(
shown_in_popup_ ? AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent80)
: AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::
kControlBackgroundColorInactive)));
} else {
MessageView::UpdateBackgroundPainter();
}
}

void ArcNotificationView::UpdateControlButtonsVisibility() {
content_view_->UpdateControlButtonsVisibility();
}
Expand Down Expand Up @@ -202,12 +215,6 @@ void ArcNotificationView::OnThemeChanged() {
GetColorProvider()->GetColor(ui::kColorFocusableBorderFocused),
gfx::Insets::TLBR(0, 1, 3, 2));
}

if (features::IsNotificationsRefreshEnabled() && shown_in_popup_) {
SetBackground(
views::CreateSolidBackground(AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent80)));
}
}

void ArcNotificationView::OnContainerAnimationEnded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ArcNotificationView : public message_center::MessageView,
void OnSnoozeButtonPressed(const ui::Event& event) override;
void OnThemeChanged() override;
void UpdateCornerRadius(int top_radius, int bottom_radius) override;
void UpdateBackgroundPainter() override;
base::TimeDelta GetBoundsAnimationDuration(
const message_center::Notification&) const override;

Expand Down
9 changes: 0 additions & 9 deletions ui/message_center/views/message_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,6 @@ void MessageView::UpdateBackgroundPainter() {
is_active_ ? ui::kColorNotificationBackgroundActive
: ui::kColorNotificationBackgroundInactive);

#if BUILDFLAG(IS_CHROMEOS_ASH)
if (ash::features::IsNotificationsRefreshEnabled()) {
// These are the same colors provided by AshColorProvider.
// See ash/style/ash_color_provider.cc
background_color = is_active_ ? SkColorSetA(SK_ColorBLACK, 0x0D)
: SkColorSetA(SK_ColorWHITE, 0x1A);
}
#endif

SetBackground(views::CreateBackgroundFromPainter(
std::make_unique<NotificationBackgroundPainter>(
top_radius_, bottom_radius_, background_color)));
Expand Down
6 changes: 3 additions & 3 deletions ui/message_center/views/message_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class MESSAGE_CENTER_EXPORT MessageView
// Changes the background color and schedules a paint.
virtual void SetDrawBackgroundAsActive(bool active);

// Updates the background painter using the themed background color and radii.
virtual void UpdateBackgroundPainter();

void UpdateControlButtonsVisibilityWithNotification(
const Notification& notification);

Expand All @@ -243,9 +246,6 @@ class MESSAGE_CENTER_EXPORT MessageView
// Returns if the control buttons should be shown.
bool ShouldShowControlButtons() const;

// Updates the background painter using the themed background color and radii.
void UpdateBackgroundPainter();

void UpdateNestedBorder();

std::string notification_id_;
Expand Down

0 comments on commit f9a0bbe

Please sign in to comment.