Commit b14d4171 authored by David Black's avatar David Black Committed by Commit Bot

Reset Assistant query view when necessary.

When Assistant UI is closed, we need to reset the query view to empty
as AssistantMainStage is not necessarily being destroyed.

We also need to handle the case where an interaction is cancelled (e.g.
if the user taps the mic partway through a dictation). In such
situations, the query view should restore the previous committed query.

Bug: b:128712891
Change-Id: I61c8e05496efd69739fbd60c60f947bccaad2807
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526815Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#641692}
parent a37624bc
...@@ -220,6 +220,14 @@ void AssistantMainStage::OnPendingQueryChanged( ...@@ -220,6 +220,14 @@ void AssistantMainStage::OnPendingQueryChanged(
query_view_->SetQuery(query); query_view_->SetQuery(query);
} }
void AssistantMainStage::OnPendingQueryCleared() {
// When a pending query is cleared, it may be because the interaction was
// cancelled, or because the query was committed. If the query was committed,
// reseting the query here will have no visible effect. If the interaction was
// cancelled, we set the query here to restore the previously committed query.
query_view_->SetQuery(delegate_->GetInteractionModel()->committed_query());
}
void AssistantMainStage::OnResponseChanged( void AssistantMainStage::OnResponseChanged(
const std::shared_ptr<ash::AssistantResponse>& response) { const std::shared_ptr<ash::AssistantResponse>& response) {
// TODO(wutao): Replace the visibility change by animations. // TODO(wutao): Replace the visibility change by animations.
...@@ -260,6 +268,8 @@ void AssistantMainStage::OnUiVisibilityChanged( ...@@ -260,6 +268,8 @@ void AssistantMainStage::OnUiVisibilityChanged(
progress_indicator_->layer()->SetOpacity(0.f); progress_indicator_->layer()->SetOpacity(0.f);
progress_indicator_->layer()->SetTransform(gfx::Transform()); progress_indicator_->layer()->SetTransform(gfx::Transform());
query_view_->SetQuery(ash::AssistantNullQuery());
UpdateFooter(); UpdateFooter();
} }
......
...@@ -50,6 +50,7 @@ class APP_LIST_EXPORT AssistantMainStage ...@@ -50,6 +50,7 @@ class APP_LIST_EXPORT AssistantMainStage
// AssistantInteractionModelObserver: // AssistantInteractionModelObserver:
void OnCommittedQueryChanged(const ash::AssistantQuery& query) override; void OnCommittedQueryChanged(const ash::AssistantQuery& query) override;
void OnPendingQueryChanged(const ash::AssistantQuery& query) override; void OnPendingQueryChanged(const ash::AssistantQuery& query) override;
void OnPendingQueryCleared() override;
void OnResponseChanged( void OnResponseChanged(
const std::shared_ptr<ash::AssistantResponse>& response) override; const std::shared_ptr<ash::AssistantResponse>& response) override;
......
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