Skip to content

Commit 254feb6

Browse files
Taylor BergquistChromium LUCI CQ
authored andcommitted
Revert "ash: Show calendar events in CalendarDateCellView"
This reverts commit 279a629. Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1258843 Original change's description: > ash: Show calendar events in CalendarDateCellView > > Fetch events and store them by month and day in > CalendarViewController. > > Each day displays a dot if it contains any events. > > Add unit tests. > > Bug: 1238927 > Change-Id: Ia1837797ff62b34e8a89fed508e9545704974048 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3179301 > Commit-Queue: Roger Tinkoff <[email protected]> > Reviewed-by: Alex Newcomer <[email protected]> > Reviewed-by: Boris Sazonov <[email protected]> > Cr-Commit-Position: refs/heads/main@{#930155} Bug: 1238927 Change-Id: Ie686aca72c53f81a475b167b4b712a599eb0085d No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3218030 Bot-Commit: Rubber Stamper <[email protected]> Owners-Override: Taylor Bergquist <[email protected]> Auto-Submit: Taylor Bergquist <[email protected]> Commit-Queue: Taylor Bergquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#930232}
1 parent d2f773a commit 254feb6

12 files changed

+52
-657
lines changed

ash/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,6 @@ component("ash") {
19191919
"//chromeos/ui/vector_icons",
19201920
"//components/discardable_memory/public/mojom",
19211921
"//google_apis/calendar",
1922-
"//google_apis/common",
19231922
"//mojo/public/cpp/bindings",
19241923
"//mojo/public/cpp/system",
19251924
"//services/data_decoder/public/mojom",
@@ -2698,7 +2697,6 @@ test("ash_unittests") {
26982697
"//device/bluetooth",
26992698
"//device/bluetooth:mocks",
27002699
"//extensions/common:common_constants",
2701-
"//google_apis/calendar",
27022700
"//mojo/core/embedder",
27032701
"//mojo/public/cpp/bindings",
27042702
"//net:net",

ash/system/time/DEPS

Lines changed: 0 additions & 4 deletions
This file was deleted.

ash/system/time/calendar_month_view.cc

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ constexpr int kLineThickness = 2;
2727
// The radius used to draw rounded today's circle
2828
constexpr float kTodayRoundedRadius = 20.f;
2929

30-
// Radius of the small dot we display on a CalendarDateCellView if events are
31-
// present for that day.
32-
constexpr float kEventsPresentRoundedRadius = 2.f;
33-
3430
// The padding of the focus circle.
3531
constexpr int kFocusCirclePadding = 4;
3632

@@ -50,10 +46,8 @@ using views::GridLayout;
5046

5147
// TODO(https://crbug.com/1236276): Fix the ChromeVox window position on this
5248
// view.
53-
CalendarDateCellView::CalendarDateCellView(
54-
CalendarViewController* calendar_view_controller,
55-
base::Time::Exploded& date,
56-
bool is_grayed_out_date)
49+
CalendarDateCellView::CalendarDateCellView(base::Time::Exploded& date,
50+
bool is_grayed_out_date)
5751
: views::LabelButton(
5852
views::Button::PressedCallback(base::BindRepeating([]() {
5953
// TODO(https://crbug.com/1238927): Add a menthod in the
@@ -62,8 +56,7 @@ CalendarDateCellView::CalendarDateCellView(
6256
base::UTF8ToUTF16(base::NumberToString(date.day_of_month)),
6357
CONTEXT_CALENDAR_DATE),
6458
date_(date),
65-
grayed_out_(is_grayed_out_date),
66-
calendar_view_controller_(calendar_view_controller) {
59+
grayed_out_(is_grayed_out_date) {
6760
SetHorizontalAlignment(gfx::ALIGN_CENTER);
6861
SetBorder(views::CreateEmptyBorder(calendar_utils::kDateCellInsets));
6962
label()->SetElideBehavior(gfx::NO_ELIDE);
@@ -154,35 +147,6 @@ void CalendarDateCellView::DisableFocus() {
154147
SetFocusBehavior(FocusBehavior::NEVER);
155148
}
156149

157-
gfx::Point CalendarDateCellView::GetEventsPresentIndicatorCenterPosition() {
158-
const gfx::Rect content = GetContentsBounds();
159-
return gfx::Point(
160-
(content.width() + calendar_utils::kDateHorizontalPadding * 2) / 2,
161-
(content.height() + calendar_utils::kDateVerticalPadding * 2) / 2 +
162-
calendar_utils::kDateVerticalPadding);
163-
}
164-
165-
void CalendarDateCellView::MaybeDrawEventsIndicator(gfx::Canvas* canvas) {
166-
base::Time unexploded;
167-
DCHECK(base::Time::FromUTCExploded(date_, &unexploded));
168-
169-
if (!calendar_view_controller_->IsDayWithEvents(unexploded,
170-
/*events =*/nullptr)) {
171-
return;
172-
}
173-
174-
cc::PaintFlags indicator_paint_flags;
175-
indicator_paint_flags.setColor(calendar_utils::GetPrimaryTextColor());
176-
indicator_paint_flags.setStyle(cc::PaintFlags::kFill_Style);
177-
canvas->DrawCircle(GetEventsPresentIndicatorCenterPosition(),
178-
kEventsPresentRoundedRadius, indicator_paint_flags);
179-
}
180-
181-
void CalendarDateCellView::PaintButtonContents(gfx::Canvas* canvas) {
182-
views::LabelButton::PaintButtonContents(canvas);
183-
MaybeDrawEventsIndicator(canvas);
184-
}
185-
186150
CalendarMonthView::CalendarMonthView(
187151
const base::Time first_day_of_month,
188152
CalendarViewController* calendar_view_controller)
@@ -267,7 +231,7 @@ CalendarDateCellView* CalendarMonthView::AddDateCellToLayout(
267231
if (column_set_id == 0)
268232
layout_manager->StartRow(0, 0);
269233
return layout_manager->AddView(std::make_unique<CalendarDateCellView>(
270-
calendar_view_controller_, current_date_exploded,
234+
current_date_exploded,
271235
/*is_grayed_out_date=*/!is_in_current_month));
272236
}
273237

ash/system/time/calendar_month_view.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ class CalendarDateCellView : public views::LabelButton {
1919
public:
2020
METADATA_HEADER(CalendarDateCellView);
2121

22-
CalendarDateCellView(CalendarViewController* calendar_view_controller,
23-
base::Time::Exploded& date,
24-
bool is_grayed_out_date);
22+
CalendarDateCellView(base::Time::Exploded& date, bool is_grayed_out_date);
2523
CalendarDateCellView(const CalendarDateCellView& other) = delete;
2624
CalendarDateCellView& operator=(const CalendarDateCellView& other) = delete;
2725
~CalendarDateCellView() override;
@@ -39,24 +37,11 @@ class CalendarDateCellView : public views::LabelButton {
3937
// Disables focus behavior of this cell.
4038
void DisableFocus();
4139

42-
protected:
43-
// views::Button:
44-
void PaintButtonContents(gfx::Canvas* canvas) override;
45-
4640
private:
47-
// Computes the position of the indicator that our day has events.
48-
gfx::Point GetEventsPresentIndicatorCenterPosition();
49-
50-
// Draw the indicator if our day has events.
51-
void MaybeDrawEventsIndicator(gfx::Canvas* canvas);
52-
5341
// The date used to render this cell view.
5442
const base::Time::Exploded date_;
5543

5644
const bool grayed_out_;
57-
58-
// Owned by UnifiedCalendarViewController.
59-
const CalendarViewController* const calendar_view_controller_;
6045
};
6146

6247
// Container for `CalendarDateCellView` for a single month.

ash/system/time/calendar_view.cc

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ constexpr gfx::Insets kContentInsets{kContentVerticalPadding};
4040
// bottom if there's this much pixel left.
4141
constexpr int kPrepareEndOfView = 30;
4242

43-
// After the user is finished navigating to a different month, this is how long
44-
// we wait before fetchiung more events.
45-
constexpr base::TimeDelta kScrollingSettledTimeout = base::Milliseconds(100);
46-
4743
// TODO(https://crbug.com/1236276): for some language it may start from "M".
4844
constexpr int kDefaultWeekTitles[] = {
4945
IDS_ASH_CALENDAR_SUN, IDS_ASH_CALENDAR_MON, IDS_ASH_CALENDAR_TUE,
@@ -124,15 +120,15 @@ class CalendarView::MonthYearHeaderView : public views::View {
124120
: month_label_(AddChildView(std::make_unique<views::Label>())) {
125121
switch (type) {
126122
case PREVIOUS:
127-
date_ = calendar_view_controller->GetPreviousMonthFirstDay(1);
123+
date_ = calendar_view_controller->GetPreviousMonthFirstDay();
128124
month_name_ = calendar_view_controller->GetPreviousMonthName();
129125
break;
130126
case CURRENT:
131127
date_ = calendar_view_controller->GetOnScreenMonthFirstDay();
132128
month_name_ = calendar_view_controller->GetOnScreenMonthName();
133129
break;
134130
case NEXT:
135-
date_ = calendar_view_controller->GetNextMonthFirstDay(1);
131+
date_ = calendar_view_controller->GetNextMonthFirstDay();
136132
month_name_ = calendar_view_controller->GetNextMonthName();
137133
break;
138134
}
@@ -192,12 +188,7 @@ CalendarView::CalendarView(DetailedViewDelegate* delegate,
192188
CalendarViewController* calendar_view_controller)
193189
: TrayDetailedView(delegate),
194190
controller_(controller),
195-
calendar_view_controller_(calendar_view_controller),
196-
scrolling_settled_timer_(
197-
FROM_HERE,
198-
kScrollingSettledTimeout,
199-
base::BindRepeating(&CalendarView::OnScrollingSettledTimerFired,
200-
base::Unretained(this))) {
191+
calendar_view_controller_(calendar_view_controller) {
201192
CreateTitleRow(IDS_ASH_CALENDAR_TITLE);
202193

203194
// Add the header.
@@ -272,10 +263,6 @@ CalendarView::CalendarView(DetailedViewDelegate* delegate,
272263

273264
CalendarView::~CalendarView() = default;
274265

275-
void CalendarView::Init() {
276-
calendar_view_controller_->FetchEvents();
277-
}
278-
279266
void CalendarView::CreateExtraTitleRowButtons() {
280267
DCHECK(!reset_to_today_button_);
281268
tri_view()->SetContainerVisible(TriView::Container::END, /*visible=*/true);
@@ -309,14 +296,14 @@ views::Button* CalendarView::CreateInfoButton(
309296
void CalendarView::SetMonthViews() {
310297
previous_label_ = AddLabelWithId(LabelType::PREVIOUS);
311298
previous_month_ =
312-
AddMonth(calendar_view_controller_->GetPreviousMonthFirstDay(1));
299+
AddMonth(calendar_view_controller_->GetPreviousMonthFirstDay());
313300

314301
current_label_ = AddLabelWithId(LabelType::CURRENT);
315302
current_month_ =
316303
AddMonth(calendar_view_controller_->GetOnScreenMonthFirstDay());
317304

318305
next_label_ = AddLabelWithId(LabelType::NEXT);
319-
next_month_ = AddMonth(calendar_view_controller_->GetNextMonthFirstDay(1));
306+
next_month_ = AddMonth(calendar_view_controller_->GetNextMonthFirstDay());
320307
}
321308

322309
int CalendarView::PositionOfCurrentMonth() {
@@ -498,20 +485,11 @@ void CalendarView::OnMonthChanged(const base::Time::Exploded current_month) {
498485

499486
header_->SetText(calendar_view_controller_->GetOnScreenMonthName());
500487
header_year_->SetText(year_string);
501-
502-
scrolling_settled_timer_.Reset();
503-
}
504-
505-
void CalendarView::OnEventsFetched(
506-
const google_apis::calendar::EventList* events) {
507-
// No need to store the events, but we need to notify the month views that
508-
// something may have changed and they need to refresh.
509-
SchedulePaint();
510488
}
511489

512490
void CalendarView::ScrollUpOneMonth() {
513491
calendar_view_controller_->UpdateMonth(
514-
calendar_view_controller_->GetPreviousMonthFirstDay(1));
492+
calendar_view_controller_->GetPreviousMonthFirstDay());
515493
content_view_->RemoveChildViewT(next_label_);
516494
content_view_->RemoveChildViewT(next_month_);
517495

@@ -521,7 +499,7 @@ void CalendarView::ScrollUpOneMonth() {
521499
current_month_ = previous_month_;
522500

523501
previous_month_ =
524-
AddMonth(calendar_view_controller_->GetPreviousMonthFirstDay(1),
502+
AddMonth(calendar_view_controller_->GetPreviousMonthFirstDay(),
525503
/*add_at_front=*/true);
526504
if (IsDateCellViewFocused())
527505
previous_month_->EnableFocus();
@@ -550,7 +528,7 @@ void CalendarView::ScrollDownOneMonth() {
550528
previous_label_->GetPreferredSize().height();
551529

552530
calendar_view_controller_->UpdateMonth(
553-
calendar_view_controller_->GetNextMonthFirstDay(1));
531+
calendar_view_controller_->GetNextMonthFirstDay());
554532

555533
content_view_->RemoveChildViewT(previous_label_);
556534
content_view_->RemoveChildViewT(previous_month_);
@@ -561,7 +539,7 @@ void CalendarView::ScrollDownOneMonth() {
561539
current_month_ = next_month_;
562540

563541
next_label_ = AddLabelWithId(LabelType::NEXT);
564-
next_month_ = AddMonth(calendar_view_controller_->GetNextMonthFirstDay(1));
542+
next_month_ = AddMonth(calendar_view_controller_->GetNextMonthFirstDay());
565543
if (IsDateCellViewFocused())
566544
next_month_->EnableFocus();
567545

@@ -696,10 +674,6 @@ void CalendarView::OnEvent(ui::Event* event) {
696674
}
697675
}
698676

699-
void CalendarView::OnScrollingSettledTimerFired() {
700-
calendar_view_controller_->FetchEvents();
701-
}
702-
703677
BEGIN_METADATA(CalendarView, views::View)
704678
END_METADATA
705679

ash/system/time/calendar_view.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "ash/system/tray/tray_detailed_view.h"
1111
#include "ash/system/unified/unified_system_tray_controller.h"
1212
#include "base/scoped_multi_source_observation.h"
13-
#include "base/timer/timer.h"
1413
#include "ui/base/metadata/metadata_header_macros.h"
1514
#include "ui/views/controls/scroll_view.h"
1615
#include "ui/views/view.h"
@@ -40,14 +39,11 @@ class ASH_EXPORT CalendarView : public CalendarViewController::Observer,
4039
CalendarView& operator=(const CalendarView& other) = delete;
4140
~CalendarView() override;
4241

43-
void Init();
44-
4542
// views::ScrollView::Observer:
4643
void OnContentsScrolled() override;
4744

4845
// CalendarViewController::Observer:
4946
void OnMonthChanged(const base::Time::Exploded current_month) override;
50-
void OnEventsFetched(const google_apis::calendar::EventList* events) override;
5147

5248
// views::ViewObserver:
5349
void OnViewBoundsChanged(views::View* observed_view) override;
@@ -118,9 +114,6 @@ class ASH_EXPORT CalendarView : public CalendarViewController::Observer,
118114
// today's button), resets the content view's `FocusBehavior` to `ALWAYS`.
119115
void MaybeResetContentViewFocusBehavior();
120116

121-
// We only fetch events after we've "settled" on the current on-screen month.
122-
void OnScrollingSettledTimerFired();
123-
124117
// Unowned.
125118
UnifiedSystemTrayController* controller_;
126119

@@ -148,10 +141,6 @@ class ASH_EXPORT CalendarView : public CalendarViewController::Observer,
148141
// don't need to check if we need to update the month or not.
149142
bool is_resetting_scroll_ = false;
150143

151-
// Timer that fires when we've "settled" on, i.e. finished scrolling to, a
152-
// currently-visible month
153-
base::RetainingOneShotTimer scrolling_settled_timer_;
154-
155144
base::ScopedObservation<views::ScrollView,
156145
views::ScrollView::Observer,
157146
&views::ScrollView::AddScrollViewObserver,

0 commit comments

Comments
 (0)