Commit 29673bb7 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Respect persistent state in tray.

This change ensures that the tray remains expanded
or collapsed when opened after being previously
expanded or collapsed by the user.

Change-Id: I66f5547e36f7f245f75eabfa74fb63e021bbe20f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1992168
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729590}
parent 85c6ade4
...@@ -439,10 +439,16 @@ void UnifiedSystemTrayController::UpdateExpandedAmount() { ...@@ -439,10 +439,16 @@ void UnifiedSystemTrayController::UpdateExpandedAmount() {
if (bubble_) if (bubble_)
bubble_->UpdateTransform(); bubble_->UpdateTransform();
if (expanded_amount == 0.0 || expanded_amount == 1.0) if (expanded_amount == 0.0 || expanded_amount == 1.0)
model_->set_expanded_on_open(expanded_amount == 1.0); model_->set_expanded_on_open(
expanded_amount == 1.0
? UnifiedSystemTrayModel::StateOnOpen::EXPANDED
: UnifiedSystemTrayModel::StateOnOpen::COLLAPSED);
} }
void UnifiedSystemTrayController::ResetToCollapsedIfRequired() { void UnifiedSystemTrayController::ResetToCollapsedIfRequired() {
if (model_->IsExplicitlyExpanded())
return;
if (features::IsUnifiedMessageCenterRefactorEnabled()) { if (features::IsUnifiedMessageCenterRefactorEnabled()) {
if (unified_view_->feature_pods_container()->row_count() == if (unified_view_->feature_pods_container()->row_count() ==
kUnifiedFeaturePodMinRows) { kUnifiedFeaturePodMinRows) {
......
...@@ -87,10 +87,14 @@ void UnifiedSystemTrayModel::RemoveObserver(Observer* observer) { ...@@ -87,10 +87,14 @@ void UnifiedSystemTrayModel::RemoveObserver(Observer* observer) {
} }
bool UnifiedSystemTrayModel::IsExpandedOnOpen() const { bool UnifiedSystemTrayModel::IsExpandedOnOpen() const {
return expanded_on_open_ || return expanded_on_open_ != StateOnOpen::COLLAPSED ||
Shell::Get()->accessibility_controller()->spoken_feedback_enabled(); Shell::Get()->accessibility_controller()->spoken_feedback_enabled();
} }
bool UnifiedSystemTrayModel::IsExplicitlyExpanded() const {
return expanded_on_open_ == StateOnOpen::EXPANDED;
}
base::Optional<bool> UnifiedSystemTrayModel::GetNotificationExpanded( base::Optional<bool> UnifiedSystemTrayModel::GetNotificationExpanded(
const std::string& notification_id) const { const std::string& notification_id) const {
auto it = notification_changes_.find(notification_id); auto it = notification_changes_.find(notification_id);
......
...@@ -17,6 +17,15 @@ namespace ash { ...@@ -17,6 +17,15 @@ namespace ash {
// SystemTrayModel. // SystemTrayModel.
class ASH_EXPORT UnifiedSystemTrayModel { class ASH_EXPORT UnifiedSystemTrayModel {
public: public:
enum class StateOnOpen {
// The user has not made any changes to the quick settings state.
UNSET,
// Quick settings has been explicitly set to collapsed by the user.
COLLAPSED,
// Quick settings has been explicitly set to expanded by the user.
EXPANDED
};
enum class NotificationTargetMode { enum class NotificationTargetMode {
// Notification list scrolls to the last notification. // Notification list scrolls to the last notification.
LAST_NOTIFICATION, LAST_NOTIFICATION,
...@@ -42,8 +51,13 @@ class ASH_EXPORT UnifiedSystemTrayModel { ...@@ -42,8 +51,13 @@ class ASH_EXPORT UnifiedSystemTrayModel {
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
// Returns true if the tray should be expanded when initially opened.
bool IsExpandedOnOpen() const; bool IsExpandedOnOpen() const;
// Returns true if the user explicity set the tray to its
// expanded state.
bool IsExplicitlyExpanded() const;
// Returns empty if it's not manually expanded/collapsed. Otherwise, the value // Returns empty if it's not manually expanded/collapsed. Otherwise, the value
// is true if the notification is manually expanded, and false if it's // is true if the notification is manually expanded, and false if it's
// manually collapsed. // manually collapsed.
...@@ -67,7 +81,7 @@ class ASH_EXPORT UnifiedSystemTrayModel { ...@@ -67,7 +81,7 @@ class ASH_EXPORT UnifiedSystemTrayModel {
float display_brightness() const { return display_brightness_; } float display_brightness() const { return display_brightness_; }
float keyboard_brightness() const { return keyboard_brightness_; } float keyboard_brightness() const { return keyboard_brightness_; }
void set_expanded_on_open(bool expanded_on_open) { void set_expanded_on_open(StateOnOpen expanded_on_open) {
expanded_on_open_ = expanded_on_open; expanded_on_open_ = expanded_on_open;
} }
...@@ -101,7 +115,7 @@ class ASH_EXPORT UnifiedSystemTrayModel { ...@@ -101,7 +115,7 @@ class ASH_EXPORT UnifiedSystemTrayModel {
// If UnifiedSystemTray bubble is expanded on its open. It's expanded by // If UnifiedSystemTray bubble is expanded on its open. It's expanded by
// default, and if a user collapses manually, it remembers previous state. // default, and if a user collapses manually, it remembers previous state.
bool expanded_on_open_ = true; StateOnOpen expanded_on_open_ = StateOnOpen::UNSET;
// The last value of the display brightness slider. Between 0.0 and 1.0. // The last value of the display brightness slider. Between 0.0 and 1.0.
float display_brightness_ = 1.f; float display_brightness_ = 1.f;
......
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