Commit c2cff202 authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Add a button to open lock screen notification setting

This CL add a "Change" button to open lock screen notification setting
next to the message "Notifications are hidden" in the unified system
tray on the lock screen.

This CL just adds a button which doesn't work. The code to open the
setting is separated.

Bug: 864964
Test: manual (see the button in the unified systray)

Change-Id: I812fc1369d4020044e22874a83cafb187f173e31
Reviewed-on: https://chromium-review.googlesource.com/1176301
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585944}
parent 1e68ba12
......@@ -999,6 +999,8 @@ component("ash") {
"system/unified/ime_mode_view.h",
"system/unified/notification_counter_view.cc",
"system/unified/notification_counter_view.h",
"system/unified/notification_hidden_view.cc",
"system/unified/notification_hidden_view.h",
"system/unified/quiet_mode_feature_pod_controller.cc",
"system/unified/quiet_mode_feature_pod_controller.h",
"system/unified/sign_out_button.cc",
......
......@@ -1609,6 +1609,12 @@ This file contains the strings for ash.
<message name="IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_UNIFIED" desc="The label in the message center area on lock screen.">
Notifications are hidden.
</message>
<message name="IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_CHANGE" desc="The label in the button in the message center area on lock screen. This button is to open the setting of the lock scren notification.">
Change
</message>
<message name="IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_CHANGE_TOOLTIP" desc="The tooltip text for Change button to open the setting of lock screen notification.">
Change the lock-screen notification settings
</message>
<message name="IDS_ASH_MESSAGE_CENTER_NO_MESSAGES" desc="The message displayed in the message center when there are no notifications.">
All done
</message>
......
// 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/notification_hidden_view.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/unified/sign_out_button.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/lock_screen/lock_screen_controller.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_impl.h"
#include "ui/views/background.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
namespace ash {
NotificationHiddenView::NotificationHiddenView() {
const bool lock_screen_notification_enabled =
features::IsLockScreenNotificationsEnabled();
auto* label = new views::Label;
label->SetEnabledColor(kUnifiedMenuTextColor);
label->SetAutoColorReadabilityEnabled(false);
label->SetText(
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_UNIFIED));
label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
label->SetLineHeight(kUnifiedNotificationHiddenLineHeight);
label->SetBorder(views::CreateEmptyBorder(kUnifiedNotificationHiddenPadding));
auto* clear_all_button = new RoundedLabelButton(
this,
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_CHANGE));
clear_all_button->SetTooltipText(l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_CHANGE_TOOLTIP));
auto* container = new views::View;
container->SetBackground(views::CreateBackgroundFromPainter(
views::Painter::CreateSolidRoundRectPainter(kUnifiedMenuButtonColor,
kUnifiedTrayCornerRadius)));
auto* layout = container->SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal));
container->AddChildView(label);
layout->SetFlexForView(label, 1);
if (lock_screen_notification_enabled) {
container->AddChildView(clear_all_button);
}
SetBorder(
views::CreateEmptyBorder(gfx::Insets(kUnifiedNotificationCenterSpacing)));
SetLayoutManager(std::make_unique<views::FillLayout>());
AddChildView(container);
}
void NotificationHiddenView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
// TODO(yoshiki): Refactor LockScreenController and remove the static cast.
// TODO(yoshiki): Show the setting after unlocking.
static_cast<message_center::MessageCenterImpl*>(
message_center::MessageCenter::Get())
->lock_screen_controller()
->DismissLockScreenThenExecute(base::DoNothing(), base::DoNothing());
}
} // 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_NOTIFICATION_HIDDEN_VIEW_H_
#define ASH_SYSTEM_UNIFIED_NOTIFICATION_HIDDEN_VIEW_H_
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
namespace ash {
// A view to show the message that notifications are hidden on the lock screen
// by the setting or the flag. This may show the button to encourage the user
// to change the lock screen notification setting if the condition permits.
class NotificationHiddenView : public views::View, views::ButtonListener {
public:
NotificationHiddenView();
~NotificationHiddenView() override = default;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
DISALLOW_COPY_AND_ASSIGN(NotificationHiddenView);
};
} // namespace ash
#endif // ASH_SYSTEM_UNIFIED_NOTIFICATION_HIDDEN_VIEW_H_
......@@ -9,27 +9,24 @@
#include "ash/public/cpp/ash_features.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/interacted_by_tap_recorder.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/feature_pods_container_view.h"
#include "ash/system/unified/notification_hidden_view.h"
#include "ash/system/unified/top_shortcuts_view.h"
#include "ash/system/unified/unified_message_center_view.h"
#include "ash/system/unified/unified_system_info_view.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "ash/system/unified/unified_system_tray_model.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/label.h"
#include "ui/views/focus/focus_search.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/painter.h"
#include "ui/views/widget/widget.h"
......@@ -37,29 +34,6 @@ namespace ash {
namespace {
// Create a view to show the message that notifications are hidden. Shown when
// screen is locked.
views::View* CreateNotificationHiddenView() {
auto* label = new views::Label;
label->SetEnabledColor(kUnifiedMenuTextColor);
label->SetAutoColorReadabilityEnabled(false);
label->SetText(
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_LOCKSCREEN_UNIFIED));
label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
label->SetLineHeight(kUnifiedNotificationHiddenLineHeight);
label->SetBorder(views::CreateEmptyBorder(kUnifiedNotificationHiddenPadding));
label->SetBackground(views::CreateBackgroundFromPainter(
views::Painter::CreateSolidRoundRectPainter(kUnifiedMenuButtonColor,
kUnifiedTrayCornerRadius)));
auto* view = new views::View;
view->SetBorder(
views::CreateEmptyBorder(gfx::Insets(kUnifiedNotificationCenterSpacing)));
view->SetLayoutManager(std::make_unique<views::FillLayout>());
view->AddChildView(label);
return view;
}
// Border applied to SystemTrayContainer and DetailedViewContainer to iminate
// notification list scrolling under SystemTray part of UnifiedSystemTray.
// The border paints mock notification frame behind the top corners based on
......@@ -239,7 +213,7 @@ UnifiedSystemTrayView::UnifiedSystemTrayView(
bool initially_expanded)
: expanded_amount_(initially_expanded ? 1.0 : 0.0),
controller_(controller),
notification_hidden_view_(CreateNotificationHiddenView()),
notification_hidden_view_(new NotificationHiddenView()),
top_shortcuts_view_(new TopShortcutsView(controller_)),
feature_pods_container_(new FeaturePodsContainerView(initially_expanded)),
sliders_container_(new UnifiedSlidersContainerView(initially_expanded)),
......
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