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

Unified Diff: ash/shelf/app_list_button.cc

Issue 2972923002: Update voice interaction burst animation (Closed)
Patch Set: update formating 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..51d6d0cfdfc6f39bc6a98534c10c2e916fb1da2a 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;
}
@@ -86,6 +89,8 @@ AppListButton::~AppListButton() {
Shell::Get()->RemoveShellObserver(this);
if (voice_interaction_animation_delay_timer_)
voice_interaction_animation_delay_timer_->Stop();
+ if (voice_interaction_animation_hide_delay_timer_)
+ voice_interaction_animation_hide_delay_timer_->Stop();
oshima 2017/07/06 19:23:54 just curious. Timer's dtor automatically abandon t
xiaohuic 2017/07/06 20:55:41 Maybe I don't, removed.
}
void AppListButton::OnAppListShown() {
@@ -135,8 +140,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 +325,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