Commit 9091e3de authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Help text update for Click to Call dialog.

Updates the copy for the sync help text if there are no devices to
choose from.

Bug: 987596
Change-Id: I96b0224d7a29fe2598e44c16ee512a91bd848b23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719012Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681259}
parent 304cbbe6
......@@ -21,7 +21,7 @@
#include "ui/gfx/paint_vector_icon.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/border.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
......@@ -59,6 +59,21 @@ std::unique_ptr<views::ImageView> CreateDeviceIcon(
return CreateIconView(*vector_icon);
}
std::unique_ptr<views::StyledLabel> CreateHelpText(
views::StyledLabelListener* listener) {
const base::string16 link = l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TROUBLESHOOT_LINK);
size_t offset;
const base::string16 text = l10n_util::GetStringFUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES, link,
&offset);
auto label = std::make_unique<views::StyledLabel>(text, listener);
views::StyledLabel::RangeStyleInfo link_style =
views::StyledLabel::RangeStyleInfo::CreateForLink();
label->AddStyleRange(gfx::Range(offset, offset + link.length()), link_style);
return label;
}
} // namespace
ClickToCallDialogView::ClickToCallDialogView(
......@@ -85,27 +100,12 @@ std::unique_ptr<views::View> ClickToCallDialogView::CreateFootnoteView() {
if (!devices_.empty() || apps_.empty() || send_failed_)
return nullptr;
auto view = std::make_unique<views::View>();
view->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical));
auto label = std::make_unique<views::Label>(
l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES),
views::style::CONTEXT_LABEL, ChromeTextStyle::STYLE_SECONDARY);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
view->AddChildView(std::move(label));
auto link = std::make_unique<views::Link>(l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_SYNC_HELP_TEXT));
link->set_listener(this);
link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
view->AddChildView(std::move(link));
return view;
return CreateHelpText(this);
}
void ClickToCallDialogView::LinkClicked(views::Link* source, int event_flags) {
void ClickToCallDialogView::StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
controller_->OnHelpTextClicked();
}
......@@ -195,18 +195,7 @@ void ClickToCallDialogView::InitListView() {
void ClickToCallDialogView::InitEmptyView() {
LogClickToCallDialogShown(SharingClickToCallDialogType::kEducationalDialog);
auto label = std::make_unique<views::Label>(
l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES),
views::style::CONTEXT_LABEL, ChromeTextStyle::STYLE_SECONDARY);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(std::move(label));
auto link = std::make_unique<views::Link>(l10n_util::GetStringUTF16(
IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_SYNC_HELP_TEXT));
link->set_listener(this);
link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(std::move(link));
AddChildView(CreateHelpText(this));
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
auto image_view = std::make_unique<NonAccessibleImageView>();
......
......@@ -13,10 +13,10 @@
#include "chrome/browser/sharing/sharing_device_info.h"
#include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/link_listener.h"
#include "ui/views/controls/styled_label_listener.h"
namespace views {
class Link;
class StyledLabel;
class View;
} // namespace views
......@@ -25,7 +25,7 @@ class HoverButton;
class ClickToCallDialogView : public ClickToCallDialog,
public views::ButtonListener,
public views::LinkListener,
public views::StyledLabelListener,
public LocationBarBubbleDelegateView {
public:
// Bubble will be anchored to |anchor_view|.
......@@ -43,8 +43,10 @@ class ClickToCallDialogView : public ClickToCallDialog,
base::string16 GetWindowTitle() const override;
void WindowClosing() override;
// views::LinkListener:
void LinkClicked(views::Link* source, int event_flags) override;
// views::StyledLabelListener:
void StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) override;
// views::DialogDelegate:
int GetDialogButtons() const override;
......
......@@ -979,11 +979,11 @@ need to be translated for each locale.-->
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TITLE_FAILED_TO_SEND" desc="The label to be shown as the title of the dialog when user click on a phone number, if sending it to a device failed.">
Can't send number
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES" desc="The label to be shown as a help text of the dialog when user click on a phone number, if there are no phones or apps to choose from.">
To make a call from your phone, turn on sync.
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_HELP_TEXT_NO_DEVICES" desc="The label to be shown as a help text of the dialog when user click on a phone number, if there are no phones to choose from.">
To send a number from here to your phone, <ph name="TROUBLESHOOT_LINK">$1<ex>turn on sync</ex></ph> for both devices in settings.
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_SYNC_HELP_TEXT" desc="The label to be shown on the dialog when user click on a phone number for the link to a help page to turn on sync.">
Learn how to turn on sync
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_TROUBLESHOOT_LINK" desc="The label to be shown on the dialog when user click on a phone number for the link to a help page to turn on sync.">
turn on sync
</message>
<message name="IDS_BROWSER_SHARING_CLICK_TO_CALL_DIALOG_FAILED_MESSAGE" desc="The label to be shown on the dialog when user click on a phone number, if sending it to a device failed.">
Check your phone's connection and try again
......
0ba364c07952c23071c154045407d235ea8a2dbc
\ No newline at end of file
a5eae26416ab8f82745704c4f1e6610181f7353c
\ No newline at end of file
0ba364c07952c23071c154045407d235ea8a2dbc
\ No newline at end of file
a5eae26416ab8f82745704c4f1e6610181f7353c
\ No newline at end of file
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