Commit da3076c2 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add notifier settings to UnifiedSystemTray.

Preivously, notifier settings was accessible from Notification Center.
In UnifiedSystemTray, System Tray and Notification Center are merged,
and notifier settings is accessible as a detailed view of Do not disturb
feature pod item.

Screenshot: http://screen/f2PaXeD71LQ

TEST=manual
BUG=835733

Change-Id: Ia6302647ebb837c4f8b494a150509273f0d56161
Reviewed-on: https://chromium-review.googlesource.com/1100719Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567562}
parent b0fd211f
......@@ -944,6 +944,8 @@ component("ash") {
"system/unified/unified_detailed_view_delegate.h",
"system/unified/unified_message_center_view.cc",
"system/unified/unified_message_center_view.h",
"system/unified/unified_notifier_settings_controller.cc",
"system/unified/unified_notifier_settings_controller.h",
"system/unified/unified_slider_bubble_controller.cc",
"system/unified/unified_slider_bubble_controller.h",
"system/unified/unified_slider_view.cc",
......
......@@ -233,6 +233,8 @@ MessageCenterView::MessageCenterView(
scroller_->SetContents(scroller_contents);
settings_view_ = new NotifierSettingsView();
settings_view_->SetBackground(
views::CreateSolidBackground(message_center_style::kBackgroundColor));
no_notifications_view_ = CreateEmptyNotificationView();
......
......@@ -13,10 +13,12 @@
#include "ash/message_center/message_center_controller.h"
#include "ash/message_center/message_center_style.h"
#include "ash/message_center/message_center_view.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_utils.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
......@@ -82,12 +84,6 @@ const int kInnateCheckboxRightPadding = 2;
constexpr int kComputedCheckboxSize =
kCheckboxSizeWithPadding - kInnateCheckboxRightPadding;
// A function to create a focus border.
std::unique_ptr<views::Painter> CreateFocusPainter() {
return views::Painter::CreateSolidFocusPainter(
message_center::kFocusBorderColor, gfx::Insets(1, 2, 3, 2));
}
// TODO(tetsui): Give more general names and remove kEntryHeight, etc.
constexpr gfx::Insets kTopLabelPadding(16, 18, 15, 18);
const int kQuietModeViewSpacing = 18;
......@@ -145,7 +141,8 @@ class NotifierButtonWrapperView : public views::View {
};
NotifierButtonWrapperView::NotifierButtonWrapperView(views::View* contents)
: focus_painter_(CreateFocusPainter()), contents_(contents) {
: focus_painter_(TrayPopupUtils::CreateFocusPainter()),
contents_(contents) {
AddChildView(contents);
}
......@@ -275,6 +272,7 @@ class EmptyNotifierView : public views::View {
views::Label* label = new views::Label(
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_NO_NOTIFIERS));
label->SetEnabledColor(message_center_style::kEmptyViewColor);
label->SetSubpixelRenderingEnabled(false);
// "Roboto-Medium, 12sp" is specified in the mock.
label->SetFontList(
gfx::FontList().DeriveWithWeight(gfx::Font::Weight::MEDIUM));
......@@ -300,7 +298,10 @@ NotifierSettingsView::NotifierButton::NotifierButton(
name_view_(new views::Label(notifier_ui_data.name)),
checkbox_(new views::Checkbox(base::string16(), true /* force_md */)) {
name_view_->SetAutoColorReadabilityEnabled(false);
name_view_->SetEnabledColor(kLabelColor);
name_view_->SetEnabledColor(features::IsSystemTrayUnifiedEnabled()
? kUnifiedMenuTextColor
: kLabelColor);
name_view_->SetSubpixelRenderingEnabled(false);
// "Roboto-Regular, 13sp" is specified in the mock.
name_view_->SetFontList(
gfx::FontList().DeriveWithSizeDelta(kLabelFontSizeDelta));
......@@ -324,7 +325,9 @@ void NotifierSettingsView::NotifierButton::UpdateIconImage(
const gfx::ImageSkia& icon) {
if (icon.isNull()) {
icon_view_->SetImage(gfx::CreateVectorIcon(
message_center::kProductIcon, kEntryIconSize, gfx::kChromeIconGrey));
message_center::kProductIcon, kEntryIconSize,
features::IsSystemTrayUnifiedEnabled() ? kUnifiedMenuIconColor
: gfx::kChromeIconGrey));
} else {
icon_view_->SetImage(icon);
icon_view_->SetImageSize(gfx::Size(kEntryIconSize, kEntryIconSize));
......@@ -408,9 +411,8 @@ NotifierSettingsView::NotifierSettingsView()
scroller_(nullptr),
no_notifiers_view_(nullptr) {
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
SetBackground(
views::CreateSolidBackground(message_center_style::kBackgroundColor));
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
header_view_ = new views::View;
header_view_->SetLayoutManager(std::make_unique<views::BoxLayout>(
......@@ -436,7 +438,10 @@ NotifierSettingsView::NotifierSettingsView()
quiet_mode_label->SetFontList(
gfx::FontList().DeriveWithSizeDelta(kLabelFontSizeDelta));
quiet_mode_label->SetAutoColorReadabilityEnabled(false);
quiet_mode_label->SetEnabledColor(kLabelColor);
quiet_mode_label->SetEnabledColor(features::IsSystemTrayUnifiedEnabled()
? kUnifiedMenuTextColor
: kLabelColor);
quiet_mode_label->SetSubpixelRenderingEnabled(false);
quiet_mode_label->SetBorder(views::CreateEmptyBorder(kQuietModeLabelPadding));
quiet_mode_view->AddChildView(quiet_mode_label);
quiet_mode_layout->SetFlexForView(quiet_mode_label, 1);
......@@ -458,7 +463,10 @@ NotifierSettingsView::NotifierSettingsView()
top_label_->SetFontList(gfx::FontList().Derive(
kLabelFontSizeDelta, gfx::Font::NORMAL, gfx::Font::Weight::MEDIUM));
top_label_->SetAutoColorReadabilityEnabled(false);
top_label_->SetEnabledColor(kTopLabelColor);
top_label_->SetEnabledColor(features::IsSystemTrayUnifiedEnabled()
? kUnifiedMenuTextColor
: kTopLabelColor);
top_label_->SetSubpixelRenderingEnabled(false);
top_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
top_label_->SetMultiLine(true);
header_view_->AddChildView(top_label_);
......@@ -466,7 +474,7 @@ NotifierSettingsView::NotifierSettingsView()
AddChildView(header_view_);
scroller_ = new views::ScrollView();
scroller_->SetBackgroundColor(message_center_style::kBackgroundColor);
scroller_->SetBackgroundColor(SK_ColorTRANSPARENT);
scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false));
scroller_->SetHorizontalScrollBar(new views::OverlayScrollBar(true));
scroller_->set_draw_overflow_indicator(false);
......@@ -492,11 +500,14 @@ void NotifierSettingsView::SetQuietModeState(bool is_quiet_mode) {
quiet_mode_toggle_->SetIsOn(is_quiet_mode, false /* animate */);
if (is_quiet_mode) {
quiet_mode_icon_->SetImage(gfx::CreateVectorIcon(
kNotificationCenterDoNotDisturbOnIcon, kMenuIconSize, kMenuIconColor));
kNotificationCenterDoNotDisturbOnIcon, kMenuIconSize,
features::IsSystemTrayUnifiedEnabled() ? kUnifiedMenuIconColor
: kMenuIconColor));
} else {
quiet_mode_icon_->SetImage(
gfx::CreateVectorIcon(kNotificationCenterDoNotDisturbOffIcon,
kMenuIconSize, kMenuIconColorDisabled));
quiet_mode_icon_->SetImage(gfx::CreateVectorIcon(
kNotificationCenterDoNotDisturbOffIcon, kMenuIconSize,
features::IsSystemTrayUnifiedEnabled() ? kUnifiedMenuIconColorDisabled
: kMenuIconColorDisabled));
}
}
......@@ -526,11 +537,12 @@ void NotifierSettingsView::SetNotifierList(
top_label_->SetVisible(notifier_count > 0);
no_notifiers_view_->SetVisible(notifier_count == 0);
top_label_->InvalidateLayout();
scroller_->SetContents(contents_view);
contents_view->SetBoundsRect(gfx::Rect(contents_view->GetPreferredSize()));
InvalidateLayout();
Layout();
}
void NotifierSettingsView::UpdateNotifierIcon(const NotifierId& notifier_id,
......
......@@ -7,6 +7,7 @@
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
......@@ -14,7 +15,9 @@ using message_center::MessageCenter;
namespace ash {
QuietModeFeaturePodController::QuietModeFeaturePodController() {
QuietModeFeaturePodController::QuietModeFeaturePodController(
UnifiedSystemTrayController* tray_controller)
: tray_controller_(tray_controller) {
MessageCenter::Get()->AddObserver(this);
}
......@@ -37,6 +40,10 @@ void QuietModeFeaturePodController::OnIconPressed() {
message_center->SetQuietMode(!is_quiet_mode);
}
void QuietModeFeaturePodController::OnLabelPressed() {
tray_controller_->ShowNotifierSettingsView();
}
SystemTrayItemUmaType QuietModeFeaturePodController::GetUmaType() const {
return SystemTrayItemUmaType::UMA_NOT_RECORDED;
}
......@@ -46,6 +53,9 @@ void QuietModeFeaturePodController::OnQuietModeChanged(bool in_quiet_mode) {
? kNotificationCenterDoNotDisturbOnIcon
: kNotificationCenterDoNotDisturbOffIcon);
button_->SetToggled(in_quiet_mode);
button_->SetSubLabel(l10n_util::GetStringUTF16(
in_quiet_mode ? IDS_ASH_STATUS_TRAY_NIGHT_LIGHT_ON_STATE
: IDS_ASH_STATUS_TRAY_NIGHT_LIGHT_OFF_STATE));
}
} // namespace ash
......@@ -12,6 +12,8 @@
namespace ash {
class UnifiedSystemTrayController;
// Controller of a feature pod button that toggles do-not-disturb mode.
// If the do-not-disturb mode is enabled, the button indicates it by bright
// background color and different icon.
......@@ -19,18 +21,22 @@ class QuietModeFeaturePodController
: public FeaturePodControllerBase,
public message_center::MessageCenterObserver {
public:
QuietModeFeaturePodController();
explicit QuietModeFeaturePodController(
UnifiedSystemTrayController* tray_controller);
~QuietModeFeaturePodController() override;
// FeaturePodControllerBase:
FeaturePodButton* CreateButton() override;
void OnIconPressed() override;
void OnLabelPressed() override;
SystemTrayItemUmaType GetUmaType() const override;
// message_center::MessageCenterObserver:
void OnQuietModeChanged(bool in_quiet_mode) override;
private:
UnifiedSystemTrayController* const tray_controller_;
FeaturePodButton* button_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(QuietModeFeaturePodController);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/unified/unified_notifier_settings_controller.h"
#include "ash/message_center/notifier_settings_view.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_detailed_view.h"
#include "ash/system/unified/unified_detailed_view_delegate.h"
#include "ui/message_center/message_center_observer.h"
#include "ui/views/layout/box_layout.h"
namespace ash {
namespace {
class UnifiedNotifierSettingsView
: public TrayDetailedView,
public message_center::MessageCenterObserver {
public:
explicit UnifiedNotifierSettingsView(DetailedViewDelegate* delegate)
: TrayDetailedView(delegate), settings_view_(new NotifierSettingsView()) {
CreateTitleRow(IDS_ASH_MESSAGE_CENTER_FOOTER_TITLE);
AddChildView(settings_view_);
box_layout()->SetFlexForView(settings_view_, 1);
OnQuietModeChanged(message_center::MessageCenter::Get()->IsQuietMode());
message_center::MessageCenter::Get()->AddObserver(this);
}
~UnifiedNotifierSettingsView() override {
message_center::MessageCenter::Get()->RemoveObserver(this);
}
// MessageCenterObserver:
void OnQuietModeChanged(bool in_quiet_mode) override {
settings_view_->SetQuietModeState(in_quiet_mode);
}
private:
NotifierSettingsView* const settings_view_;
DISALLOW_COPY_AND_ASSIGN(UnifiedNotifierSettingsView);
};
} // namespace
UnifiedNotifierSettingsController::UnifiedNotifierSettingsController(
UnifiedSystemTrayController* tray_controller)
: detailed_view_delegate_(
std::make_unique<UnifiedDetailedViewDelegate>(tray_controller)) {}
UnifiedNotifierSettingsController::~UnifiedNotifierSettingsController() =
default;
views::View* UnifiedNotifierSettingsController::CreateView() {
return new UnifiedNotifierSettingsView(detailed_view_delegate_.get());
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_UNIFIED_UNIFIED_NOTIFIER_SETTINGS_CONTROLLER_H_
#define ASH_SYSTEM_UNIFIED_UNIFIED_NOTIFIER_SETTINGS_CONTROLLER_H_
#include <memory>
#include "ash/system/unified/detailed_view_controller.h"
#include "base/macros.h"
namespace ash {
class DetailedViewDelegate;
class UnifiedSystemTrayController;
// Controller of notifier settings detailed view in UnifiedSystemTray.
class UnifiedNotifierSettingsController : public DetailedViewController {
public:
explicit UnifiedNotifierSettingsController(
UnifiedSystemTrayController* tray_controller);
~UnifiedNotifierSettingsController() override;
// DetailedViewControllerBase:
views::View* CreateView() override;
private:
const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_;
DISALLOW_COPY_AND_ASSIGN(UnifiedNotifierSettingsController);
};
} // namespace ash
#endif // ASH_SYSTEM_UNIFIED_UNIFIED_NOTIFIER_SETTINGS_CONTROLLER_H_
......@@ -31,6 +31,7 @@
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/feature_pod_controller_base.h"
#include "ash/system/unified/quiet_mode_feature_pod_controller.h"
#include "ash/system/unified/unified_notifier_settings_controller.h"
#include "ash/system/unified/unified_system_tray_model.h"
#include "ash/system/unified/unified_system_tray_view.h"
#include "ash/system/unified/user_chooser_view.h"
......@@ -225,6 +226,10 @@ void UnifiedSystemTrayController::ShowAudioDetailedView() {
ShowDetailedView(std::make_unique<UnifiedAudioDetailedViewController>(this));
}
void UnifiedSystemTrayController::ShowNotifierSettingsView() {
ShowDetailedView(std::make_unique<UnifiedNotifierSettingsController>(this));
}
void UnifiedSystemTrayController::TransitionToMainView(bool restore_focus) {
detailed_view_controller_.reset();
unified_view_->ResetDetailedView();
......@@ -256,7 +261,7 @@ void UnifiedSystemTrayController::AnimationCanceled(
void UnifiedSystemTrayController::InitFeaturePods() {
AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>());
AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<RotationLockFeaturePodController>());
AddFeaturePodItem(std::make_unique<NightLightFeaturePodController>());
AddFeaturePodItem(std::make_unique<CastFeaturePodController>(this));
......
......@@ -71,6 +71,8 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
void ShowIMEDetailedView();
// Show the detailed view of audio. Called from the view.
void ShowAudioDetailedView();
// Show the detailed view of notifier settings. Called from the view.
void ShowNotifierSettingsView();
// If you want to add a new detailed view, add here.
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ash/system/unified_accessibility_detailed_view_controller.h"
#include "ash/accessibility/accessibility_controller.h"
#include "ash/shell.h"
#include "ash/system/tray_accessibility.h"
......
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