Skip to content

Commit

Permalink
Clean up pre-QSRevamp code from StackedNotificationBar
Browse files Browse the repository at this point in the history
Part of an overall post QSRevamp clean up of the notification
area code.

Removed the expand button since there isn't a collapsed
mode anymore.
Removed animation code.

Bug: b:306077397

Change-Id: I66c54d1d30ec00eaeb9627681721b8a98d1f0507
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4950184
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: Jiaming Cheng <jiamingc@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1212540}
  • Loading branch information
amehfooz32 authored and Chromium LUCI CQ committed Oct 20, 2023
1 parent cd6262a commit 93ddd8d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 82 deletions.
6 changes: 0 additions & 6 deletions ash/system/notification_center/notification_center_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ void NotificationCenterView::SetExpanded() {
}

collapsed_ = false;
notification_bar_->SetExpanded();
scroller_->SetVisible(true);
}

Expand All @@ -175,7 +174,6 @@ void NotificationCenterView::SetCollapsed(bool animate) {
StartCollapseAnimation();
} else {
scroller_->SetVisible(false);
notification_bar_->SetCollapsed();
}
}

Expand Down Expand Up @@ -323,7 +321,6 @@ void NotificationCenterView::AnimationEnded(const gfx::Animation* animation) {
PreferredSizeChanged();

animation_state_ = NotificationCenterAnimationState::kIdle;
notification_bar_->SetAnimationState(animation_state_);
UpdateVisibility();
}

Expand All @@ -335,7 +332,6 @@ void NotificationCenterView::AnimationProgressed(
if (collapsed_ && scroller_->GetVisible() &&
animation_->GetCurrentValue() >= 0.5) {
scroller_->SetVisible(false);
notification_bar_->SetCollapsed();
}
PreferredSizeChanged();
}
Expand All @@ -352,15 +348,13 @@ void NotificationCenterView::OnContentsScrolled() {
void NotificationCenterView::StartHideStackingBarAnimation() {
animation_->End();
animation_state_ = NotificationCenterAnimationState::kHideStackingBar;
notification_bar_->SetAnimationState(animation_state_);
animation_->SetDuration(kHideStackingBarAnimationDuration);
animation_->Start();
}

void NotificationCenterView::StartCollapseAnimation() {
animation_->End();
animation_state_ = NotificationCenterAnimationState::kCollapse;
notification_bar_->SetAnimationState(animation_state_);
animation_->SetDuration(kCollapseAnimationDuration);
animation_->Start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ class NotificationCenterViewTest : public AshTestBase,
return notification_center_view()->notification_bar_->clear_all_button_;
}

views::View* GetNotificationBarExpandAllButton() {
return notification_center_view()->notification_bar_->expand_all_button_;
}

int total_notification_count() {
return GetNotificationBar()->total_notification_count_;
}
Expand Down Expand Up @@ -648,18 +644,14 @@ TEST_P(NotificationCenterViewTest, CollapseAndExpand_NonAnimated) {
test_api()->ToggleBubble();
EXPECT_TRUE(GetScroller()->GetVisible());
EXPECT_TRUE(GetNotificationBarClearAllButton()->GetVisible());
EXPECT_FALSE(GetNotificationBarExpandAllButton()->GetVisible());

// Set to collapsed state.
notification_center_view()->SetCollapsed(false /* animate */);
EXPECT_FALSE(GetScroller()->GetVisible());
EXPECT_TRUE(GetNotificationBar()->GetVisible());
EXPECT_TRUE(GetNotificationBarExpandAllButton()->GetVisible());
EXPECT_FALSE(GetNotificationBarClearAllButton()->GetVisible());

// Set back to expanded state.
notification_center_view()->SetExpanded();
EXPECT_FALSE(GetNotificationBarExpandAllButton()->GetVisible());
EXPECT_TRUE(GetNotificationBarClearAllButton()->GetVisible());
EXPECT_TRUE(GetScroller()->GetVisible());
}
Expand All @@ -683,12 +675,9 @@ TEST_P(NotificationCenterViewTest, CollapseAndExpand_Animated) {

collapse_animation->End();
AnimateNotificationListToEnd();
EXPECT_TRUE(GetNotificationBarExpandAllButton()->GetVisible());
EXPECT_FALSE(GetNotificationBarClearAllButton()->GetVisible());

// Set back to expanded state.
notification_center_view()->SetExpanded();
EXPECT_FALSE(GetNotificationBarExpandAllButton()->GetVisible());
EXPECT_TRUE(GetNotificationBarClearAllButton()->GetVisible());
EXPECT_TRUE(GetScroller()->GetVisible());
}
Expand Down
58 changes: 6 additions & 52 deletions ash/system/notification_center/stacked_notification_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,26 @@

#include "ash/system/notification_center/stacked_notification_bar.h"

#include "ash/constants/ash_features.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/pill_button.h"
#include "ash/style/style_util.h"
#include "ash/style/typography.h"
#include "ash/system/message_center/message_center_constants.h"
#include "ash/system/message_center/message_center_style.h"
#include "ash/system/tray/tray_constants.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "chromeos/constants/chromeos_features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/vector_icons.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
Expand All @@ -49,9 +43,7 @@ class StackingBarLabelButton : public PillButton {
NotificationCenterView* notification_center_view)
: PillButton(std::move(callback),
text,
chromeos::features::IsJellyEnabled()
? PillButton::Type::kFloatingWithoutIcon
: PillButton::Type::kAccentFloatingWithoutIcon,
PillButton::Type::kFloatingWithoutIcon,
/*icon=*/nullptr,
kNotificationPillButtonHorizontalSpacing),
notification_center_view_(notification_center_view) {
Expand Down Expand Up @@ -84,8 +76,7 @@ class StackedNotificationBar::StackedNotificationBarIcon
: public views::ImageView,
public ui::LayerAnimationObserver {
public:
explicit StackedNotificationBarIcon(const std::string& id)
: views::ImageView(), id_(id) {
explicit StackedNotificationBarIcon(const std::string& id) : id_(id) {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
}
Expand All @@ -107,10 +98,7 @@ class StackedNotificationBar::StackedNotificationBarIcon
return;

SkColor accent_color =
chromeos::features::IsJellyEnabled()
? GetColorProvider()->GetColor(cros_tokens::kCrosSysOnSurface)
: AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
GetColorProvider()->GetColor(cros_tokens::kCrosSysOnSurface);
gfx::Image masked_small_icon = notification->GenerateMaskedSmallIcon(
kStackedNotificationIconSize, accent_color, SK_ColorTRANSPARENT,
accent_color);
Expand Down Expand Up @@ -240,12 +228,6 @@ StackedNotificationBar::StackedNotificationBar(
l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_CLEAR_ALL_BUTTON_LABEL),
notification_center_view))),
expand_all_button_(AddChildView(std::make_unique<StackingBarLabelButton>(
base::BindRepeating(&NotificationCenterView::ExpandMessageCenter,
base::Unretained(notification_center_view_)),
l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_EXPAND_ALL_NOTIFICATIONS_BUTTON_LABEL),
notification_center_view))),
layout_manager_(SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal,
kNotificationBarPadding))) {
Expand All @@ -260,23 +242,14 @@ StackedNotificationBar::StackedNotificationBar(

message_center::MessageCenter::Get()->AddObserver(this);

if (chromeos::features::IsJellyEnabled()) {
count_label_->SetEnabledColorId(cros_tokens::kCrosSysOnSurface);
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosAnnotation1,
*count_label_);
} else {
count_label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary));
count_label_->SetFontList(views::Label::GetDefaultFontList().Derive(
1, gfx::Font::NORMAL, gfx::Font::Weight::MEDIUM));
}
count_label_->SetEnabledColorId(cros_tokens::kCrosSysOnSurface);
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosAnnotation1,
*count_label_);

layout_manager_->SetFlexForView(spacer_, 1);

clear_all_button_->SetTooltipText(l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_CLEAR_ALL_BUTTON_TOOLTIP));

expand_all_button_->SetVisible(false);
}

StackedNotificationBar::~StackedNotificationBar() {
Expand Down Expand Up @@ -315,25 +288,6 @@ bool StackedNotificationBar::Update(
return true;
}

void StackedNotificationBar::SetAnimationState(
NotificationCenterAnimationState animation_state) {
animation_state_ = animation_state;
}

void StackedNotificationBar::SetCollapsed() {
layout_manager_->set_inside_border_insets(gfx::Insets());

clear_all_button_->SetVisible(false);
expand_all_button_->SetVisible(true);
}

void StackedNotificationBar::SetExpanded() {
layout_manager_->set_inside_border_insets(kNotificationBarPadding);

clear_all_button_->SetVisible(true);
expand_all_button_->SetVisible(false);
}

void StackedNotificationBar::AddNotificationIcon(
message_center::Notification* notification,
bool at_front) {
Expand Down
13 changes: 0 additions & 13 deletions ash/system/notification_center/stacked_notification_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ class StackedNotificationBar : public views::View,
int pinned_notification_count,
std::vector<message_center::Notification*> stacked_notifications);

// Sets the current animation state.
void SetAnimationState(NotificationCenterAnimationState animation_state);

// Set notification bar state to collapsed.
void SetCollapsed();

// Set notification bar state to expanded.
void SetExpanded();

// views::View:
const char* GetClassName() const override;

Expand Down Expand Up @@ -98,16 +89,12 @@ class StackedNotificationBar : public views::View,
int pinned_notification_count_ = 0;
int stacked_notification_count_ = 0;

NotificationCenterAnimationState animation_state_ =
NotificationCenterAnimationState::kIdle;

const raw_ptr<NotificationCenterView, ExperimentalAsh>
notification_center_view_;
raw_ptr<views::View, ExperimentalAsh> notification_icons_container_;
const raw_ptr<views::Label, ExperimentalAsh> count_label_;
const raw_ptr<views::View, ExperimentalAsh> spacer_;
const raw_ptr<views::Button, ExperimentalAsh> clear_all_button_;
const raw_ptr<views::Button, ExperimentalAsh> expand_all_button_;
const raw_ptr<views::BoxLayout, ExperimentalAsh> layout_manager_;

base::WeakPtrFactory<StackedNotificationBar> weak_ptr_factory_{this};
Expand Down

0 comments on commit 93ddd8d

Please sign in to comment.