focus-mode: Finalize the text and tooltip for offline state
This CL will finalize the text and tooltip for the task view and sounds view when it's offline. Bug: b/288975135 Test: Manual Change-Id: I22ad3efd84f3d29712a638c6e80b8032771cd93a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5608914 Commit-Queue: Hongyu Long <hongyulong@chromium.org> Reviewed-by: Richard Chui <richui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1312375}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
771f8b9260
commit
7da5a69ebb
@ -796,8 +796,8 @@ Style notes:
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_SUBHEADER" desc="The text used for the subheader of the task section of the focus mode detailed view.">
|
||||
Google Tasks
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_OFFLINE_SUBHEADER" translateable="false" desc="The text used for the subheader of the task section of the focus mode detailed view when the user is offline.">
|
||||
Google Tasks · Offline
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_OFFLINE_TOOLTIP" desc="The text used for the tooltip text of the task section of the focus mode detailed view when the user is offline.">
|
||||
You're offline. Check your connection and try again.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_TEXTFIELD_PLACEHOLDER" desc="The text used for the placeholder for the textfield in the task section of the focus mode detailed view.">
|
||||
What would you like to focus on?
|
||||
@ -823,8 +823,11 @@ Style notes:
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_LEARN_MORE_BUTTON" desc="The text on the learn more button.">
|
||||
Learn more
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_OFFLINE_LABEL" translateable="false" desc="The text shown to the user in the sounds view when they are offline.">
|
||||
You are not connected to the internet
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_OFFLINE_LABEL_ONE" desc="The text shown to the user in the first line of the sounds view when they are offline.">
|
||||
You're offline.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_OFFLINE_LABEL_TWO" desc="The text shown to the user in the second line of the sounds view when they are offline.">
|
||||
Check your connection and try again.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_DO_NOT_DISTURB" desc="The label text shown on the left side of do not disturb button in Focus mode settings panel.">
|
||||
Do Not Disturb while in Focus
|
||||
|
@ -0,0 +1 @@
|
||||
806ed3a116a9b94e94e3f644b4d8a9936d614c22
|
@ -0,0 +1 @@
|
||||
061536f91e529289630d2bd67abc053102802970
|
@ -0,0 +1 @@
|
||||
106dc8bdcbd03ce8e5de3c0b1ba42ef0d1d65023
|
@ -735,10 +735,8 @@ void FocusModeDetailedView::CreateTaskView(bool is_network_connected) {
|
||||
// Create the task header.
|
||||
auto* task_view_header =
|
||||
task_view_container_->AddChildView(std::make_unique<views::Label>());
|
||||
task_view_header->SetText(l10n_util::GetStringUTF16(
|
||||
is_network_connected
|
||||
? IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_SUBHEADER
|
||||
: IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_OFFLINE_SUBHEADER));
|
||||
task_view_header->SetText(
|
||||
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_SUBHEADER));
|
||||
task_view_header->SetHorizontalAlignment(
|
||||
gfx::HorizontalAlignment::ALIGN_TO_HEAD);
|
||||
task_view_header->SetBorder(views::CreateEmptyBorder(kTaskViewHeaderInsets));
|
||||
|
@ -88,6 +88,18 @@ class FocusModeTaskView::TaskTextfield : public SystemTextfield {
|
||||
show_selected_state_ = show_selected_state;
|
||||
}
|
||||
|
||||
std::u16string GetTooltipText() const { return tooltip_text_; }
|
||||
|
||||
void SetTooltipText(const std::u16string& tooltip_text) {
|
||||
if (tooltip_text_ == tooltip_text) {
|
||||
return;
|
||||
}
|
||||
|
||||
tooltip_text_ = tooltip_text;
|
||||
TooltipTextChanged();
|
||||
OnPropertyChanged(&tooltip_text_, views::kPropertyEffectsNone);
|
||||
}
|
||||
|
||||
void UpdateElideBehavior(bool active) {
|
||||
GetRenderText()->SetElideBehavior(active ? gfx::NO_ELIDE : gfx::ELIDE_TAIL);
|
||||
}
|
||||
@ -116,15 +128,18 @@ class FocusModeTaskView::TaskTextfield : public SystemTextfield {
|
||||
|
||||
// views::View:
|
||||
std::u16string GetTooltipText(const gfx::Point& p) const override {
|
||||
return show_selected_state_ ? GetText() : std::u16string();
|
||||
return tooltip_text_;
|
||||
}
|
||||
|
||||
private:
|
||||
// True if `FocusModeTaskView` has a selected task.
|
||||
bool show_selected_state_ = false;
|
||||
|
||||
std::u16string tooltip_text_;
|
||||
};
|
||||
|
||||
BEGIN_METADATA(FocusModeTaskView, TaskTextfield)
|
||||
ADD_PROPERTY_METADATA(std::u16string, TooltipText)
|
||||
END_METADATA
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -511,6 +526,11 @@ void FocusModeTaskView::UpdateStyle(bool show_selected_state,
|
||||
kIconSize));
|
||||
|
||||
textfield_->set_show_selected_state(show_selected_state);
|
||||
textfield_->SetTooltipText(
|
||||
is_network_connected
|
||||
? (show_selected_state ? textfield_->GetText() : std::u16string())
|
||||
: l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_FOCUS_MODE_TASK_OFFLINE_TOOLTIP));
|
||||
textfield_->GetViewAccessibility().SetName(
|
||||
show_selected_state
|
||||
? l10n_util::GetStringFUTF16(
|
||||
|
@ -50,6 +50,7 @@ constexpr int kNonPremiumChildViewsSpacing = 16;
|
||||
constexpr int kNonPremiumLabelViewMaxWidth = 288;
|
||||
|
||||
constexpr float kOfflineStateOpacity = 0.38f;
|
||||
constexpr auto kLabelPadding = gfx::Insets::VH(0, 40);
|
||||
|
||||
std::optional<int> GetYouTubeMusicIconResourceId() {
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
@ -105,19 +106,27 @@ std::unique_ptr<views::BoxLayoutView> CreateNonPremiumView() {
|
||||
return box_view;
|
||||
}
|
||||
|
||||
std::unique_ptr<views::BoxLayoutView> CreateOfflineStateView() {
|
||||
auto box_view = std::make_unique<views::BoxLayoutView>();
|
||||
box_view->SetOrientation(views::BoxLayout::Orientation::kVertical);
|
||||
box_view->SetCrossAxisAlignment(
|
||||
views::BoxLayout::CrossAxisAlignment::kCenter);
|
||||
|
||||
auto* label = box_view->AddChildView(
|
||||
std::make_unique<views::Label>(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_OFFLINE_LABEL)));
|
||||
std::unique_ptr<views::Label> CreateOfflineLabel(const int message_id) {
|
||||
auto label =
|
||||
std::make_unique<views::Label>(l10n_util::GetStringUTF16(message_id));
|
||||
label->SetFontList(ash::TypographyProvider::Get()->ResolveTypographyToken(
|
||||
ash::TypographyToken::kCrosBody2));
|
||||
label->SetEnabledColorId(cros_tokens::kCrosSysOnSurface);
|
||||
label->SetMultiLine(true);
|
||||
label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER);
|
||||
return label;
|
||||
}
|
||||
|
||||
std::unique_ptr<views::BoxLayoutView> CreateOfflineStateView() {
|
||||
auto box_view = std::make_unique<views::BoxLayoutView>();
|
||||
box_view->SetOrientation(views::BoxLayout::Orientation::kVertical);
|
||||
box_view->SetBorder(views::CreateEmptyBorder(kLabelPadding));
|
||||
box_view->SetCrossAxisAlignment(
|
||||
views::BoxLayout::CrossAxisAlignment::kCenter);
|
||||
box_view->AddChildView(CreateOfflineLabel(
|
||||
IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_OFFLINE_LABEL_ONE));
|
||||
box_view->AddChildView(CreateOfflineLabel(
|
||||
IDS_ASH_STATUS_TRAY_FOCUS_MODE_SOUNDS_OFFLINE_LABEL_TWO));
|
||||
return box_view;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user