Commit 8cecfee8 authored by Li Lin's avatar Li Lin Committed by Commit Bot

Update Quick Answers consent title and description.

Based on feedback, update the notice which better represents the
functionality of the feature and includes relevant information about
the user's selection.

Mock at: go/quick-answers(slide 28)

Bug: b/159167345
Test: manual tests
Change-Id: I28df28fb025e42292ccdf5eb4d273c5b78a056d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250586
Commit-Queue: Li Lin <llin@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782145}
parent a9413ff7
...@@ -2437,11 +2437,23 @@ Here are some things you can try to get started. ...@@ -2437,11 +2437,23 @@ Here are some things you can try to get started.
<message name="IDS_ASH_QUICK_ANSWERS_DOGFOOD_BUTTON_TOOLTIP_TEXT" desc="Tooltip text for the dogfood-button within Quick-Answers related views to help users file bugs easily."> <message name="IDS_ASH_QUICK_ANSWERS_DOGFOOD_BUTTON_TOOLTIP_TEXT" desc="Tooltip text for the dogfood-button within Quick-Answers related views to help users file bugs easily.">
File feedback File feedback
</message> </message>
<message name="IDS_ASH_QUICK_ANSWERS_DEFINITION_INTENT" desc="Display text of definition intent. This is used in the title of Quick Answers user consent dialog.">
definition
</message>
<message name="IDS_ASH_QUICK_ANSWERS_TRANSLATION_INTENT" desc="Display text of translation intent. This is used in the title of Quick Answers user consent dialog.">
translation
</message>
<message name="IDS_ASH_QUICK_ANSWERS_UNIT_CONVERSION_INTENT" desc="Display text of unit conversion intent. This is used in the title of Quick Answers user consent dialog.">
conversion
</message>
<message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT" desc="Title text of the dialog that opens up to seek user-consent for the Quick Answers feature."> <message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT" desc="Title text of the dialog that opens up to seek user-consent for the Quick Answers feature.">
Get info related to your selection Get info related to your selection
</message> </message>
<message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT_WITH_INTENT" desc="Title text of the dialog that opens up to seek user-consent for the Quick Answers feature when supported intent is generated.">
Get the <ph name="intent">$1<ex>definition</ex></ph> for "<ph name="query">$2<ex>unfathomable</ex></ph>"
</message>
<message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_DESC_TEXT" desc="Description in the dialog that opens up to seek user-consent for the Quick Answers feature."> <message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_DESC_TEXT" desc="Description in the dialog that opens up to seek user-consent for the Quick Answers feature.">
With a right click or long press, Assistant shows you info related to what you select on the screen. With a right-click or a long press, Assistant shows info such as the definition or unit conversion for your selection.
</message> </message>
<message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_MANAGE_SETTINGS_BUTTON" desc="Display text on the Manage-Settings button in the dialog that opens up to seek user-consent for the Quick Answers feature."> <message name="IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_MANAGE_SETTINGS_BUTTON" desc="Display text on the Manage-Settings button in the dialog that opens up to seek user-consent for the Quick Answers feature.">
Manage Settings Manage Settings
......
0c2be95e7f1f00e2c5f9af99ffd184e1aab94a41
\ No newline at end of file
3aa7311dedde2fb5606147c54c1c192c8300a140
\ No newline at end of file
979ca2aaa8fd05ca61b6a707c41916b0b65f6b01
\ No newline at end of file
52fbb33419a28bf5ff088d208eed11e7f69123af e512771795e84328ecc069b5e40f56541d5b7eb9
\ No newline at end of file \ No newline at end of file
0c2be95e7f1f00e2c5f9af99ffd184e1aab94a41
\ No newline at end of file
...@@ -11,11 +11,13 @@ ...@@ -11,11 +11,13 @@
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "chromeos/components/quick_answers/quick_answers_consents.h" #include "chromeos/components/quick_answers/quick_answers_consents.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h" #include "url/gurl.h"
// TODO(yanxiao):Add a unit test for QuickAnswersControllerImpl. // TODO(yanxiao):Add a unit test for QuickAnswersControllerImpl.
namespace { namespace {
using chromeos::quick_answers::Context; using chromeos::quick_answers::Context;
using chromeos::quick_answers::IntentType;
using chromeos::quick_answers::QuickAnswer; using chromeos::quick_answers::QuickAnswer;
using chromeos::quick_answers::QuickAnswersClient; using chromeos::quick_answers::QuickAnswersClient;
using chromeos::quick_answers::QuickAnswersRequest; using chromeos::quick_answers::QuickAnswersRequest;
...@@ -28,6 +30,21 @@ constexpr char kDogfoodUrl[] = ...@@ -28,6 +30,21 @@ constexpr char kDogfoodUrl[] =
// TODO:(yanxiao) move the string to grd source file. // TODO:(yanxiao) move the string to grd source file.
constexpr char kNoResult[] = "See result in Assistant"; constexpr char kNoResult[] = "See result in Assistant";
base::string16 IntentTypeToString(IntentType intent_type) {
switch (intent_type) {
case IntentType::kUnit:
return l10n_util::GetStringUTF16(
IDS_ASH_QUICK_ANSWERS_UNIT_CONVERSION_INTENT);
case IntentType::kDictionary:
return l10n_util::GetStringUTF16(IDS_ASH_QUICK_ANSWERS_DEFINITION_INTENT);
case IntentType::kTranslation:
return l10n_util::GetStringUTF16(
IDS_ASH_QUICK_ANSWERS_TRANSLATION_INTENT);
case IntentType::kUnknown:
return base::string16();
}
}
} // namespace } // namespace
namespace ash { namespace ash {
...@@ -66,7 +83,7 @@ void QuickAnswersControllerImpl::MaybeShowQuickAnswers( ...@@ -66,7 +83,7 @@ void QuickAnswersControllerImpl::MaybeShowQuickAnswers(
// Send the request for preprocessing. Only shows quick answers view if the // Send the request for preprocessing. Only shows quick answers view if the
// predicted intent is not |kUnknown| at |OnRequestPreprocessFinish|. // predicted intent is not |kUnknown| at |OnRequestPreprocessFinish|.
quick_answers_client_->SendRequestForPreprocessing(request); quick_answers_client_->SendRequestForPreprocessing(request);
} else if (!MaybeShowUserConsent()) { } else if (!MaybeShowUserConsent(base::string16(), base::string16())) {
// Text annotator is not enabled and consent view is not showing, shows // Text annotator is not enabled and consent view is not showing, shows
// quick answers view with placeholder and send the request. // quick answers view with placeholder and send the request.
quick_answers_ui_controller_->CreateQuickAnswersView(anchor_bounds, title_, quick_answers_ui_controller_->CreateQuickAnswersView(anchor_bounds, title_,
...@@ -138,7 +155,10 @@ void QuickAnswersControllerImpl::OnRequestPreprocessFinished( ...@@ -138,7 +155,10 @@ void QuickAnswersControllerImpl::OnRequestPreprocessFinished(
query_ = processed_request.preprocessed_output.query; query_ = processed_request.preprocessed_output.query;
title_ = processed_request.preprocessed_output.intent_text; title_ = processed_request.preprocessed_output.intent_text;
if (!MaybeShowUserConsent()) { if (!MaybeShowUserConsent(
IntentTypeToString(processed_request.preprocessed_output.intent_type),
base::UTF8ToUTF16(
processed_request.preprocessed_output.intent_text))) {
quick_answers_ui_controller_->CreateQuickAnswersView(anchor_bounds_, title_, quick_answers_ui_controller_->CreateQuickAnswersView(anchor_bounds_, title_,
query_); query_);
quick_answers_client_->FetchQuickAnswers(processed_request); quick_answers_client_->FetchQuickAnswers(processed_request);
...@@ -193,11 +213,14 @@ void QuickAnswersControllerImpl::MaybeDismissQuickAnswersConsent() { ...@@ -193,11 +213,14 @@ void QuickAnswersControllerImpl::MaybeDismissQuickAnswersConsent() {
quick_answers_ui_controller_->CloseUserConsentView(); quick_answers_ui_controller_->CloseUserConsentView();
} }
bool QuickAnswersControllerImpl::MaybeShowUserConsent() { bool QuickAnswersControllerImpl::MaybeShowUserConsent(
const base::string16& intent_type,
const base::string16& intent_text) {
if (consent_controller_->ShouldShowConsent()) { if (consent_controller_->ShouldShowConsent()) {
// Show user-consent notice informing user about the feature if required. // Show user-consent notice informing user about the feature if required.
if (!quick_answers_ui_controller_->is_showing_user_consent_view()) { if (!quick_answers_ui_controller_->is_showing_user_consent_view()) {
quick_answers_ui_controller_->CreateUserConsentView(anchor_bounds_); quick_answers_ui_controller_->CreateUserConsentView(
anchor_bounds_, intent_type, intent_text);
consent_controller_->StartConsent(); consent_controller_->StartConsent();
} }
return true; return true;
......
...@@ -88,7 +88,8 @@ class ASH_EXPORT QuickAnswersControllerImpl ...@@ -88,7 +88,8 @@ class ASH_EXPORT QuickAnswersControllerImpl
void MaybeDismissQuickAnswersConsent(); void MaybeDismissQuickAnswersConsent();
// Return true if the user consent view is showing. // Return true if the user consent view is showing.
bool MaybeShowUserConsent(); bool MaybeShowUserConsent(const base::string16& intent_type,
const base::string16& intent_text);
chromeos::quick_answers::QuickAnswersRequest BuildRequest(); chromeos::quick_answers::QuickAnswersRequest BuildRequest();
......
...@@ -98,10 +98,13 @@ void QuickAnswersUiController::UpdateQuickAnswersBounds( ...@@ -98,10 +98,13 @@ void QuickAnswersUiController::UpdateQuickAnswersBounds(
} }
void QuickAnswersUiController::CreateUserConsentView( void QuickAnswersUiController::CreateUserConsentView(
const gfx::Rect& anchor_bounds) { const gfx::Rect& anchor_bounds,
const base::string16& intent_type,
const base::string16& intent_text) {
DCHECK(!quick_answers_view_); DCHECK(!quick_answers_view_);
DCHECK(!user_consent_view_); DCHECK(!user_consent_view_);
user_consent_view_ = new quick_answers::UserConsentView(anchor_bounds, this); user_consent_view_ = new quick_answers::UserConsentView(
anchor_bounds, intent_type, intent_text, this);
user_consent_view_->GetWidget()->ShowInactive(); user_consent_view_->GetWidget()->ShowInactive();
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/strings/string16.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
namespace chromeos { namespace chromeos {
...@@ -60,7 +61,9 @@ class ASH_EXPORT QuickAnswersUiController { ...@@ -60,7 +61,9 @@ class ASH_EXPORT QuickAnswersUiController {
// Creates a view for user-consent for Quick Answers vertically aligned to the // Creates a view for user-consent for Quick Answers vertically aligned to the
// anchor. // anchor.
void CreateUserConsentView(const gfx::Rect& anchor_bounds); void CreateUserConsentView(const gfx::Rect& anchor_bounds,
const base::string16& intent_type,
const base::string16& intent_text);
// Returns true if there was a UserConsentView to close. // Returns true if there was a UserConsentView to close.
bool CloseUserConsentView(); bool CloseUserConsentView();
......
...@@ -121,6 +121,8 @@ class CustomizedLabelButton : public views::MdTextButton { ...@@ -121,6 +121,8 @@ class CustomizedLabelButton : public views::MdTextButton {
// UserConsentView ------------------------------------------------------------- // UserConsentView -------------------------------------------------------------
UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds, UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds,
const base::string16& intent_type,
const base::string16& intent_text,
QuickAnswersUiController* ui_controller) QuickAnswersUiController* ui_controller)
: anchor_view_bounds_(anchor_view_bounds), : anchor_view_bounds_(anchor_view_bounds),
event_handler_(std::make_unique<QuickAnswersPreTargetHandler>(this)), event_handler_(std::make_unique<QuickAnswersPreTargetHandler>(this)),
...@@ -129,6 +131,15 @@ UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds, ...@@ -129,6 +131,15 @@ UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds,
this, this,
base::BindRepeating(&UserConsentView::GetFocusableViews, base::BindRepeating(&UserConsentView::GetFocusableViews,
base::Unretained(this)))) { base::Unretained(this)))) {
if (intent_type.empty() || intent_text.empty()) {
title_ = l10n_util::GetStringUTF16(
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT);
} else {
title_ = l10n_util::GetStringFUTF16(
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT_WITH_INTENT,
intent_type, intent_text);
}
InitLayout(); InitLayout();
InitWidget(); InitWidget();
...@@ -143,11 +154,8 @@ UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds, ...@@ -143,11 +154,8 @@ UserConsentView::UserConsentView(const gfx::Rect& anchor_view_bounds,
// Read out user-consent notice if screen-reader is active. // Read out user-consent notice if screen-reader is active.
GetViewAccessibility().OverrideRole(ax::mojom::Role::kAlert); GetViewAccessibility().OverrideRole(ax::mojom::Role::kAlert);
GetViewAccessibility().OverrideName( GetViewAccessibility().OverrideName(base::StringPrintf(
base::StringPrintf(kA11yInfoNameTemplate, kA11yInfoNameTemplate, base::UTF16ToUTF8(title_).c_str()));
l10n_util::GetStringUTF8(
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT)
.c_str()));
GetViewAccessibility().OverrideDescription(l10n_util::GetStringUTF8( GetViewAccessibility().OverrideDescription(l10n_util::GetStringUTF8(
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_DESC_TEXT)); IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_DESC_TEXT));
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
...@@ -253,9 +261,7 @@ void UserConsentView::InitContent() { ...@@ -253,9 +261,7 @@ void UserConsentView::InitContent() {
// Title. // Title.
content_->AddChildView( content_->AddChildView(
CreateLabel(l10n_util::GetStringUTF16( CreateLabel(title_, kTitleTextColor, kTitleFontSizeDelta));
IDS_ASH_QUICK_ANSWERS_USER_CONSENT_VIEW_TITLE_TEXT),
kTitleTextColor, kTitleFontSizeDelta));
// Description. // Description.
auto* desc = content_->AddChildView( auto* desc = content_->AddChildView(
......
...@@ -24,10 +24,15 @@ class QuickAnswersPreTargetHandler; ...@@ -24,10 +24,15 @@ class QuickAnswersPreTargetHandler;
namespace quick_answers { namespace quick_answers {
// TODO(siabhijeet): Investigate BubbleDialogDelegateView as a common view for // TODO(siabhijeet): Investigate BubbleDialogDelegateView as a common view for
// UserConsentView and QuickAnswersView // UserConsentView and QuickAnswersView.
// |intent_type| and |intent_text| are used to generate the consent title
// including predicted intent information. Fallback to title without intent
// information if any of these two strings are empty.
class UserConsentView : public views::View, public views::ButtonListener { class UserConsentView : public views::View, public views::ButtonListener {
public: public:
UserConsentView(const gfx::Rect& anchor_view_bounds, UserConsentView(const gfx::Rect& anchor_view_bounds,
const base::string16& intent_type,
const base::string16& intent_text,
QuickAnswersUiController* ui_controller); QuickAnswersUiController* ui_controller);
// Disallow copy and assign. // Disallow copy and assign.
...@@ -61,6 +66,8 @@ class UserConsentView : public views::View, public views::ButtonListener { ...@@ -61,6 +66,8 @@ class UserConsentView : public views::View, public views::ButtonListener {
// Cached bounds of the anchor this view is tied to. // Cached bounds of the anchor this view is tied to.
gfx::Rect anchor_view_bounds_; gfx::Rect anchor_view_bounds_;
// Cached title text.
base::string16 title_;
std::unique_ptr<QuickAnswersPreTargetHandler> event_handler_; std::unique_ptr<QuickAnswersPreTargetHandler> event_handler_;
QuickAnswersUiController* const ui_controller_; QuickAnswersUiController* const ui_controller_;
......
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