Support multiple cards and interspersed card/text elements.
Involved:
- Creating UI element classes.
- Combining Card/Text containers into single UiElementContainer.
- Adding support for multiple cards.
- Implementing queue to pend UI elements to ensure ordering. This is
necessary as cards are rendered asynchronously before being added to
the view hierarchy.
Also adds a background to text elements.
See bug for further details.
Bug: b:78130077
Change-Id: Ic10517de487de2e8aafe649062e8da56234557b5
Reviewed-on: https://chromium-review.googlesource.com/1019974
Reviewed-by: Xiaohui Chen <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: David Black <[email protected]>
Cr-Commit-Position: refs/heads/master@{#553311}
diff --git a/ash/assistant/ash_assistant_controller.cc b/ash/assistant/ash_assistant_controller.cc
index 15c3d24..9bc3277 100644
--- a/ash/assistant/ash_assistant_controller.cc
+++ b/ash/assistant/ash_assistant_controller.cc
@@ -4,11 +4,14 @@
#include "ash/assistant/ash_assistant_controller.h"
+#include <memory>
+
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "base/unguessable_token.h"
#include "ui/app_list/assistant_interaction_model_observer.h"
+#include "ui/app_list/assistant_ui_element.h"
namespace ash {
@@ -71,6 +74,12 @@
assistant_card_renderer_->Release(id_token);
}
+void AshAssistantController::ReleaseCards(
+ const std::vector<base::UnguessableToken>& id_tokens) {
+ DCHECK(assistant_card_renderer_);
+ assistant_card_renderer_->ReleaseAll(id_tokens);
+}
+
void AshAssistantController::AddInteractionModelObserver(
app_list::AssistantInteractionModelObserver* observer) {
assistant_interaction_model_.AddObserver(observer);
@@ -96,7 +105,8 @@
if (!is_app_list_shown_)
return;
- assistant_interaction_model_.SetCard(response);
+ assistant_interaction_model_.AddUiElement(
+ std::make_unique<app_list::AssistantCardElement>(response));
}
void AshAssistantController::OnSuggestionChipPressed(const std::string& text) {
@@ -122,7 +132,8 @@
if (!is_app_list_shown_)
return;
- assistant_interaction_model_.AddText(response);
+ assistant_interaction_model_.AddUiElement(
+ std::make_unique<app_list::AssistantTextElement>(response));
}
void AshAssistantController::OnSpeechRecognitionStarted() {