[image search] Finalize string and update ash_string.grd
This is a reland of crrev/c/4879885. The toast builder requires the member objects to be initialized. Please refer to the original cl for other detail. Bug: 1352636 Change-Id: I2e438d372fb835c965e9e303ef98c1e66cf2687a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4887736 Commit-Queue: Wen-Chien Wang <wcwang@chromium.org> Reviewed-by: Toni Barzic <tbarzic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1200399}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
812cd1e973
commit
a97a3035ad
ash
app_list
views
ash_strings_grd
IDS_ASH_SEARCH_BOX_FILTER_BUTTON_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APPS_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APP_SHORTCUTS_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_FILES_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_GAMES_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_HELP_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_IMAGES_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_PLAYSTORE_TOOLTIP.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_TITLE.png.sha1IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_WEBSITES_TOOLTIP.png.sha1IDS_ASH_SEARCH_IMAGE_SEARCH_PRIVACY_NOTICE_CONTENT.png.sha1IDS_ASH_SEARCH_IMAGE_SEARCH_PRIVACY_NOTICE_TITLE.png.sha1
@ -116,12 +116,10 @@ AppListSearchView::AppListSearchView(
|
||||
view_delegate->SetCategoryEnabled(AppListSearchControlCategory::kImages,
|
||||
false);
|
||||
|
||||
// TODO(crbug.com/1352636): Update the strings with the l10n translated
|
||||
// ones.
|
||||
AppListToastView::Builder toast_view_builder(
|
||||
u"You can now find your images by keyword");
|
||||
AppListToastView::Builder toast_view_builder(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_SEARCH_IMAGE_SEARCH_PRIVACY_NOTICE_TITLE));
|
||||
toast_view_builder.SetButton(
|
||||
u"Get started",
|
||||
l10n_util::GetStringUTF16(IDS_ASH_CONTINUE_BUTTON),
|
||||
base::BindRepeating(&AppListSearchView::OnSearchNotifierButtonPressed,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
search_notifier_ = scroll_contents->AddChildView(
|
||||
@ -129,8 +127,9 @@ AppListSearchView::AppListSearchView(
|
||||
.SetIcon(ui::ImageModel::FromVectorIcon(
|
||||
vector_icons::kImageSearchIcon, ui::kColorMenuIcon,
|
||||
kSearchNotifierIconSize))
|
||||
.SetSubtitle(
|
||||
u"Try \'cat\', \'dog\', \'building\', \'receipts\', etc")
|
||||
.SetSubtitle(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_SEARCH_IMAGE_SEARCH_PRIVACY_NOTICE_CONTENT))
|
||||
.SetSubtitleMultiline(true)
|
||||
.Build());
|
||||
search_notifier_->SetProperty(views::kMarginsKey,
|
||||
gfx::Insets::TLBR(16, 16, 0, 16));
|
||||
|
@ -730,6 +730,59 @@ TEST_P(SearchResultImageViewTest, SearchCategoryMenuItemToggleTest) {
|
||||
app_list_client->set_search_callback(TestAppListClient::SearchCallback());
|
||||
}
|
||||
|
||||
// Verifies that the filter button and all menu items in the search category
|
||||
// filter have tooltips.
|
||||
TEST_P(SearchResultImageViewTest, SearchCategoryMenuItemTooltips) {
|
||||
GetAppListTestHelper()->ShowAppList();
|
||||
auto* app_list_client = GetAppListTestHelper()->app_list_client();
|
||||
|
||||
app_list_client->set_available_categories_for_test(
|
||||
{AppListSearchControlCategory::kApps,
|
||||
AppListSearchControlCategory::kAppShortcuts,
|
||||
AppListSearchControlCategory::kFiles,
|
||||
AppListSearchControlCategory::kGames,
|
||||
AppListSearchControlCategory::kHelp,
|
||||
AppListSearchControlCategory::kImages,
|
||||
AppListSearchControlCategory::kPlayStore,
|
||||
AppListSearchControlCategory::kWeb});
|
||||
|
||||
// Press a character key to open the search.
|
||||
PressAndReleaseKey(ui::VKEY_A);
|
||||
GetSearchBoxView()->GetWidget()->LayoutRootViewIfNecessary();
|
||||
views::ImageButton* filter_button = GetSearchBoxView()->filter_button();
|
||||
EXPECT_TRUE(filter_button->GetVisible());
|
||||
EXPECT_EQ(filter_button->GetTooltipText({}),
|
||||
u"Toggle search result categories");
|
||||
LeftClickOn(filter_button);
|
||||
EXPECT_TRUE(GetSearchBoxView()->IsFilterMenuOpen());
|
||||
|
||||
auto check_tooltip = [&](AppListSearchControlCategory category,
|
||||
std::u16string tooltip) {
|
||||
EXPECT_EQ(GetSearchBoxView()
|
||||
->GetFilterMenuItemByCategory(category)
|
||||
->GetTooltipText({}),
|
||||
tooltip);
|
||||
};
|
||||
|
||||
// Check that all menu items have their corresponding tooltip.
|
||||
check_tooltip(AppListSearchControlCategory::kApps, u"Your installed apps");
|
||||
check_tooltip(
|
||||
AppListSearchControlCategory::kAppShortcuts,
|
||||
u"Quick access to specific pages or actions within installed apps");
|
||||
check_tooltip(AppListSearchControlCategory::kFiles,
|
||||
u"Your files on this device and Google Drive");
|
||||
check_tooltip(AppListSearchControlCategory::kGames,
|
||||
u"Games on the Play Store and other gaming platforms");
|
||||
check_tooltip(AppListSearchControlCategory::kHelp,
|
||||
u"Key shortcuts, tips for using device, and more");
|
||||
check_tooltip(AppListSearchControlCategory::kImages,
|
||||
u"Image search by content and image previews");
|
||||
check_tooltip(AppListSearchControlCategory::kPlayStore,
|
||||
u"Available apps from the Play Store");
|
||||
check_tooltip(AppListSearchControlCategory::kWeb,
|
||||
u"Websites including pages you've visited and open pages");
|
||||
}
|
||||
|
||||
// Tests that key traversal correctly cycles between the list of results and
|
||||
// search box buttons.
|
||||
TEST_P(SearchResultImageViewTest, ResultSelectionCycle) {
|
||||
|
@ -109,6 +109,10 @@ std::unique_ptr<AppListToastView> AppListToastView::Builder::Build() {
|
||||
if (subtitle_)
|
||||
toast->SetSubtitle(*subtitle_);
|
||||
|
||||
if (subtitle_ && is_subtitle_multiline_) {
|
||||
toast->SetSubtitleMultiline(is_subtitle_multiline_);
|
||||
}
|
||||
|
||||
return toast;
|
||||
}
|
||||
|
||||
@ -124,6 +128,12 @@ AppListToastView::Builder& AppListToastView::Builder::SetSubtitle(
|
||||
return *this;
|
||||
}
|
||||
|
||||
AppListToastView::Builder& AppListToastView::Builder::SetSubtitleMultiline(
|
||||
bool multiline) {
|
||||
is_subtitle_multiline_ = multiline;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AppListToastView::Builder& AppListToastView::Builder::SetIconSize(
|
||||
int icon_size) {
|
||||
icon_size_ = icon_size;
|
||||
@ -280,6 +290,14 @@ void AppListToastView::SetSubtitle(const std::u16string subtitle) {
|
||||
subtitle_label_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
|
||||
}
|
||||
|
||||
void AppListToastView::SetSubtitleMultiline(bool multiline) {
|
||||
if (!subtitle_label_) {
|
||||
return;
|
||||
}
|
||||
|
||||
subtitle_label_->SetMultiLine(multiline);
|
||||
}
|
||||
|
||||
void AppListToastView::SetIcon(const ui::ImageModel& icon) {
|
||||
CreateIconView();
|
||||
|
||||
|
@ -51,6 +51,7 @@ class ASH_EXPORT AppListToastView : public views::View {
|
||||
Builder& SetIconBackground(bool has_icon_background);
|
||||
|
||||
Builder& SetSubtitle(const std::u16string subtitle);
|
||||
Builder& SetSubtitleMultiline(bool multiline);
|
||||
Builder& SetButton(std::u16string button_text,
|
||||
views::Button::PressedCallback button_callback);
|
||||
Builder& SetCloseButton(
|
||||
@ -62,6 +63,7 @@ class ASH_EXPORT AppListToastView : public views::View {
|
||||
private:
|
||||
std::u16string title_;
|
||||
absl::optional<std::u16string> subtitle_;
|
||||
bool is_subtitle_multiline_ = false;
|
||||
absl::optional<std::u16string> button_text_;
|
||||
absl::optional<ui::ImageModel> icon_;
|
||||
absl::optional<int> icon_size_;
|
||||
@ -93,7 +95,7 @@ class ASH_EXPORT AppListToastView : public views::View {
|
||||
void SetIconSize(int icon_size);
|
||||
void SetTitle(const std::u16string title);
|
||||
void SetSubtitle(const std::u16string subtitle);
|
||||
|
||||
void SetSubtitleMultiline(bool multiline);
|
||||
void UpdateInteriorMargins(const gfx::Insets& margins);
|
||||
|
||||
void SetViewDelegate(AppListViewDelegate* delegate);
|
||||
|
@ -197,6 +197,40 @@ std::u16string GetCategoryName(SearchResult* search_result) {
|
||||
}
|
||||
}
|
||||
|
||||
std::u16string GetCategoryMenuItemTooltip(
|
||||
AppListSearchControlCategory category) {
|
||||
int tooltip_id = -1;
|
||||
switch (category) {
|
||||
case AppListSearchControlCategory::kApps:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APPS_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kAppShortcuts:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APP_SHORTCUTS_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kFiles:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_FILES_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kGames:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_GAMES_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kHelp:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_HELP_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kImages:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_IMAGES_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kPlayStore:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_PLAYSTORE_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kWeb:
|
||||
tooltip_id = IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_WEBSITES_TOOLTIP;
|
||||
break;
|
||||
case AppListSearchControlCategory::kCannotToggle:
|
||||
NOTREACHED_NORETURN();
|
||||
}
|
||||
return l10n_util::GetStringUTF16(tooltip_id);
|
||||
}
|
||||
|
||||
// Returns the check box icon that is shown on the category filter menu item.
|
||||
ui::ImageModel GetCheckboxImage(bool checked) {
|
||||
return ui::ImageModel::FromVectorIcon(
|
||||
@ -248,6 +282,14 @@ class FilterMenuAdapter : public views::MenuModelAdapter {
|
||||
// Keep the menu open if the user toggles the checkboxes in the menu.
|
||||
return true;
|
||||
}
|
||||
std::u16string GetTooltipText(int id,
|
||||
const gfx::Point& screen_loc) const override {
|
||||
if (id == ui::MenuModel::kTitleId) {
|
||||
return std::u16string();
|
||||
}
|
||||
return GetCategoryMenuItemTooltip(
|
||||
static_cast<AppListSearchControlCategory>(id));
|
||||
}
|
||||
void ExecuteCommand(int id) override { ExecuteCommand(id, 0); }
|
||||
void ExecuteCommand(int id, int mouse_event_flags) override {
|
||||
CHECK(id >= static_cast<int>(AppListSearchControlCategory::kMinValue) &&
|
||||
@ -399,8 +441,8 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
|
||||
views::ImageButton* filter_button = CreateFilterButton(base::BindRepeating(
|
||||
&SearchBoxView::ShowFilterMenu, weak_ptr_factory_.GetWeakPtr()));
|
||||
filter_button->SetFlipCanvasOnPaintForRTLUI(false);
|
||||
// TODO(crbug.com/1352636): Replace this with the l10n string.
|
||||
std::u16string filter_button_label(u"Toggle search result categories");
|
||||
std::u16string filter_button_label(
|
||||
l10n_util::GetStringUTF16(IDS_ASH_SEARCH_BOX_FILTER_BUTTON_TOOLTIP));
|
||||
filter_button->SetAccessibleName(filter_button_label);
|
||||
filter_button->SetTooltipText(filter_button_label);
|
||||
}
|
||||
@ -1587,8 +1629,8 @@ void SearchBoxView::ResetHighlightRange() {
|
||||
|
||||
ui::SimpleMenuModel* SearchBoxView::BuildFilterMenuModel() {
|
||||
filter_menu_model_ = std::make_unique<ui::SimpleMenuModel>(nullptr);
|
||||
// TODO(crbug.com/1352636): Use l10n string when the text is finalized.
|
||||
filter_menu_model_->AddTitle(u"Search categories");
|
||||
filter_menu_model_->AddTitle(
|
||||
l10n_util::GetStringUTF16(IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_TITLE));
|
||||
std::vector<AppListSearchControlCategory> available_categories =
|
||||
GetToggleableCategories();
|
||||
|
||||
|
@ -2279,6 +2279,42 @@ Style notes:
|
||||
<message name="IDS_ASH_SEARCH_RESULT_IMAGE_FILE_LOCATION" desc="The title for the file location of the image file search result, where the information is listed beside the launcher image result.">
|
||||
Location
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_BOX_FILTER_BUTTON_TOOLTIP" desc="The tooltip text of the filter button in the search box, which is used to open a menu to filter the search results by their categories.">
|
||||
Toggle search result categories
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_TITLE" desc="The title of the search category filter menu which is used to filter the search results by their categories.">
|
||||
Search categories
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APPS_TOOLTIP" desc="The tooltip text of the apps menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Your installed apps
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APP_SHORTCUTS_TOOLTIP" desc="The tooltip text of the app shortcut menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Quick access to specific pages or actions within installed apps
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_FILES_TOOLTIP" desc="The tooltip text of the files menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Your files on this device and Google Drive
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_GAMES_TOOLTIP" desc="The tooltip text of the games menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Games on the Play Store and other gaming platforms
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_HELP_TOOLTIP" desc="The tooltip text of the help menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Key shortcuts, tips for using device, and more
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_IMAGES_TOOLTIP" desc="The tooltip text of the images menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Image search by content and image previews
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_PLAYSTORE_TOOLTIP" desc="The tooltip text of the playstore menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Available apps from the Play Store
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_WEBSITES_TOOLTIP" desc="The tooltip text of the website menu item in the search category filter menu that shows what search results the category includes.">
|
||||
Websites including pages you've visited and open pages
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_IMAGE_SEARCH_PRIVACY_NOTICE_TITLE" desc="The title of the search privacy notice that guides users to search their image files by the content of the image.">
|
||||
Find your images by the content
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_IMAGE_SEARCH_PRIVACY_NOTICE_CONTENT" desc="The content of the search privacy notice that guides users to search their image files by the content of the image. Sunset and tree are two of the examples for users to try.">
|
||||
Try searching "sunset" or "tree" instead of the file name. You can turn off image search in the search bar.
|
||||
</message>
|
||||
<message name="IDS_ASH_SEARCH_RESULT_SEPARATOR" desc="Separator between the title and details text in ash search result view.">
|
||||
''' - '''
|
||||
</message>
|
||||
|
@ -0,0 +1 @@
|
||||
6b5684d10517a13e098724be4f0579bfbb16027e
|
@ -0,0 +1 @@
|
||||
4d27ef8df7be1d07654d4952dc22f3b5d234f7ac
|
1
ash/ash_strings_grd/IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APP_SHORTCUTS_TOOLTIP.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_SEARCH_CATEGORY_FILTER_MENU_APP_SHORTCUTS_TOOLTIP.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
aee3790b4087c0b9dbfd0532cee16bd721b9e6fc
|
@ -0,0 +1 @@
|
||||
10eb17ae79279ee45e5218cf93e0ac5bd4f92e98
|
@ -0,0 +1 @@
|
||||
1441a2aa36cd976678a025713f78bee810938f84
|
@ -0,0 +1 @@
|
||||
fdb94ebb23ce4f5af97b6ef341b3e221586748c9
|
@ -0,0 +1 @@
|
||||
5bd9311bbb8608c237dceff1d0abe7d24a83db6a
|
@ -0,0 +1 @@
|
||||
083b068650ea2da0d22c32079545414b1ea98330
|
@ -0,0 +1 @@
|
||||
175a3175d67bd73394f747db3e8412db66dee52e
|
@ -0,0 +1 @@
|
||||
3048c611623a5097b06800ab683b76f6a7c211f4
|
@ -0,0 +1 @@
|
||||
08ababc8604b9ada37e4d3b7203210db7f79b029
|
@ -0,0 +1 @@
|
||||
08ababc8604b9ada37e4d3b7203210db7f79b029
|
Reference in New Issue
Block a user