Merge "Fix excessive entrance animation duration + delay" into qt-dev
am: 6072e42a45
Change-Id: I8b7336d7b66747b77a8a0c0be7524dc1a29a66d1
This commit is contained in:
@@ -61,6 +61,7 @@ public class StackStateAnimator {
|
|||||||
public static final int DELAY_EFFECT_MAX_INDEX_DIFFERENCE = 2;
|
public static final int DELAY_EFFECT_MAX_INDEX_DIFFERENCE = 2;
|
||||||
public static final int ANIMATION_DELAY_HEADS_UP = 120;
|
public static final int ANIMATION_DELAY_HEADS_UP = 120;
|
||||||
public static final int ANIMATION_DELAY_HEADS_UP_CLICKED= 120;
|
public static final int ANIMATION_DELAY_HEADS_UP_CLICKED= 120;
|
||||||
|
private static final int MAX_STAGGER_COUNT = 5;
|
||||||
|
|
||||||
private final int mGoToFullShadeAppearingTranslation;
|
private final int mGoToFullShadeAppearingTranslation;
|
||||||
private final int mPulsingAppearingTranslation;
|
private final int mPulsingAppearingTranslation;
|
||||||
@@ -78,8 +79,6 @@ public class StackStateAnimator {
|
|||||||
private long mCurrentLength;
|
private long mCurrentLength;
|
||||||
private long mCurrentAdditionalDelay;
|
private long mCurrentAdditionalDelay;
|
||||||
|
|
||||||
/** The current index for the last child which was not added in this event set. */
|
|
||||||
private int mCurrentLastNotAddedIndex;
|
|
||||||
private ValueAnimator mTopOverScrollAnimator;
|
private ValueAnimator mTopOverScrollAnimator;
|
||||||
private ValueAnimator mBottomOverScrollAnimator;
|
private ValueAnimator mBottomOverScrollAnimator;
|
||||||
private int mHeadsUpAppearHeightBottom;
|
private int mHeadsUpAppearHeightBottom;
|
||||||
@@ -137,7 +136,8 @@ public class StackStateAnimator {
|
|||||||
mAnimationFilter.applyCombination(mNewEvents);
|
mAnimationFilter.applyCombination(mNewEvents);
|
||||||
mCurrentAdditionalDelay = additionalDelay;
|
mCurrentAdditionalDelay = additionalDelay;
|
||||||
mCurrentLength = NotificationStackScrollLayout.AnimationEvent.combineLength(mNewEvents);
|
mCurrentLength = NotificationStackScrollLayout.AnimationEvent.combineLength(mNewEvents);
|
||||||
mCurrentLastNotAddedIndex = findLastNotAddedIndex();
|
// Used to stagger concurrent animations' delays and durations for visual effect
|
||||||
|
int animationStaggerCount = 0;
|
||||||
for (int i = 0; i < childCount; i++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
final ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i);
|
final ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i);
|
||||||
|
|
||||||
@@ -147,7 +147,10 @@ public class StackStateAnimator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
initAnimationProperties(child, viewState);
|
if (mAnimationProperties.wasAdded(child) && animationStaggerCount < MAX_STAGGER_COUNT) {
|
||||||
|
animationStaggerCount++;
|
||||||
|
}
|
||||||
|
initAnimationProperties(child, viewState, animationStaggerCount);
|
||||||
viewState.animateTo(child, mAnimationProperties);
|
viewState.animateTo(child, mAnimationProperties);
|
||||||
}
|
}
|
||||||
if (!isRunning()) {
|
if (!isRunning()) {
|
||||||
@@ -161,10 +164,10 @@ public class StackStateAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initAnimationProperties(ExpandableView child,
|
private void initAnimationProperties(ExpandableView child,
|
||||||
ExpandableViewState viewState) {
|
ExpandableViewState viewState, int animationStaggerCount) {
|
||||||
boolean wasAdded = mAnimationProperties.wasAdded(child);
|
boolean wasAdded = mAnimationProperties.wasAdded(child);
|
||||||
mAnimationProperties.duration = mCurrentLength;
|
mAnimationProperties.duration = mCurrentLength;
|
||||||
adaptDurationWhenGoingToFullShade(child, viewState, wasAdded);
|
adaptDurationWhenGoingToFullShade(child, viewState, wasAdded, animationStaggerCount);
|
||||||
mAnimationProperties.delay = 0;
|
mAnimationProperties.delay = 0;
|
||||||
if (wasAdded || mAnimationFilter.hasDelays
|
if (wasAdded || mAnimationFilter.hasDelays
|
||||||
&& (viewState.yTranslation != child.getTranslationY()
|
&& (viewState.yTranslation != child.getTranslationY()
|
||||||
@@ -174,16 +177,15 @@ public class StackStateAnimator {
|
|||||||
|| viewState.clipTopAmount != child.getClipTopAmount()
|
|| viewState.clipTopAmount != child.getClipTopAmount()
|
||||||
|| viewState.dark != child.isDark())) {
|
|| viewState.dark != child.isDark())) {
|
||||||
mAnimationProperties.delay = mCurrentAdditionalDelay
|
mAnimationProperties.delay = mCurrentAdditionalDelay
|
||||||
+ calculateChildAnimationDelay(viewState);
|
+ calculateChildAnimationDelay(viewState, animationStaggerCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adaptDurationWhenGoingToFullShade(ExpandableView child,
|
private void adaptDurationWhenGoingToFullShade(ExpandableView child,
|
||||||
ExpandableViewState viewState, boolean wasAdded) {
|
ExpandableViewState viewState, boolean wasAdded, int animationStaggerCount) {
|
||||||
if (wasAdded && mAnimationFilter.hasGoToFullShadeEvent) {
|
if (wasAdded && mAnimationFilter.hasGoToFullShadeEvent) {
|
||||||
child.setTranslationY(child.getTranslationY() + mGoToFullShadeAppearingTranslation);
|
child.setTranslationY(child.getTranslationY() + mGoToFullShadeAppearingTranslation);
|
||||||
float longerDurationFactor = viewState.notGoneIndex - mCurrentLastNotAddedIndex;
|
float longerDurationFactor = (float) Math.pow(animationStaggerCount, 0.7f);
|
||||||
longerDurationFactor = (float) Math.pow(longerDurationFactor, 0.7f);
|
|
||||||
mAnimationProperties.duration = ANIMATION_DURATION_APPEAR_DISAPPEAR + 50 +
|
mAnimationProperties.duration = ANIMATION_DURATION_APPEAR_DISAPPEAR + 50 +
|
||||||
(long) (100 * longerDurationFactor);
|
(long) (100 * longerDurationFactor);
|
||||||
}
|
}
|
||||||
@@ -214,25 +216,10 @@ public class StackStateAnimator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findLastNotAddedIndex() {
|
private long calculateChildAnimationDelay(ExpandableViewState viewState,
|
||||||
int childCount = mHostLayout.getChildCount();
|
int animationStaggerCount) {
|
||||||
for (int i = childCount - 1; i >= 0; i--) {
|
|
||||||
final ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i);
|
|
||||||
|
|
||||||
ExpandableViewState viewState = child.getViewState();
|
|
||||||
if (viewState == null || child.getVisibility() == View.GONE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!mNewAddChildren.contains(child)) {
|
|
||||||
return viewState.notGoneIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private long calculateChildAnimationDelay(ExpandableViewState viewState) {
|
|
||||||
if (mAnimationFilter.hasGoToFullShadeEvent) {
|
if (mAnimationFilter.hasGoToFullShadeEvent) {
|
||||||
return calculateDelayGoToFullShade(viewState);
|
return calculateDelayGoToFullShade(viewState, animationStaggerCount);
|
||||||
}
|
}
|
||||||
if (mAnimationFilter.customDelay != AnimationFilter.NO_DELAY) {
|
if (mAnimationFilter.customDelay != AnimationFilter.NO_DELAY) {
|
||||||
return mAnimationFilter.customDelay;
|
return mAnimationFilter.customDelay;
|
||||||
@@ -286,13 +273,13 @@ public class StackStateAnimator {
|
|||||||
return minDelay;
|
return minDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calculateDelayGoToFullShade(ExpandableViewState viewState) {
|
private long calculateDelayGoToFullShade(ExpandableViewState viewState,
|
||||||
|
int animationStaggerCount) {
|
||||||
int shelfIndex = mShelf.getNotGoneIndex();
|
int shelfIndex = mShelf.getNotGoneIndex();
|
||||||
float index = viewState.notGoneIndex;
|
float index = viewState.notGoneIndex;
|
||||||
long result = 0;
|
long result = 0;
|
||||||
if (index > shelfIndex) {
|
if (index > shelfIndex) {
|
||||||
float diff = index - shelfIndex;
|
float diff = (float) Math.pow(animationStaggerCount, 0.7f);
|
||||||
diff = (float) Math.pow(diff, 0.7f);
|
|
||||||
result += (long) (diff * ANIMATION_DELAY_PER_ELEMENT_GO_TO_FULL_SHADE * 0.25);
|
result += (long) (diff * ANIMATION_DELAY_PER_ELEMENT_GO_TO_FULL_SHADE * 0.25);
|
||||||
index = shelfIndex;
|
index = shelfIndex;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user