0

Update launcher "hide continue section" to new UX spec, part 2

This CL updates the tablet mode launcher:
- Add "Hide / show all suggestions" to the tablet mode "desktop"
  context menu (which is the one you get when you long-press between
  apps).
- Remove "Hide all suggestions" from the recent apps context menu.
  This allows simplifying the AppListController public interface, since
  code in //chrome/browser/ui/app_list doesn't need to toggle the
  continue section any more.
- Remove the "Continue where you left off" button when the continue
  section is hidden.
- Add a custom icon for the "Show all suggestions" item

https://screenshot.googleplex.com/7GrnP6hsw5eEA8L
https://screenshot.googleplex.com/7KVZ84XpZabBn8v

TODO:
- Decide if we still want "Hide all suggestions" in the individual
  continue task context menu. It's still there as of this CL.
- Animations.

Bug: 1334337
Test: existing ash_unittests
Change-Id: I4fe970b5312c0a2a1f3863b6eb675c7f2b722710
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3704586
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1015105}
This commit is contained in:
James Cook
2022-06-16 21:31:20 +00:00
committed by Chromium LUCI CQ
parent e4ae8a4013
commit a972d0e251
22 changed files with 78 additions and 128 deletions

@ -453,10 +453,6 @@ bool AppListControllerImpl::IsVisible() {
return IsVisible(absl::nullopt);
}
void AppListControllerImpl::HideContinueSection() {
SetHideContinueSection(true);
}
void AppListControllerImpl::OnActiveUserPrefServiceChanged(
PrefService* pref_service) {
if (IsKioskSession())

@ -113,7 +113,6 @@ class ASH_EXPORT AppListControllerImpl
aura::Window* GetWindow() override;
bool IsVisible(const absl::optional<int64_t>& display_id) override;
bool IsVisible() override;
void HideContinueSection() override;
// SessionObserver:
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;

@ -1331,12 +1331,6 @@ TEST_F(AppListControllerImplAppListBubbleTest, HideContinueSectionUpdatesPref) {
controller->SetHideContinueSection(false);
EXPECT_FALSE(controller->ShouldHideContinueSection());
EXPECT_FALSE(prefs->GetBoolean(prefs::kLauncherContinueSectionHidden));
// Hiding continue section can be done via the AppListController interface
// exposed in //ash/public.
AppListController::Get()->HideContinueSection();
EXPECT_TRUE(controller->ShouldHideContinueSection());
EXPECT_TRUE(prefs->GetBoolean(prefs::kLauncherContinueSectionHidden));
}
// AppListControllerImpl test that start in inactive session.

@ -475,7 +475,6 @@ bool IsCommandIdAnAppLaunch(int command_id_number) {
case CommandId::REORDER_BY_NAME_ALPHABETICAL:
case CommandId::REORDER_BY_NAME_REVERSE_ALPHABETICAL:
case CommandId::REORDER_BY_COLOR:
case CommandId::HIDE_CONTINUE_SECTION:
case CommandId::SHUTDOWN_GUEST_OS:
case CommandId::EXTENSIONS_CONTEXT_CUSTOM_FIRST:
case CommandId::EXTENSIONS_CONTEXT_CUSTOM_LAST:

@ -34,10 +34,8 @@
#include "ash/public/cpp/app_list/app_list_switches.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/style/color_provider.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/search_box/search_box_constants.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/pill_button.h"
#include "base/bind.h"
#include "base/check.h"
#include "base/command_line.h"
@ -60,7 +58,6 @@
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"
@ -177,25 +174,6 @@ class AppsContainerView::ContinueContainer : public views::View {
SetLayoutManager(std::make_unique<views::FlexLayout>())
->SetOrientation(views::LayoutOrientation::kVertical);
// Add the button to show the continue section, wrapped in a view to center
// it horizontally.
auto* button_container = AddChildView(std::make_unique<views::View>());
button_container
->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical))
->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter);
show_continue_section_button_ =
button_container->AddChildView(std::make_unique<PillButton>(
base::BindRepeating(&AppsContainerView::ContinueContainer::
OnPressShowContinueSection,
base::Unretained(this)),
l10n_util::GetStringUTF16(IDS_ASH_LAUNCHER_SHOW_CONTINUE_SECTION),
PillButton::Type::kIcon, &kExpandAllIcon));
show_continue_section_button_->SetUseDefaultLabelFont();
// Put the icon on the right.
show_continue_section_button_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
continue_section_ = AddChildView(std::make_unique<ContinueSectionView>(
view_delegate, dialog_controller, kContinueColumnCount,
/*tablet_mode=*/true));
@ -220,15 +198,6 @@ class AppsContainerView::ContinueContainer : public views::View {
UpdateRecentAppsMargins();
}
void OnThemeChanged() override {
views::View::OnThemeChanged();
// The "show continue section" button appears directly over the wallpaper,
// so use a "base layer" color for its background.
show_continue_section_button_->SetBackgroundColor(
AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent40));
}
bool HasRecentApps() const { return recent_apps_->GetVisible(); }
void UpdateAppListConfig(AppListConfig* config) {
@ -236,9 +205,6 @@ class AppsContainerView::ContinueContainer : public views::View {
}
void UpdateContinueSectionVisibility() {
// Show the "Show continue section" button if continue section is hidden.
bool hide_continue_section = view_delegate_->ShouldHideContinueSection();
show_continue_section_button_->SetVisible(hide_continue_section);
// The continue section view and recent apps view manage their own
// visibility internally.
continue_section_->UpdateElementsVisibility();
@ -246,9 +212,6 @@ class AppsContainerView::ContinueContainer : public views::View {
UpdateSeparatorVisibility();
}
PillButton* show_continue_section_button() {
return show_continue_section_button_;
}
ContinueSectionView* continue_section() { return continue_section_; }
RecentAppsView* recent_apps() { return recent_apps_; }
@ -267,13 +230,7 @@ class AppsContainerView::ContinueContainer : public views::View {
continue_section_->GetVisible());
}
void OnPressShowContinueSection(const ui::Event& event) {
view_delegate_->SetHideContinueSection(false);
UpdateContinueSectionVisibility();
}
AppListViewDelegate* const view_delegate_;
PillButton* show_continue_section_button_ = nullptr;
ContinueSectionView* continue_section_ = nullptr;
RecentAppsView* recent_apps_ = nullptr;
views::Separator* separator_ = nullptr;
@ -1774,10 +1731,4 @@ int AppsContainerView::GetSeparatorHeight() {
views::Separator::kThickness;
}
views::View* AppsContainerView::GetShowContinueSectionButtonForTest() {
return continue_container_
? continue_container_->show_continue_section_button()
: nullptr;
}
} // namespace ash

@ -233,8 +233,6 @@ class ASH_EXPORT AppsContainerView
// Gets the height of the `separator_` including its vertical margin.
int GetSeparatorHeight();
views::View* GetShowContinueSectionButtonForTest();
SearchResultPageAnchoredDialog* dialog_for_test() {
return dialog_controller_->dialog();
}

@ -38,15 +38,10 @@ TEST_F(AppsContainerViewTest, ContinueSectionVisibleByDefault) {
helper->AddAppItems(5);
TabletMode::Get()->SetEnabledForTest(true);
// The show continue section button is hidden.
auto* apps_container_view = helper->GetAppsContainerView();
EXPECT_FALSE(
apps_container_view->GetShowContinueSectionButtonForTest()->GetVisible());
// The continue section and recent apps are visible.
EXPECT_TRUE(helper->GetFullscreenContinueSectionView()->GetVisible());
EXPECT_TRUE(helper->GetFullscreenRecentAppsView()->GetVisible());
EXPECT_TRUE(apps_container_view->separator()->GetVisible());
EXPECT_TRUE(helper->GetAppsContainerView()->separator()->GetVisible());
}
TEST_F(AppsContainerViewTest, CanHideContinueSection) {
@ -61,19 +56,13 @@ TEST_F(AppsContainerViewTest, CanHideContinueSection) {
// Hide the continue section.
Shell::Get()->app_list_controller()->SetHideContinueSection(true);
// The show continue section button appears.
auto* apps_container_view = helper->GetAppsContainerView();
auto* show_continue_section_button =
apps_container_view->GetShowContinueSectionButtonForTest();
EXPECT_TRUE(show_continue_section_button->GetVisible());
// Continue section and recent apps are hidden.
EXPECT_FALSE(helper->GetFullscreenContinueSectionView()->GetVisible());
EXPECT_FALSE(helper->GetFullscreenRecentAppsView()->GetVisible());
EXPECT_FALSE(apps_container_view->separator()->GetVisible());
EXPECT_FALSE(helper->GetAppsContainerView()->separator()->GetVisible());
}
TEST_F(AppsContainerViewTest, CanShowContinueSectionByClickingButton) {
TEST_F(AppsContainerViewTest, CanShowContinueSection) {
// Simulate a user with the continue section hidden on startup.
Shell::Get()->app_list_controller()->SetHideContinueSection(true);
@ -85,27 +74,18 @@ TEST_F(AppsContainerViewTest, CanShowContinueSectionByClickingButton) {
helper->AddAppItems(5);
TabletMode::Get()->SetEnabledForTest(true);
// The show continue section button appears.
auto* apps_container_view = helper->GetAppsContainerView();
auto* show_continue_section_button =
apps_container_view->GetShowContinueSectionButtonForTest();
EXPECT_TRUE(show_continue_section_button->GetVisible());
// Continue section and recent apps are hidden.
EXPECT_FALSE(helper->GetFullscreenContinueSectionView()->GetVisible());
EXPECT_FALSE(helper->GetFullscreenRecentAppsView()->GetVisible());
EXPECT_FALSE(apps_container_view->separator()->GetVisible());
EXPECT_FALSE(helper->GetAppsContainerView()->separator()->GetVisible());
// Click the show continue section button.
LeftClickOn(show_continue_section_button);
// The button hides.
EXPECT_FALSE(show_continue_section_button->GetVisible());
// Show the continue section.
Shell::Get()->app_list_controller()->SetHideContinueSection(false);
// The continue section and recent apps are visible.
EXPECT_TRUE(helper->GetFullscreenContinueSectionView()->GetVisible());
EXPECT_TRUE(helper->GetFullscreenRecentAppsView()->GetVisible());
EXPECT_TRUE(apps_container_view->separator()->GetVisible());
EXPECT_TRUE(helper->GetAppsContainerView()->separator()->GetVisible());
}
} // namespace ash

@ -310,7 +310,8 @@ ui::SimpleMenuModel* ContinueTaskView::BuildMenuModel() {
IDS_ASH_LAUNCHER_CONTINUE_SECTION_CONTEXT_MENU_REMOVE),
ui::ImageModel::FromVectorIcon(kRemoveOutlineIcon,
ui::kColorAshSystemUIMenuIcon));
if (features::IsLauncherHideContinueSectionEnabled()) {
if (features::IsLauncherHideContinueSectionEnabled() &&
Shell::Get()->IsInTabletMode()) {
context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
context_menu_model_->AddItemWithIcon(
ContinueTaskCommandId::kHideContinueSection,

@ -4562,8 +4562,8 @@ Here are some things you can try to get started.
<message name="IDS_ASH_LAUNCHER_CONTINUE_SECTION_CONTEXT_MENU_REMOVE" desc="Context menu option title to remove a suggestion for a task in the launcher. Tasks display in the continue section located above the app list.">
Remove suggestion
</message>
<message name="IDS_ASH_LAUNCHER_SHOW_CONTINUE_SECTION" desc="Button title to show the launcher continue section after it has been hidden.">
Continue where you left off
<message name="IDS_ASH_LAUNCHER_SHOW_CONTINUE_SECTION" desc="Context menu label to show the launcher continue section after it has been hidden.">
Show all suggestions
</message>
<message name="IDS_ASH_LAUNCHER_HIDE_CONTINUE_SECTION" desc="Context menu label to hide the launcher continue section (which defaults to being shown).">
Hide all suggestions

@ -1 +1 @@
f096f6de3327762aff86de7dd9409339a6b417a5
1262963f696b6d23d1851bff45065aca150d4c03

@ -94,10 +94,6 @@ class ASH_PUBLIC_EXPORT AppListController {
bool animate,
base::OnceClosure update_position_closure) = 0;
// Hides the continue section. Sets a pref so the section stays hidden across
// restarts.
virtual void HideContinueSection() = 0;
protected:
AppListController();
virtual ~AppListController();

@ -66,9 +66,6 @@ enum CommandId {
REORDER_BY_NAME_REVERSE_ALPHABETICAL = 302,
REORDER_BY_COLOR = 303,
// Used by the launcher recent apps items via AppServiceContextMenu.
HIDE_CONTINUE_SECTION = 400,
// Range of command ids reserved for launching app shortcuts from context
// menu for Android app. Used by AppContextMenu and ShelfContextMenu.
LAUNCH_APP_SHORTCUT_FIRST = 1000,

@ -129,6 +129,7 @@ aggregate_vector_icons("ash_vector_icons") {
"ksv_volume_up.icon",
"launch.icon",
"launcher_hide_continue_section.icon",
"launcher_show_continue_section.icon",
"lock_screen_alert.icon",
"lock_screen_arrow.icon",
"lock_screen_arrow_back.icon",

@ -0,0 +1,29 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 20,
MOVE_TO, 10, 13,
CUBIC_TO, 8.34f, 13, 7, 11.66f, 7, 10,
CUBIC_TO, 7, 8.34f, 8.34f, 7, 10, 7,
CUBIC_TO, 11.66f, 7, 13, 8.34f, 13, 10,
CUBIC_TO, 13, 11.66f, 11.66f, 13, 10, 13,
CLOSE,
MOVE_TO, 10, 11,
CUBIC_TO, 10.55f, 11, 11, 10.55f, 11, 10,
CUBIC_TO, 11, 9.45f, 10.55f, 9, 10, 9,
CUBIC_TO, 9.45f, 9, 9, 9.45f, 9, 10,
CUBIC_TO, 9, 10.55f, 9.45f, 11, 10, 11,
CLOSE,
MOVE_TO, 10, 16,
CUBIC_TO, 14.33f, 16, 17.33f, 14, 19, 10,
CUBIC_TO, 17, 6, 14, 4, 10, 4,
CUBIC_TO, 6, 4, 3, 6, 1, 10,
CUBIC_TO, 2.67f, 14, 5.67f, 16, 10, 16,
CLOSE,
MOVE_TO, 10, 6,
CUBIC_TO, 12.94f, 6, 15.13f, 7.29f, 16.76f, 10.07f,
CUBIC_TO, 15.38f, 12.75f, 13.21f, 14, 10, 14,
CUBIC_TO, 6.79f, 14, 4.62f, 12.75f, 3.24f, 10.07f,
CUBIC_TO, 4.87f, 7.29f, 7.06f, 6, 10, 6,
CLOSE

@ -822,6 +822,24 @@ void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
sort_apps_submenu_.get(),
ui::ImageModel::FromVectorIcon(kReorderIcon,
ui::kColorAshSystemUIMenuIcon));
// Append the "Show all suggestions" / "Hide all suggestions" item.
if (features::IsLauncherHideContinueSectionEnabled()) {
menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
if (app_list_controller->ShouldHideContinueSection()) {
menu_model->AddItemWithIcon(
ShelfContextMenuModel::MENU_SHOW_CONTINUE_SECTION,
l10n_util::GetStringUTF16(IDS_ASH_LAUNCHER_SHOW_CONTINUE_SECTION),
ui::ImageModel::FromVectorIcon(kLauncherShowContinueSectionIcon,
ui::kColorAshSystemUIMenuIcon));
} else {
menu_model->AddItemWithIcon(
ShelfContextMenuModel::MENU_HIDE_CONTINUE_SECTION,
l10n_util::GetStringUTF16(IDS_ASH_LAUNCHER_HIDE_CONTINUE_SECTION),
ui::ImageModel::FromVectorIcon(kLauncherHideContinueSectionIcon,
ui::kColorAshSystemUIMenuIcon));
}
}
}
root_window_menu_model_adapter_->Run(

@ -128,6 +128,16 @@ void ShelfContextMenuModel::ExecuteCommand(int command_id, int event_flags) {
PersonalizationEntryPoint::kHomeScreen);
NewWindowDelegate::GetPrimary()->OpenPersonalizationHub();
break;
case MENU_HIDE_CONTINUE_SECTION:
DCHECK(features::IsLauncherHideContinueSectionEnabled());
DCHECK(is_tablet_mode);
shell->app_list_controller()->SetHideContinueSection(true);
break;
case MENU_SHOW_CONTINUE_SECTION:
DCHECK(features::IsLauncherHideContinueSectionEnabled());
DCHECK(is_tablet_mode);
shell->app_list_controller()->SetHideContinueSection(false);
break;
// Using reorder CommandId in ash/public/cpp/app_menu_constants.h
case REORDER_BY_NAME_ALPHABETICAL:
AppListModelProvider::Get()->model()->delegate()->RequestAppListSort(

@ -16,6 +16,7 @@ namespace ash {
class ShelfItemDelegate;
// A context menu shown for shelf items, the shelf itself, or the desktop area.
// In tablet mode the "desktop area" includes the app list.
class ASH_EXPORT ShelfContextMenuModel : public ui::SimpleMenuModel,
public ui::SimpleMenuModel::Delegate {
public:
@ -34,6 +35,8 @@ class ASH_EXPORT ShelfContextMenuModel : public ui::SimpleMenuModel,
MENU_ALIGNMENT_BOTTOM = 504,
MENU_CHANGE_WALLPAPER = 505,
MENU_PERSONALIZATION_HUB = 506,
MENU_HIDE_CONTINUE_SECTION = 507,
MENU_SHOW_CONTINUE_SECTION = 508,
MENU_ASH_END
};

@ -124,8 +124,6 @@ const gfx::VectorIcon& AppContextMenu::GetMenuItemVectorIcon(int command_id,
return ash::kSortAlphabeticalIcon;
case ash::REORDER_BY_COLOR:
return ash::kSortColorIcon;
case ash::HIDE_CONTINUE_SECTION:
return ash::kLauncherHideContinueSectionIcon;
case ash::NOTIFICATION_CONTAINER:
NOTREACHED() << "NOTIFICATION_CONTAINER does not have an icon, and it is "
"added to the model by NotificationMenuController.";

@ -373,10 +373,8 @@ TEST_F(AppContextMenuTest, ChromeApp) {
}
TEST_F(AppContextMenuTest, ChromeAppInRecentAppsList) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({ash::features::kProductivityLauncher,
ash::features::kLauncherHideContinueSection},
{});
base::test::ScopedFeatureList feature_list(
ash::features::kProductivityLauncher);
scoped_refptr<extensions::Extension> app = MakeChromeApp();
service_->AddExtension(app.get());
@ -396,10 +394,6 @@ TEST_F(AppContextMenuTest, ChromeAppInRecentAppsList) {
AddToStates(menu, MenuState(ash::APP_CONTEXT_MENU_NEW_INCOGNITO_WINDOW),
&states);
AddToStates(menu, MenuState(ash::SHOW_APP_INFO), &states);
// A separator item and the hide continue section item appear at the end.
AddToStates(menu, MenuState(), &states);
AddToStates(menu, MenuState(ash::HIDE_CONTINUE_SECTION), &states);
ValidateMenuState(menu_model.get(), states);
}

@ -5,7 +5,6 @@
#include "chrome/browser/ui/app_list/app_service/app_service_context_menu.h"
#include "ash/constants/ash_features.h"
#include "ash/public/cpp/app_list/app_list_controller.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/app_menu_constants.h"
#include "ash/public/cpp/new_window_delegate.h"
@ -254,10 +253,6 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) {
RequestAppListSort(profile(), ash::AppListSortOrder::kColor);
break;
case ash::HIDE_CONTINUE_SECTION:
ash::AppListController::Get()->HideContinueSection();
break;
default:
if (command_id >= ash::USE_LAUNCH_TYPE_COMMAND_START &&
command_id < ash::USE_LAUNCH_TYPE_COMMAND_END) {
@ -430,17 +425,6 @@ void AppServiceContextMenu::OnGetMenuModel(
color_id));
}
if (item_context_ == ash::AppListItemContext::kRecentApps &&
ash::features::IsLauncherHideContinueSectionEnabled()) {
menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
menu_model->AddItemWithIcon(
ash::HIDE_CONTINUE_SECTION,
l10n_util::GetStringUTF16(IDS_ASH_LAUNCHER_HIDE_CONTINUE_SECTION),
ui::ImageModel::FromVectorIcon(
GetMenuItemVectorIcon(ash::HIDE_CONTINUE_SECTION, /*string_id=*/-1),
color_id));
}
std::move(callback).Run(std::move(menu_model));
}

@ -47,7 +47,6 @@ class TestAppListController : public ash::AppListController {
const absl::optional<ash::AppListSortOrder>& new_order,
bool animate,
base::OnceClosure update_position_closure) override;
void HideContinueSection() override {}
private:
void NotifyAppListVisibilityChanged();

@ -15604,6 +15604,9 @@ Called by update_protocol_commands_enum.py.-->
<int value="503" label="Shelf Alignment Right"/>
<int value="504" label="Shelf Alignment Bottom"/>
<int value="505" label="Change Wallpaper"/>
<int value="506" label="Personalization Hub"/>
<int value="507" label="Hide Continue Section"/>
<int value="508" label="Show Continue Section"/>
</enum>
<enum name="ChromeOSUsbEventTiming">