Commit 567cebb9 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Change feature pod toggle behavior.

This CL changes feature pod toggle behavior as follows:

Current behavior:
The feature was enabled. -> The feature is disabled.
The feature was disabled. -> The feature is enabled.

Expected behavior (This CL):
The feature was enabled. -> The feature is disabled.
The feature was disabled. -> The feature is enabled &
                             transition to the detailed view.

As currently we only have three feature pod buttons which are togglable
& having a detailed view, so it changes behavior of these buttons:
* Network
* Bluetooth
* Quiet Mode

TEST=manual
BUG=856028

Change-Id: I860bd9501bc651d74d982130d22b5006e0fba6e0
Reviewed-on: https://chromium-review.googlesource.com/1116503Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571390}
parent 83c528e8
......@@ -36,8 +36,12 @@ FeaturePodButton* BluetoothFeaturePodController::CreateButton() {
}
void BluetoothFeaturePodController::OnIconPressed() {
Shell::Get()->tray_bluetooth_helper()->SetBluetoothEnabled(
!button_->IsToggled());
bool was_enabled = button_->IsToggled();
Shell::Get()->tray_bluetooth_helper()->SetBluetoothEnabled(!was_enabled);
// If Bluetooth was disabled, show device list as well as enabling Bluetooth.
if (!was_enabled)
tray_controller_->ShowBluetoothDetailedView();
}
void BluetoothFeaturePodController::OnLabelPressed() {
......
......@@ -64,7 +64,12 @@ FeaturePodButton* NetworkFeaturePodController::CreateButton() {
}
void NetworkFeaturePodController::OnIconPressed() {
SetNetworkEnabled(!button_->IsToggled());
bool was_enabled = button_->IsToggled();
SetNetworkEnabled(!was_enabled);
// If network was disabled, show network list as well as enabling network.
if (!was_enabled)
tray_controller_->ShowNetworkDetailedView();
}
void NetworkFeaturePodController::OnLabelPressed() {
......
......@@ -44,9 +44,15 @@ void QuietModeFeaturePodController::OnIconPressed() {
MessageCenter* message_center = MessageCenter::Get();
bool is_quiet_mode = message_center->IsQuietMode();
message_center->SetQuietMode(!is_quiet_mode);
// If quiet mode was disabled, show notifier settings as well as enabling
// quiet mode.
if (!is_quiet_mode)
tray_controller_->ShowNotifierSettingsView();
}
void QuietModeFeaturePodController::OnLabelPressed() {
MessageCenter::Get()->SetQuietMode(true);
tray_controller_->ShowNotifierSettingsView();
}
......
......@@ -151,7 +151,7 @@ void UnifiedSystemTrayController::ToggleExpanded() {
UMA_HISTOGRAM_ENUMERATION("ChromeOS.SystemTray.ToggleExpanded",
TOGGLE_EXPANDED_TYPE_BY_BUTTON,
TOGGLE_EXPANDED_TYPE_COUNT);
if (animation_->IsShowing())
if (IsExpanded())
animation_->Hide();
else
animation_->Show();
......@@ -170,7 +170,7 @@ void UnifiedSystemTrayController::OnClearAllAnimationEnded() {
void UnifiedSystemTrayController::BeginDrag(const gfx::Point& location) {
drag_init_point_ = location;
was_expanded_ = animation_->IsShowing();
was_expanded_ = IsExpanded();
}
void UnifiedSystemTrayController::UpdateDrag(const gfx::Point& location) {
......@@ -217,6 +217,9 @@ void UnifiedSystemTrayController::ShowUserChooserWidget() {
}
void UnifiedSystemTrayController::ShowNetworkDetailedView() {
if (!IsExpanded())
return;
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_STATUS_AREA_DETAILED_NETWORK_VIEW);
ShowDetailedView(
......@@ -224,6 +227,9 @@ void UnifiedSystemTrayController::ShowNetworkDetailedView() {
}
void UnifiedSystemTrayController::ShowBluetoothDetailedView() {
if (!IsExpanded())
return;
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
ShowDetailedView(
......@@ -258,6 +264,9 @@ void UnifiedSystemTrayController::ShowAudioDetailedView() {
}
void UnifiedSystemTrayController::ShowNotifierSettingsView() {
if (!IsExpanded())
return;
DCHECK(Shell::Get()->session_controller()->ShouldShowNotificationTray());
DCHECK(!Shell::Get()->session_controller()->IsScreenLocked());
ShowDetailedView(std::make_unique<UnifiedNotifierSettingsController>(this));
......@@ -362,4 +371,8 @@ double UnifiedSystemTrayController::GetDragExpandedAmount(
}
}
bool UnifiedSystemTrayController::IsExpanded() const {
return animation_->IsShowing();
}
} // namespace ash
......@@ -136,6 +136,9 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
// keeps returning 1.0.
double GetDragExpandedAmount(const gfx::Point& location) const;
// Return true if UnifiedSystemTray is expanded.
bool IsExpanded() const;
// Model that stores UI specific variables. Unowned.
UnifiedSystemTrayModel* const model_;
......
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