Commit cdc6f428 authored by Yue Li's avatar Yue Li Committed by Commit Bot

Quick Answers: Move more A11y strings into grd file

Bug: b/149758492
Test: Manual Test
Change-Id: I66fe3baa162659f22ae4e756ac364861d60f12b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2516390
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823752}
parent 82064acd
...@@ -2891,6 +2891,30 @@ Here are some things you can try to get started. ...@@ -2891,6 +2891,30 @@ Here are some things you can try to get started.
<message name="IDS_ASH_QUICK_ANSWERS_USER_NOTICE_VIEW_A11Y_INFO_DESC_TEMPLATE" desc="A11y description template for the Quick Answers user notice view."> <message name="IDS_ASH_QUICK_ANSWERS_USER_NOTICE_VIEW_A11Y_INFO_DESC_TEMPLATE" desc="A11y description template for the Quick Answers user notice view.">
<ph name="DESC_TEXT">$1<ex>With a right-click or a long press, Assistant shows info such as the definition, translation or unit conversion for your selection.</ex></ph> Use Left or Right arrow keys to manage this feature. <ph name="DESC_TEXT">$1<ex>With a right-click or a long press, Assistant shows info such as the definition, translation or unit conversion for your selection.</ex></ph> Use Left or Right arrow keys to manage this feature.
</message> </message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_LOADING" desc="Display text when the Quick Answers view is loading.">
Loading...
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_NETWORK_ERROR" desc="Display text when network error occurs in the Quick Answers view.">
Cannot connect to internet.
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_RETRY" desc="Display text when the Quick Answers view is retry.">
Retry
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_INFO_ALERT_TEXT" desc="A11y alert text for the Quick Answers view.">
Info related to your selection available. Use Up arrow key to access.
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_INFO_DESC_TEMPLATE" desc="A11y description template for the Quick Answers view.">
<ph name="DESC_TEXT">$1<ex>Query texts</ex></ph>; Click the dialog to see result in Assistant.
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_NAME_TEXT" desc="A11y name text for the Quick Answers view.">
Info related to your selection
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_RETRY_LABEL_DESC" desc="A11y retry label description for the Quick Answers view.">
Cannot connect to the internet. Click to try again.
</message>
<message name="IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_RETRY_LABEL_NAME_TEMPLATE" desc="A11y retry label name template for the Quick Answers view.">
<ph name="DESC_TEXT">$1<ex>Cannot connect to the internet. Click to try again.</ex></ph>: Retry
</message>
<!-- Media Notification --> <!-- Media Notification -->
<message name="IDS_ASH_MEDIA_NOTIFICATION_ACTION_PREVIOUS_TRACK" desc="The button to trigger media playback to go to the previous track."> <message name="IDS_ASH_MEDIA_NOTIFICATION_ACTION_PREVIOUS_TRACK" desc="The button to trigger media playback to go to the previous track.">
......
f84d1c5b4a95681de2f200c338b9c3f4a04e57c8
\ No newline at end of file
a54a9781638401dc399f5aa506d1db54944abda7
\ No newline at end of file
a54a9781638401dc399f5aa506d1db54944abda7
\ No newline at end of file
73b923c3df266a2b4aaa45053e96e0663a1d1bee
\ No newline at end of file
73b923c3df266a2b4aaa45053e96e0663a1d1bee
\ No newline at end of file
3233246718c54ce2806f0b698326ffcc229b3c7d
\ No newline at end of file
a1fe5e969ddcc39a7cdf9101a788ec1c80d2704b
\ No newline at end of file
a1fe5e969ddcc39a7cdf9101a788ec1c80d2704b
\ No newline at end of file
...@@ -61,27 +61,11 @@ constexpr int kLineHeightDip = 20; ...@@ -61,27 +61,11 @@ constexpr int kLineHeightDip = 20;
// Spacing between labels in the horizontal elements view. // Spacing between labels in the horizontal elements view.
constexpr int kLabelSpacingDip = 2; constexpr int kLabelSpacingDip = 2;
// TODO(llin): Move to grd after confirming specs (b/149758492).
constexpr char kDefaultLoadingStr[] = "Loading...";
constexpr char kDefaultRetryStr[] = "Retry";
constexpr char kNetworkErrorStr[] = "Cannot connect to internet.";
// Dogfood button. // Dogfood button.
constexpr int kDogfoodButtonMarginDip = 4; constexpr int kDogfoodButtonMarginDip = 4;
constexpr int kDogfoodButtonSizeDip = 20; constexpr int kDogfoodButtonSizeDip = 20;
constexpr SkColor kDogfoodButtonColor = gfx::kGoogleGrey500; constexpr SkColor kDogfoodButtonColor = gfx::kGoogleGrey500;
// Accessibility.
// TODO(siabhijeet): Move to grd (tracked in b/149758492).
constexpr char kA11yAlertAnnouncement[] =
"Info related to your selection available. Use Up arrow key to access.";
constexpr char kA11yNameText[] = "Info related to your selection";
constexpr char kA11yDescTemplate[] =
"%s; Click the dialog to see result in Assistant.";
constexpr char kA11yRetryLabelNameTemplate[] = "%s: Retry";
constexpr char kA11yRetryLabelDesc[] =
"Cannot connect to the internet. Click to try again.";
// Maximum height QuickAnswersView can expand to. // Maximum height QuickAnswersView can expand to.
int MaximumViewHeight() { int MaximumViewHeight() {
return kMainViewInsets.height() + kContentViewInsets.height() + return kMainViewInsets.height() + kContentViewInsets.height() +
...@@ -199,7 +183,8 @@ void QuickAnswersView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -199,7 +183,8 @@ void QuickAnswersView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
} }
node_data->role = ax::mojom::Role::kDialog; node_data->role = ax::mojom::Role::kDialog;
node_data->SetName(kA11yNameText); node_data->SetName(
l10n_util::GetStringUTF8(IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_NAME_TEXT));
} }
std::vector<views::View*> QuickAnswersView::GetFocusableViews() { std::vector<views::View*> QuickAnswersView::GetFocusableViews() {
...@@ -260,8 +245,9 @@ void QuickAnswersView::ShowRetryView() { ...@@ -260,8 +245,9 @@ void QuickAnswersView::ShowRetryView() {
// Add error label. // Add error label.
std::vector<std::unique_ptr<QuickAnswerUiElement>> description_labels; std::vector<std::unique_ptr<QuickAnswerUiElement>> description_labels;
description_labels.push_back( description_labels.push_back(std::make_unique<QuickAnswerText>(
std::make_unique<QuickAnswerText>(kNetworkErrorStr, gfx::kGoogleGrey700)); l10n_util::GetStringUTF8(IDS_ASH_QUICK_ANSWERS_VIEW_NETWORK_ERROR),
gfx::kGoogleGrey700));
auto* description_container = auto* description_container =
AddHorizontalUiElements(description_labels, content_view_); AddHorizontalUiElements(description_labels, content_view_);
...@@ -270,13 +256,16 @@ void QuickAnswersView::ShowRetryView() { ...@@ -270,13 +256,16 @@ void QuickAnswersView::ShowRetryView() {
description_container->AddChildView(std::make_unique<views::LabelButton>( description_container->AddChildView(std::make_unique<views::LabelButton>(
base::BindRepeating(&QuickAnswersUiController::OnRetryLabelPressed, base::BindRepeating(&QuickAnswersUiController::OnRetryLabelPressed,
base::Unretained(controller_)), base::Unretained(controller_)),
base::UTF8ToUTF16(kDefaultRetryStr))); l10n_util::GetStringUTF16(IDS_ASH_QUICK_ANSWERS_VIEW_RETRY)));
retry_label_->SetEnabledTextColors(gfx::kGoogleBlue600); retry_label_->SetEnabledTextColors(gfx::kGoogleBlue600);
retry_label_->SetRequestFocusOnPress(true); retry_label_->SetRequestFocusOnPress(true);
SetButtonNotifyActionToOnPress(retry_label_); SetButtonNotifyActionToOnPress(retry_label_);
retry_label_->SetAccessibleName(base::UTF8ToUTF16( retry_label_->SetAccessibleName(l10n_util::GetStringFUTF16(
base::StringPrintf(kA11yRetryLabelNameTemplate, kA11yNameText))); IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_RETRY_LABEL_NAME_TEMPLATE,
retry_label_->GetViewAccessibility().OverrideDescription(kA11yRetryLabelDesc); l10n_util::GetStringUTF16(IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_NAME_TEXT)));
retry_label_->GetViewAccessibility().OverrideDescription(
l10n_util::GetStringUTF8(
IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_RETRY_LABEL_DESC));
} }
void QuickAnswersView::AddAssistantIcon() { void QuickAnswersView::AddAssistantIcon() {
...@@ -328,7 +317,9 @@ void QuickAnswersView::InitLayout() { ...@@ -328,7 +317,9 @@ void QuickAnswersView::InitLayout() {
views::BoxLayout::Orientation::kVertical, kContentViewInsets, views::BoxLayout::Orientation::kVertical, kContentViewInsets,
kLineSpacingDip)); kLineSpacingDip));
AddTextElement({title_}, content_view_); AddTextElement({title_}, content_view_);
AddTextElement({kDefaultLoadingStr, gfx::kGoogleGrey700}, content_view_); AddTextElement({l10n_util::GetStringUTF8(IDS_ASH_QUICK_ANSWERS_VIEW_LOADING),
gfx::kGoogleGrey700},
content_view_);
// Add dogfood button, if in dogfood. // Add dogfood button, if in dogfood.
if (chromeos::features::IsQuickAnswersDogfood()) if (chromeos::features::IsQuickAnswersDogfood())
...@@ -412,8 +403,9 @@ void QuickAnswersView::UpdateQuickAnswerResult( ...@@ -412,8 +403,9 @@ void QuickAnswersView::UpdateQuickAnswerResult(
// Update answer announcement. // Update answer announcement.
auto* answer_label = auto* answer_label =
static_cast<Label*>(first_answer_view->children().front()); static_cast<Label*>(first_answer_view->children().front());
GetViewAccessibility().OverrideDescription(base::StringPrintf( GetViewAccessibility().OverrideDescription(l10n_util::GetStringFUTF8(
kA11yDescTemplate, base::UTF16ToUTF8(answer_label->GetText()).c_str())); IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_INFO_DESC_TEMPLATE,
answer_label->GetText()));
} }
// Add second row answer. // Add second row answer.
...@@ -436,8 +428,8 @@ void QuickAnswersView::UpdateQuickAnswerResult( ...@@ -436,8 +428,8 @@ void QuickAnswersView::UpdateQuickAnswerResult(
RequestFocus(); RequestFocus();
} else { } else {
// Announce that a Quick Answer is available. // Announce that a Quick Answer is available.
GetViewAccessibility().AnnounceText( GetViewAccessibility().AnnounceText(l10n_util::GetStringUTF16(
base::UTF8ToUTF16(kA11yAlertAnnouncement)); IDS_ASH_QUICK_ANSWERS_VIEW_A11Y_INFO_ALERT_TEXT));
} }
} }
......
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