Fixed double focus animation
Change-Id: I89af2d88e7bb4f76f970283c46e8da90766d6055
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 55aba75..71b74eb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -17,6 +17,7 @@
package com.android.systemui.recents.views;
import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -93,6 +94,7 @@
int mHighlightInFillAlpha;
int mHighlightInCircleAlpha;
int mHighlightOutFillAlpha;
+ boolean mHighlightAnimatorWasTriggered;
// Optimizations
ValueAnimator.AnimatorUpdateListener mUpdateDimListener =
@@ -129,6 +131,13 @@
setOutlineProvider(mViewBounds);
mHighlightAnimator = ObjectAnimator.ofFloat(this, "highlightProgress", 1f);
+ mHighlightAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animator) {
+ mHighlightAnimatorWasTriggered = true;
+ }
+ });
+
mHighlightColor =
context.getResources().getColor(R.color.status_bar_recents_highlight_color);
mHighlightPaint.setColor(mHighlightColor);
@@ -145,6 +154,7 @@
resetNoUserInteractionState();
setClipViewInStack(false);
setCallbacks(null);
+ disableFocusAnimations();
}
/** Gets the task */
@@ -548,20 +558,23 @@
@Override
public void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
- if (mIsFocused) {
- final int x = getWidth() / 2;
- final int y = getHeight() / 2;
- final float hypot = (float) Math.hypot(x, y);
- final float radius = hypot * mHighlightInCircleRadiusProgress;
- mHighlightPaint.setAlpha(mHighlightInFillAlpha);
- canvas.drawRect(0, 0, getWidth(), getHeight(), mHighlightPaint);
+ if (mHighlightAnimatorWasTriggered) {
+ if (mIsFocused) {
+ final int x = getWidth() / 2;
+ final int y = getHeight() / 2;
+ final float hypot = (float) Math.hypot(x, y);
+ final float radius = hypot * mHighlightInCircleRadiusProgress;
- mHighlightPaint.setAlpha(mHighlightInCircleAlpha);
- canvas.drawCircle(x, y, radius, mHighlightPaint);
- } else {
- mHighlightPaint.setAlpha(mHighlightOutFillAlpha);
- canvas.drawRect(0, 0, getWidth(), getHeight(), mHighlightPaint);
+ mHighlightPaint.setAlpha(mHighlightInFillAlpha);
+ canvas.drawRect(0, 0, getWidth(), getHeight(), mHighlightPaint);
+
+ mHighlightPaint.setAlpha(mHighlightInCircleAlpha);
+ canvas.drawCircle(x, y, radius, mHighlightPaint);
+ } else {
+ mHighlightPaint.setAlpha(mHighlightOutFillAlpha);
+ canvas.drawRect(0, 0, getWidth(), getHeight(), mHighlightPaint);
+ }
}
}
@@ -737,12 +750,18 @@
void enableFocusAnimations() {
boolean wasFocusAnimationsEnabled = mFocusAnimationsEnabled;
mFocusAnimationsEnabled = true;
- if (mIsFocused) {
+ if (mIsFocused && !wasFocusAnimationsEnabled) {
// Re-notify the header if we were focused and animations were not previously enabled
performFocusAnimation();
}
}
+ void disableFocusAnimations() {
+ mFocusAnimationsEnabled = false;
+ mIsFocused = false;
+ mHighlightAnimatorWasTriggered = false;
+ }
+
public void disableLayersForOneFrame() {
mHeaderView.disableLayersForOneFrame();
}