Commit 12146c01 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Add dark mode feature pod.

This CL adds skeleton code for the dark mode feature pod.

Bug: 1106012
Change-Id: Icb4046bf25fd90482a69588611445a2604c39247
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339289
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796726}
parent cb2914f5
......@@ -878,6 +878,8 @@ component("ash") {
"system/cast/tray_cast.h",
"system/cast/unified_cast_detailed_view_controller.cc",
"system/cast/unified_cast_detailed_view_controller.h",
"system/dark_mode/dark_mode_feature_pod_controller.cc",
"system/dark_mode/dark_mode_feature_pod_controller.h",
"system/enterprise/enterprise_domain_observer.h",
"system/gesture_education/gesture_education_notification_controller.cc",
"system/gesture_education/gesture_education_notification_controller.h",
......
......@@ -327,6 +327,27 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP" desc="The label used in the tray popup to tell the user we are casting the desktop.">
Casting screen to <ph name="RECEIVER_NAME">$1<ex>Living Room</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_BUTTON_LABEL" desc="The shorter label used for the button in the status tray to toggle the Dark Mode feature (which controls the color temperature of the screen) on or off. [CHAR_LIMIT=14]">
Dark Mode
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_TOGGLE_TOOLTIP" desc="The tooltip text used for the button in the status tray to toggle the Dark Mode feature (which controls the color temperature of the screen) on or off.">
Toggle Dark Mode. <ph name="STATE_TEXT">$1<ex>Dark Mode is on.</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_ENABLED_STATE_TOOLTIP" desc="The tooltip text indicating the Dark Mode feature is on.">
Dark Mode is on.
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_DISABLED_STATE_TOOLTIP" desc="The tooltip text indicating the Dark Mode feature is off.">
Dark Mode is off.
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_SETTINGS_TOOLTIP" desc="The tooltip text used for the button in the status tray to show the Dark Mode feature (which controls the color temperature of the screen) settings.">
Show dark mode settings
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_OFF_STATE" desc="Button label for the Dark Mode feature." meaning="Dark Mode feature is off. [CHAR_LIMIT=14]">
Off
</message>
<message name="IDS_ASH_STATUS_TRAY_DARK_MODE_ON_STATE" desc="Button label for the Dark Mode feature." meaning="Dark Mode feature is on. [CHAR_LIMIT=14]">
On
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP_ACCESSIBILITY_STOP" desc="Stop button accessibility label used in the tray popup to tell the user to stop a cast to the desktop.">
Stop casting screen to <ph name="RECEIVER_NAME">$1<ex>Living Room</ex></ph>
</message>
......
b892fca63156aa42e5d4d2700cd4aa4764f96ce5
\ No newline at end of file
59a5e1355448f6dde367ffd0ba6003357259df40
\ No newline at end of file
effba266de5e3b9897f8ca0f75b62e64d7283528
\ No newline at end of file
87c3f620147db29ff48afa7be1b2499376a0cd84
\ No newline at end of file
b892fca63156aa42e5d4d2700cd4aa4764f96ce5
\ No newline at end of file
59a5e1355448f6dde367ffd0ba6003357259df40
\ No newline at end of file
adf958e8343448faee9d7fa20015b599fc1ec86f
\ No newline at end of file
......@@ -281,6 +281,7 @@ aggregate_vector_icons("ash_vector_icons") {
"unified_menu_bluetooth.icon",
"unified_menu_brightness.icon",
"unified_menu_cast.icon",
"unified_menu_dark_mode.icon",
"unified_menu_do_not_disturb.icon",
"unified_menu_expand.icon",
"unified_menu_info.icon",
......
// 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.
CANVAS_DIMENSIONS, 40,
MOVE_TO, 20, 36,
R_CUBIC_TO, 8.84f, 0, 16, -7.16f, 16, -16,
CUBIC_TO_SHORTHAND, 28.84f, 4, 20, 4,
CUBIC_TO_SHORTHAND, 4, 11.16f, 4, 20,
R_CUBIC_TO, 0, 8.84f, 7.16f, 16, 16, 16,
CLOSE,
R_MOVE_TO, 0, -28.23f,
R_CUBIC_TO, 6.76f, 0, 12.24f, 5.48f, 12.24f, 12.24f,
CUBIC_TO_SHORTHAND, 26.76f, 32.24f, 20, 32.24f,
V_LINE_TO, 7.77f,
CLOSE
CANVAS_DIMENSIONS, 20,
MOVE_TO, 10, 18,
R_CUBIC_TO, 4.42f, 0, 8, -3.58f, 8, -8,
R_CUBIC_TO, 0, -4.42f, -3.58f, -8, -8, -8,
R_CUBIC_TO, -4.42f, 0, -8, 3.58f, -8, 8,
R_CUBIC_TO, 0, 4.42f, 3.58f, 8, 8, 8,
CLOSE,
R_MOVE_TO, 0, -14.12f,
R_CUBIC_TO, 3.38f, 0, 6.12f, 2.74f, 6.12f, 6.12f,
R_CUBIC_TO, 0, 3.38f, -2.74f, 6.12f, -6.12f, 6.12f,
V_LINE_TO, 3.88f,
CLOSE
amehfooz@chromium.org
tengs@chromium.org
\ No newline at end of file
// Copyright 2020 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/dark_mode/dark_mode_feature_pod_controller.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
DarkModeFeaturePodController::DarkModeFeaturePodController(
UnifiedSystemTrayController* tray_controller)
: tray_controller_(tray_controller) {
DCHECK(tray_controller_);
}
DarkModeFeaturePodController::~DarkModeFeaturePodController() = default;
FeaturePodButton* DarkModeFeaturePodController::CreateButton() {
DCHECK(!button_);
button_ = new FeaturePodButton(this);
button_->SetVectorIcon(kUnifiedMenuDarkModeIcon);
button_->SetLabel(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DARK_MODE_BUTTON_LABEL));
button_->SetLabelTooltip(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_DARK_MODE_SETTINGS_TOOLTIP));
UpdateButton();
return button_;
}
void DarkModeFeaturePodController::OnIconPressed() {
// TODO: Switch dark mode here.
UpdateButton();
// TODO(amehfooz): Add metrics recording here.
}
void DarkModeFeaturePodController::OnLabelPressed() {
// TODO(amehfooz): Add entry to detailed view here.
}
SystemTrayItemUmaType DarkModeFeaturePodController::GetUmaType() const {
// TODO(amehfooz): Add new UMA type here.
return SystemTrayItemUmaType::UMA_DARK_MODE;
}
void DarkModeFeaturePodController::UpdateButton() {
const bool is_enabled = AshColorProvider::Get()->color_mode() ==
AshColorProvider::AshColorMode::kDark;
button_->SetToggled(is_enabled);
button_->SetSubLabel(l10n_util::GetStringUTF16(
is_enabled ? IDS_ASH_STATUS_TRAY_DARK_MODE_ON_STATE
: IDS_ASH_STATUS_TRAY_DARK_MODE_OFF_STATE));
base::string16 tooltip_state = l10n_util::GetStringUTF16(
is_enabled ? IDS_ASH_STATUS_TRAY_DARK_MODE_ENABLED_STATE_TOOLTIP
: IDS_ASH_STATUS_TRAY_DARK_MODE_DISABLED_STATE_TOOLTIP);
button_->SetIconTooltip(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DARK_MODE_TOGGLE_TOOLTIP, tooltip_state));
}
} // namespace ash
// Copyright 2020 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_DARK_MODE_DARK_MODE_FEATURE_POD_CONTROLLER_H_
#define ASH_SYSTEM_DARK_MODE_DARK_MODE_FEATURE_POD_CONTROLLER_H_
#include "ash/system/unified/feature_pod_controller_base.h"
#include "base/macros.h"
namespace ash {
class UnifiedSystemTrayController;
// Controller of a feature pod button that toggles dark mode for ash.
class DarkModeFeaturePodController : public FeaturePodControllerBase {
public:
explicit DarkModeFeaturePodController(
UnifiedSystemTrayController* tray_controller);
DarkModeFeaturePodController(const DarkModeFeaturePodController& other) =
delete;
DarkModeFeaturePodController& operator=(
const DarkModeFeaturePodController& other) = delete;
~DarkModeFeaturePodController() override;
// FeaturePodControllerBase:
FeaturePodButton* CreateButton() override;
void OnIconPressed() override;
void OnLabelPressed() override;
SystemTrayItemUmaType GetUmaType() const override;
private:
void UpdateButton();
UnifiedSystemTrayController* const tray_controller_;
FeaturePodButton* button_ = nullptr;
};
} // namespace ash
#endif // ASH_SYSTEM_DARK_MODE_DARK_MODE_FEATURE_POD_CONTROLLER_H_
......@@ -44,7 +44,8 @@ enum class SystemTrayItemUmaType {
UMA_QUIET_MODE = 27,
UMA_LOCALE = 28,
UMA_PRIVACY_SCREEN = 29,
UMA_COUNT = 30,
UMA_DARK_MODE = 30,
UMA_COUNT = 31,
};
} // namespace ash
......
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