Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2201)

Unified Diff: ash/shelf/app_list_button.cc

Issue 2972923002: Update voice interaction burst animation (Closed)
Patch Set: fix comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/shelf/app_list_button.cc
diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
index 82948a845eaa3e2814400e499ec6f5090e51b0e8..755edf177b0eef2bda5148a15dca574b4e631a96 100644
--- a/ash/shelf/app_list_button.cc
+++ b/ash/shelf/app_list_button.cc
@@ -45,6 +45,7 @@
namespace ash {
namespace {
constexpr int kVoiceInteractionAnimationDelayMs = 200;
+constexpr int kVoiceInteractionAnimationHideDelayMs = 500;
} // namespace
constexpr uint8_t kVoiceInteractionRunningAlpha = 255; // 100% alpha
@@ -77,6 +78,8 @@ AppListButton::AppListButton(InkDropButtonListener* listener,
AddChildView(voice_interaction_overlay_);
voice_interaction_overlay_->SetVisible(false);
voice_interaction_animation_delay_timer_.reset(new base::OneShotTimer());
+ voice_interaction_animation_hide_delay_timer_.reset(
+ new base::OneShotTimer());
} else {
voice_interaction_overlay_ = nullptr;
}
@@ -84,8 +87,6 @@ AppListButton::AppListButton(InkDropButtonListener* listener,
AppListButton::~AppListButton() {
Shell::Get()->RemoveShellObserver(this);
- if (voice_interaction_animation_delay_timer_)
- voice_interaction_animation_delay_timer_->Stop();
}
void AppListButton::OnAppListShown() {
@@ -135,8 +136,8 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
FROM_HERE,
base::TimeDelta::FromMilliseconds(
kVoiceInteractionAnimationDelayMs),
- base::Bind(&VoiceInteractionOverlay::StartAnimation,
- base::Unretained(voice_interaction_overlay_)));
+ base::Bind(&AppListButton::StartVoiceInteractionAnimation,
+ base::Unretained(this)));
}
if (!Shell::Get()->IsAppListVisible())
AnimateInkDrop(views::InkDropState::ACTION_PENDING, event);
@@ -320,6 +321,27 @@ void AppListButton::OnAppListVisibilityChanged(bool shown,
void AppListButton::OnVoiceInteractionStatusChanged(bool running) {
voice_interaction_running_ = running;
SchedulePaint();
+
+ // Voice interaction window shows up, we start hiding the animation if it is
+ // running.
+ if (running && voice_interaction_overlay_->IsBursting()) {
+ voice_interaction_animation_hide_delay_timer_->Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(
+ kVoiceInteractionAnimationHideDelayMs),
+ base::Bind(&VoiceInteractionOverlay::HideAnimation,
+ base::Unretained(voice_interaction_overlay_)));
+ }
+}
+
+void AppListButton::StartVoiceInteractionAnimation() {
+ // We only show the voice interaction icon and related animation when the
+ // shelf is at the bottom position and voice interaction is not running.
+ ShelfAlignment alignment = shelf_->alignment();
+ bool show_icon = (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) &&
+ !voice_interaction_running_;
+ voice_interaction_overlay_->StartAnimation(show_icon);
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698