Commit eed2abfe authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Fix message center collapse / expand during drag

Bug: 1026073
Change-Id: I14ce8ac49020b797a11f9a5dfa51678c802bf293
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1950891
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721804}
parent 29edde9c
......@@ -170,12 +170,7 @@ void UnifiedSystemTrayController::ToggleExpanded() {
} else {
// Collapse the message center if screen height is limited after expanding
// the quick settings to its full height.
// Note: This calculaton should be the same as
// UnifiedMessageCenterBubble::CalculateAvailableHeight().
if (bubble_ && bubble_->CalculateMaxHeight() -
unified_view_->GetExpandedSystemTrayHeight() -
kUnifiedMessageCenterBubbleSpacing <
kMessageCenterCollapseThreshold) {
if (IsMessageCenterCollapseRequired()) {
bubble_->CollapseMessageCenter();
}
animation_->Show();
......@@ -204,10 +199,12 @@ void UnifiedSystemTrayController::UpdateDrag(const gfx::Point& location) {
UpdateExpandedAmount();
if (was_expanded_ &&
drag_expanded_amount < kNotificationCenterDragExpandThreshold)
drag_expanded_amount < kNotificationCenterDragExpandThreshold) {
bubble_->ExpandMessageCenter();
else if (drag_expanded_amount >= kNotificationCenterDragExpandThreshold)
} else if (drag_expanded_amount >= kNotificationCenterDragExpandThreshold &&
IsMessageCenterCollapseRequired()) {
bubble_->CollapseMessageCenter();
}
}
void UnifiedSystemTrayController::StartAnimation(bool expand) {
......@@ -236,7 +233,7 @@ void UnifiedSystemTrayController::EndDrag(const gfx::Point& location) {
TOGGLE_EXPANDED_TYPE_COUNT);
}
if (expanded)
if (expanded && IsMessageCenterCollapseRequired())
bubble_->CollapseMessageCenter();
else
bubble_->ExpandMessageCenter();
......@@ -252,7 +249,7 @@ void UnifiedSystemTrayController::Fling(int velocity) {
// Expand when flinging up. Collapse otherwise.
bool expand = (velocity < 0);
if (expand)
if (expand && IsMessageCenterCollapseRequired())
bubble_->CollapseMessageCenter();
else
bubble_->ExpandMessageCenter();
......@@ -474,4 +471,13 @@ bool UnifiedSystemTrayController::IsExpanded() const {
return animation_->IsShowing();
}
bool UnifiedSystemTrayController::IsMessageCenterCollapseRequired() const {
// Note: This calculaton should be the same as
// UnifiedMessageCenterBubble::CalculateAvailableHeight().
return (bubble_ && bubble_->CalculateMaxHeight() -
unified_view_->GetExpandedSystemTrayHeight() -
kUnifiedMessageCenterBubbleSpacing <
kMessageCenterCollapseThreshold);
}
} // namespace ash
......@@ -170,6 +170,10 @@ class ASH_EXPORT UnifiedSystemTrayController
// Return true if UnifiedSystemTray is expanded.
bool IsExpanded() const;
// Return true if message center needs to be collapsed due to limited
// screen height.
bool IsMessageCenterCollapseRequired() const;
// Starts animation to expand or collapse the bubble.
void StartAnimation(bool expand);
......
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