From 564a8f697b3f3a287d9a4cce14ac0fe1a046709e Mon Sep 17 00:00:00 2001 From: Filip Gruszczynski Date: Fri, 20 Nov 2015 11:25:23 -0800 Subject: [PATCH] Synchronize thumbnail header in recents to freeform animation. Bug: 24913782 Change-Id: I46792ea3135794e514894783e1ee5fa696576f7f --- .../com/android/server/wm/AppWindowAnimator.java | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowAnimator.java b/services/core/java/com/android/server/wm/AppWindowAnimator.java index dfd01efe36d0..b32ec2d1b0a6 100644 --- a/services/core/java/com/android/server/wm/AppWindowAnimator.java +++ b/services/core/java/com/android/server/wm/AppWindowAnimator.java @@ -228,7 +228,8 @@ public class AppWindowAnimator { private void stepThumbnailAnimation(long currentTime) { thumbnailTransformation.clear(); - thumbnailAnimation.getTransformation(currentTime, thumbnailTransformation); + final long animationFrameTime = getAnimationFrameTime(thumbnailAnimation, currentTime); + thumbnailAnimation.getTransformation(animationFrameTime, thumbnailTransformation); thumbnailTransformation.getMatrix().preTranslate(thumbnailX, thumbnailY); ScreenRotationAnimation screenRotationAnimation = @@ -265,16 +266,26 @@ public class AppWindowAnimator { tmpFloats[Matrix.MSKEW_X], tmpFloats[Matrix.MSCALE_Y]); } + /** + * Sometimes we need to synchronize the first frame of animation with some external event, e.g. + * Recents hiding some of its content. To achieve this, we prolong the start of the animaiton + * and keep producing the first frame of the animation. + */ + private long getAnimationFrameTime(Animation animation, long currentTime) { + if (mProlongAnimation == PROLONG_ANIMATION_AT_START) { + animation.setStartTime(currentTime); + return currentTime + 1; + } + return currentTime; + } + private boolean stepAnimation(long currentTime) { if (animation == null) { return false; } transformation.clear(); - if (mProlongAnimation == PROLONG_ANIMATION_AT_START) { - animation.setStartTime(currentTime); - currentTime += 1; - } - boolean hasMoreFrames = animation.getTransformation(currentTime, transformation); + final long animationFrameTime = getAnimationFrameTime(animation, currentTime); + boolean hasMoreFrames = animation.getTransformation(animationFrameTime, transformation); if (!hasMoreFrames) { if (deferThumbnailDestruction && !deferFinalFrameCleanup) { // We are deferring the thumbnail destruction, so extend the animation for one more @@ -290,10 +301,10 @@ public class AppWindowAnimator { hasMoreFrames = true; } else { animation = null; + clearThumbnail(); + if (DEBUG_ANIM) Slog.v(TAG, "Finished animation in " + mAppToken + " @ " + + currentTime); } - clearThumbnail(); - if (DEBUG_ANIM) Slog.v(TAG, - "Finished animation in " + mAppToken + " @ " + currentTime); } } hasTransformation = hasMoreFrames; -- 2.11.0