From 8b73006a36b3000a9847534dcb01a2e7066e9d93 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 31 Jul 2014 22:19:52 +0200 Subject: [PATCH] Clean up speedbump handling when going to SHADE_LOCKED Bug: 16291973 Change-Id: Ibaa127709ff7a1a001402bd958016998e2bd23bf --- .../android/systemui/statusbar/SpeedBumpView.java | 14 ++++++++------ .../stack/NotificationStackScrollLayout.java | 4 +--- .../systemui/statusbar/stack/StackScrollState.java | 11 ++++++----- .../statusbar/stack/StackStateAnimator.java | 9 +++++++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java index d8d964e8b90f2..816612b79dda2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java @@ -76,23 +76,25 @@ public class SpeedBumpView extends ExpandableView { return true; } - public void performVisibilityAnimation(boolean nowVisible) { - animateDivider(nowVisible, null /* onFinishedRunnable */); + public void performVisibilityAnimation(boolean nowVisible, long delay) { + animateDivider(nowVisible, delay, null /* onFinishedRunnable */); } /** * Animate the divider to a new visibility. * * @param nowVisible should it now be visible + * @param delay the delay after the animation should start * @param onFinishedRunnable A runnable which should be run when the animation is * finished. */ - public void animateDivider(boolean nowVisible, Runnable onFinishedRunnable) { + public void animateDivider(boolean nowVisible, long delay, Runnable onFinishedRunnable) { if (nowVisible != mIsVisible) { // Animate dividers float endValue = nowVisible ? 1.0f : 0.0f; mLine.animate() .alpha(endValue) + .setStartDelay(delay) .scaleX(endValue) .scaleY(endValue) .setInterpolator(mFastOutSlowInInterpolator) @@ -116,13 +118,13 @@ public class SpeedBumpView extends ExpandableView { public void performRemoveAnimation(long duration, float translationDirection, Runnable onFinishedRunnable) { // TODO: Use duration - performVisibilityAnimation(false); + performVisibilityAnimation(false, 0 /* delay */); } @Override public void performAddAnimation(long delay, long duration) { - // TODO: Use delay and duration - performVisibilityAnimation(true); + // TODO: Use duration + performVisibilityAnimation(true, delay); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 14010821eb0a9..aa41b9c479594 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -1932,10 +1932,8 @@ public class NotificationStackScrollLayout extends ViewGroup if (visible) { // Make invisible to ensure that the appear animation is played. mSpeedBumpView.setInvisible(); - if (!mIsExpansionChanging) { - generateAddAnimation(mSpeedBumpView); - } } else { + // TODO: This doesn't really work, because the view is already set to GONE above. generateRemoveAnimation(mSpeedBumpView); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java index 7b90a3516efde..d0064c8e47e6f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java @@ -171,8 +171,7 @@ public class StackScrollState { updateChildClip(child, newHeight, state.topOverLap); if(child instanceof SpeedBumpView) { - float lineEnd = newYTranslation + newHeight / 2; - performSpeedBumpAnimation(i, (SpeedBumpView) child, lineEnd); + performSpeedBumpAnimation(i, (SpeedBumpView) child, state, 0); } else if (child instanceof DismissView) { DismissView dismissView = (DismissView) child; boolean visible = state.topOverLap < mClearAllTopPadding; @@ -197,12 +196,14 @@ public class StackScrollState { child.setClipBounds(mClipRect); } - private void performSpeedBumpAnimation(int i, SpeedBumpView speedBump, float speedBumpEnd) { + public void performSpeedBumpAnimation(int i, SpeedBumpView speedBump, ViewState state, + long delay) { View nextChild = getNextChildNotGone(i); if (nextChild != null) { + float lineEnd = state.yTranslation + state.height / 2; ViewState nextState = getViewStateForView(nextChild); - boolean startIsAboveNext = nextState.yTranslation > speedBumpEnd; - speedBump.animateDivider(startIsAboveNext, null /* onFinishedRunnable */); + boolean startIsAboveNext = nextState.yTranslation > lineEnd; + speedBump.animateDivider(startIsAboveNext, delay, null /* onFinishedRunnable */); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java index fddd3d6159c5b..edc669e991b66 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java @@ -27,6 +27,7 @@ import android.view.animation.Interpolator; import com.android.systemui.R; import com.android.systemui.statusbar.ExpandableView; +import com.android.systemui.statusbar.SpeedBumpView; import java.util.ArrayList; import java.util.HashSet; @@ -115,7 +116,7 @@ public class StackStateAnimator { } child.setClipBounds(null); - startAnimations(child, viewState, finalState); + startAnimations(child, viewState, finalState, i); } if (!isRunning()) { // no child has preformed any animation, lets finish @@ -145,7 +146,7 @@ public class StackStateAnimator { * Start an animation to the given viewState */ private void startAnimations(final ExpandableView child, StackScrollState.ViewState viewState, - StackScrollState finalState) { + StackScrollState finalState, int i) { int childVisibility = child.getVisibility(); boolean wasVisible = childVisibility == View.VISIBLE; final float alpha = viewState.alpha; @@ -223,6 +224,10 @@ public class StackStateAnimator { if (wasAdded) { child.performAddAnimation(delay, mCurrentLength); } + if (child instanceof SpeedBumpView) { + finalState.performSpeedBumpAnimation(i, (SpeedBumpView) child, viewState, + delay + duration); + } } private long calculateChildAnimationDelay(StackScrollState.ViewState viewState,