Skip to content

Commit

Permalink
[continue-section]: Feedback dialog for task removal
Browse files Browse the repository at this point in the history
This dialog will serve as both a confirmation dialog for the continue
section task removal and an optional feedback collection form.
The feedback collected from users' input will help understand the main
reasons behind a user's decision to remove suggestions.

This CL adds the dialog and the necessary wiring to show it and hides
the logic behind a feature flag.

Screenshots:
https://screenshot.googleplex.com/5f3TghzNQNwquqz.png
https://screenshot.googleplex.com/AgskhzU2ibTsmGb.png

Bug: 1307371
Change-Id: Ie506bd7b8290212e8e02d35b7e5559795c13f16c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3554477
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988279}
  • Loading branch information
Ana Salazar authored and Chromium LUCI CQ committed Apr 2, 2022
1 parent 2c09e2d commit fcdb8d4
Show file tree
Hide file tree
Showing 38 changed files with 543 additions and 39 deletions.
2 changes: 2 additions & 0 deletions ash/app_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ source_set("app_list") {
"views/recent_apps_view.h",
"views/remove_query_confirmation_dialog.cc",
"views/remove_query_confirmation_dialog.h",
"views/remove_task_feedback_dialog.cc",
"views/remove_task_feedback_dialog.h",
"views/result_selection_controller.cc",
"views/result_selection_controller.h",
"views/scrollable_apps_grid_view.cc",
Expand Down
11 changes: 10 additions & 1 deletion ash/app_list/test/app_list_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,18 @@ SearchResultPageView* AppListTestHelper::GetFullscreenSearchResultPageView() {
->search_result_page_view();
}

bool AppListTestHelper::IsShowingFullscreenSearchResults() {
return GetAppListView()
->app_list_main_view()
->contents_view()
->IsShowingSearchResults();
}

SearchResultPageAnchoredDialog*
AppListTestHelper::GetFullscreenSearchPageDialog() {
return GetFullscreenSearchResultPageView()->dialog_for_test();
if (IsShowingFullscreenSearchResults())
return GetFullscreenSearchResultPageView()->dialog_for_test();
return GetAppsContainerView()->dialog_for_test();
}

AppListBubbleView* AppListTestHelper::GetBubbleView() {
Expand Down
3 changes: 3 additions & 0 deletions ash/app_list/test/app_list_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class AppListTestHelper {
ProductivityLauncherSearchView* GetProductivityLauncherSearchView();
views::View* GetFullscreenLauncherAppsSeparatorView();

// Whether the fullscreen/peeking launcher is showing the search results view.
bool IsShowingFullscreenSearchResults();

// Paged launcher helpers.
PagedAppsGridView* GetRootPagedAppsGridView();

Expand Down
8 changes: 6 additions & 2 deletions ash/app_list/views/app_list_bubble_apps_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ash/app_list/views/continue_section_view.h"
#include "ash/app_list/views/recent_apps_view.h"
#include "ash/app_list/views/scrollable_apps_grid_view.h"
#include "ash/app_list/views/search_result_page_dialog_controller.h"
#include "ash/bubble/bubble_utils.h"
#include "ash/constants/ash_features.h"
#include "ash/controls/rounded_scroll_bar.h"
Expand Down Expand Up @@ -102,8 +103,10 @@ AppListBubbleAppsPage::AppListBubbleAppsPage(
ApplicationDragAndDropHost* drag_and_drop_host,
AppListConfig* app_list_config,
AppListA11yAnnouncer* a11y_announcer,
SearchResultPageDialogController* dialog_controller,
AppListFolderController* folder_controller)
: app_list_nudge_controller_(std::make_unique<AppListNudgeController>()) {
: app_list_nudge_controller_(std::make_unique<AppListNudgeController>()),
dialog_controller_(dialog_controller) {
DCHECK(view_delegate);
DCHECK(drag_and_drop_host);
DCHECK(a11y_announcer);
Expand Down Expand Up @@ -146,7 +149,8 @@ AppListBubbleAppsPage::AppListBubbleAppsPage(
// Continue section row.
continue_section_ =
scroll_contents->AddChildView(std::make_unique<ContinueSectionView>(
view_delegate, kContinueColumnCount, /*tablet_mode=*/false));
view_delegate, dialog_controller_, kContinueColumnCount,
/*tablet_mode=*/false));
continue_section_->SetBorder(
views::CreateEmptyBorder(kContinueSectionInsets));
continue_section_->SetNudgeController(app_list_nudge_controller_.get());
Expand Down
5 changes: 5 additions & 0 deletions ash/app_list/views/app_list_bubble_apps_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AppListToastContainerView;
class AppListViewDelegate;
class ContinueSectionView;
class RecentAppsView;
class SearchResultPageDialogController;
class ScrollableAppsGridView;
class ScrollViewGradientHelper;

Expand All @@ -61,6 +62,7 @@ class ASH_EXPORT AppListBubbleAppsPage : public views::View,
ApplicationDragAndDropHost* drag_and_drop_host,
AppListConfig* app_list_config,
AppListA11yAnnouncer* a11y_announcer,
SearchResultPageDialogController* dialog_controller,
AppListFolderController* folder_controller);
AppListBubbleAppsPage(const AppListBubbleAppsPage&) = delete;
AppListBubbleAppsPage& operator=(const AppListBubbleAppsPage&) = delete;
Expand Down Expand Up @@ -189,6 +191,9 @@ class ASH_EXPORT AppListBubbleAppsPage : public views::View,

std::unique_ptr<AppListNudgeController> app_list_nudge_controller_;

// Controller for showing a modal dialog in the continue section.
SearchResultPageDialogController* const dialog_controller_;

// Adds fade in/out gradients to `scroll_view_`.
std::unique_ptr<ScrollViewGradientHelper> gradient_helper_;

Expand Down
13 changes: 8 additions & 5 deletions ash/app_list/views/app_list_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,18 @@ void AppListBubbleView::InitContentsView(
// so flex the entire container.
layout->SetFlexForView(pages_container, 1);

search_page_dialog_controller_ =
std::make_unique<SearchResultPageDialogController>(this);

// NOTE: Passing drag and drop host from a specific shelf instance assumes
// that the `apps_page_` will not get reused for showing the app list in
// another root window.
apps_page_ =
pages_container->AddChildView(std::make_unique<AppListBubbleAppsPage>(
view_delegate_, drag_and_drop_host, GetAppListConfig(),
a11y_announcer_.get(),
a11y_announcer_.get(), search_page_dialog_controller_.get(),
/*folder_controller=*/this));

search_page_dialog_controller_ =
std::make_unique<SearchResultPageDialogController>(this);
search_page_ =
pages_container->AddChildView(std::make_unique<AppListBubbleSearchPage>(
view_delegate_, search_page_dialog_controller_.get(),
Expand Down Expand Up @@ -423,8 +424,10 @@ void AppListBubbleView::ShowPage(AppListBubblePage page) {
search_box_view_->SetVisible(page != AppListBubblePage::kAssistant);
separator_->SetVisible(page != AppListBubblePage::kAssistant);

search_page_dialog_controller_->SetEnabled(page ==
AppListBubblePage::kSearch);
const bool supports_anchored_dialogs =
page == AppListBubblePage::kApps || page == AppListBubblePage::kSearch;

search_page_dialog_controller_->Reset(/*enabled=*/supports_anchored_dialogs);
assistant_page_->SetVisible(page == AppListBubblePage::kAssistant);
switch (current_page_) {
case AppListBubblePage::kNone:
Expand Down
19 changes: 15 additions & 4 deletions ash/app_list/views/apps_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ash/app_list/views/folder_background_view.h"
#include "ash/app_list/views/page_switcher.h"
#include "ash/app_list/views/search_box_view.h"
#include "ash/app_list/views/search_result_page_dialog_controller.h"
#include "ash/app_list/views/suggestion_chip_container_view.h"
#include "ash/constants/ash_features.h"
#include "ash/controls/gradient_layer_delegate.h"
Expand Down Expand Up @@ -152,15 +153,17 @@ constexpr base::TimeDelta kZeroStateSearchTimeout = base::Milliseconds(16);
class AppsContainerView::ContinueContainer : public views::View {
public:
ContinueContainer(AppsContainerView* apps_container,
AppListViewDelegate* view_delegate)
AppListViewDelegate* view_delegate,
SearchResultPageDialogController* dialog_controller)
: separator_(apps_container->separator()) {
SetPaintToLayer(ui::LAYER_NOT_DRAWN);

SetLayoutManager(std::make_unique<views::FlexLayout>())
->SetOrientation(views::LayoutOrientation::kVertical);

continue_section_ = AddChildView(std::make_unique<ContinueSectionView>(
view_delegate, kContinueColumnCount, /*tablet_mode=*/true));
view_delegate, dialog_controller, kContinueColumnCount,
/*tablet_mode=*/true));
continue_section_->SetPaintToLayer();
continue_section_->layer()->SetFillsBoundsOpaquely(false);

Expand Down Expand Up @@ -252,8 +255,12 @@ AppsContainerView::AppsContainerView(ContentsView* contents_view)
// Visibility for `separator_` will be managed by the `continue_container_`.
separator_->SetVisible(false);

continue_container_ = scrollable_container_->AddChildView(
std::make_unique<ContinueContainer>(this, view_delegate));
dialog_controller_ =
std::make_unique<SearchResultPageDialogController>(this);

continue_container_ =
scrollable_container_->AddChildView(std::make_unique<ContinueContainer>(
this, view_delegate, dialog_controller_.get()));
continue_container_->continue_section()->SetNudgeController(
app_list_nudge_controller_.get());
// Update the suggestion tasks after the app list nudge controller is set in
Expand Down Expand Up @@ -1102,6 +1109,8 @@ void AppsContainerView::OnShown() {
toast_container_->UpdateVisibilityState(
AppListToastContainerView::VisibilityState::kShown);
}
if (dialog_controller_)
dialog_controller_->Reset(/*enabled=*/true);
}

void AppsContainerView::OnWillBeHidden() {
Expand Down Expand Up @@ -1129,6 +1138,8 @@ void AppsContainerView::OnHidden() {
toast_container_->UpdateVisibilityState(
AppListToastContainerView::VisibilityState::kShownInBackground);
}
if (dialog_controller_)
dialog_controller_->Reset(/*enabled=*/false);
}

void AppsContainerView::OnAnimationStarted(AppListState from_state,
Expand Down
9 changes: 9 additions & 0 deletions ash/app_list/views/apps_container_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ash/app_list/views/app_list_page.h"
#include "ash/app_list/views/paged_apps_grid_view.h"
#include "ash/app_list/views/recent_apps_view.h"
#include "ash/app_list/views/search_result_page_dialog_controller.h"
#include "ash/ash_export.h"
#include "ash/public/cpp/pagination/pagination_model_observer.h"
#include "base/callback_helpers.h"
Expand All @@ -33,6 +34,7 @@ class ContentsView;
class ContinueSectionView;
class FolderBackgroundView;
class PageSwitcher;
class SearchResultPageAnchoredDialog;
class SuggestionChipContainerView;
class GradientLayerDelegate;

Expand Down Expand Up @@ -232,6 +234,10 @@ class ASH_EXPORT AppsContainerView
// Gets the height of the `separator_` including its vertical margin.
int GetSeparatorHeight();

SearchResultPageAnchoredDialog* dialog_for_test() {
return dialog_controller_->dialog();
}

private:
enum ShowState {
SHOW_NONE, // initial state
Expand Down Expand Up @@ -337,6 +343,9 @@ class ASH_EXPORT AppsContainerView

std::unique_ptr<AppListNudgeController> app_list_nudge_controller_;

// Controller for showing a modal dialog in the continue section.
std::unique_ptr<SearchResultPageDialogController> dialog_controller_;

// The number of active requests to disable blur.
size_t suggestion_chips_blur_disabler_count_ = 0;

Expand Down
13 changes: 8 additions & 5 deletions ash/app_list/views/continue_section_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ash/app_list/views/app_list_toast_view.h"
#include "ash/app_list/views/app_list_view_util.h"
#include "ash/app_list/views/continue_task_view.h"
#include "ash/app_list/views/search_result_page_dialog_controller.h"
#include "ash/bubble/bubble_utils.h"
#include "ash/public/cpp/app_list/app_list_config.h"
#include "ash/resources/vector_icons/vector_icons.h"
Expand Down Expand Up @@ -81,10 +82,12 @@ void CleanupLayer(views::View* view) {

} // namespace

ContinueSectionView::ContinueSectionView(AppListViewDelegate* view_delegate,
int columns,
bool tablet_mode)
: tablet_mode_(tablet_mode) {
ContinueSectionView::ContinueSectionView(
AppListViewDelegate* view_delegate,
SearchResultPageDialogController* dialog_controller,
int columns,
bool tablet_mode)
: dialog_controller_(dialog_controller), tablet_mode_(tablet_mode) {
DCHECK(view_delegate);

AppListModelProvider::Get()->AddObserver(this);
Expand Down Expand Up @@ -114,7 +117,7 @@ ContinueSectionView::ContinueSectionView(AppListViewDelegate* view_delegate,
base::BindRepeating(
&ContinueSectionView::OnSearchResultContainerResultsChanged,
base::Unretained(this)),
tablet_mode));
dialog_controller_, tablet_mode));

UpdateElementsVisibility();
}
Expand Down
5 changes: 5 additions & 0 deletions ash/app_list/views/continue_section_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AppListViewDelegate;
class AppListToastView;
class ContinueTaskContainerView;
class ContinueTaskView;
class SearchResultPageDialogController;

// The "Continue" section of the bubble launcher. This view wraps around
// suggestions with tasks to continue.
Expand All @@ -35,6 +36,7 @@ class ASH_EXPORT ContinueSectionView : public views::View,
METADATA_HEADER(ContinueSectionView);

ContinueSectionView(AppListViewDelegate* view_delegate,
SearchResultPageDialogController* dialog_controller,
int columns,
bool tablet_mode);
ContinueSectionView(const ContinueSectionView&) = delete;
Expand Down Expand Up @@ -132,6 +134,9 @@ class ASH_EXPORT ContinueSectionView : public views::View,
// when the privacy notice does not have enough items after an update.
void MaybeAnimateOutPrivacyNotice();

// Controller for showing a modal dialog in the continue section.
SearchResultPageDialogController* const dialog_controller_;

bool tablet_mode_ = false;

// Timer for marking the privacy notice as shown.
Expand Down

0 comments on commit fcdb8d4

Please sign in to comment.