use of com.android.systemui.statusbar.ExpandableNotificationRow in project android_frameworks_base by DirtyUnicorns.
the class StackStateAnimator method startStackAnimations.
/**
* Start an animation to the given {@link StackViewState}.
*
* @param child the child to start the animation on
* @param viewState the {@link StackViewState} of the view to animate to
* @param finalState the final state after the animation
* @param i the index of the view; only relevant if the view is the speed bump and is
* ignored otherwise
* @param fixedDelay a fixed delay if desired or -1 if the delay should be calculated
*/
public void startStackAnimations(final ExpandableView child, StackViewState viewState, StackScrollState finalState, int i, long fixedDelay) {
boolean wasAdded = mNewAddChildren.contains(child);
long duration = mCurrentLength;
if (wasAdded && mAnimationFilter.hasGoToFullShadeEvent) {
child.setTranslationY(child.getTranslationY() + mGoToFullShadeAppearingTranslation);
float longerDurationFactor = viewState.notGoneIndex - mCurrentLastNotAddedIndex;
longerDurationFactor = (float) Math.pow(longerDurationFactor, 0.7f);
duration = ANIMATION_DURATION_APPEAR_DISAPPEAR + 50 + (long) (100 * longerDurationFactor);
}
boolean yTranslationChanging = child.getTranslationY() != viewState.yTranslation;
boolean zTranslationChanging = child.getTranslationZ() != viewState.zTranslation;
boolean alphaChanging = viewState.alpha != child.getAlpha();
boolean heightChanging = viewState.height != child.getActualHeight();
boolean shadowAlphaChanging = viewState.shadowAlpha != child.getShadowAlpha();
boolean darkChanging = viewState.dark != child.isDark();
boolean topInsetChanging = viewState.clipTopAmount != child.getClipTopAmount();
boolean hasDelays = mAnimationFilter.hasDelays;
boolean isDelayRelevant = yTranslationChanging || zTranslationChanging || alphaChanging || heightChanging || topInsetChanging || darkChanging || shadowAlphaChanging;
long delay = 0;
if (fixedDelay != -1) {
delay = fixedDelay;
} else if (hasDelays && isDelayRelevant || wasAdded) {
delay = mCurrentAdditionalDelay + calculateChildAnimationDelay(viewState, finalState);
}
startViewAnimations(child, viewState, delay, duration);
// start height animation
if (heightChanging) {
startHeightAnimation(child, viewState, duration, delay);
} else {
abortAnimation(child, TAG_ANIMATOR_HEIGHT);
}
// start shadow alpha animation
if (shadowAlphaChanging) {
startShadowAlphaAnimation(child, viewState, duration, delay);
} else {
abortAnimation(child, TAG_ANIMATOR_SHADOW_ALPHA);
}
// start top inset animation
if (topInsetChanging) {
startInsetAnimation(child, viewState, duration, delay);
} else {
abortAnimation(child, TAG_ANIMATOR_TOP_INSET);
}
// start dimmed animation
child.setDimmed(viewState.dimmed, mAnimationFilter.animateDimmed);
// apply speed bump state
child.setBelowSpeedBump(viewState.belowSpeedBump);
// start hiding sensitive animation
child.setHideSensitive(viewState.hideSensitive, mAnimationFilter.animateHideSensitive, delay, duration);
// start dark animation
child.setDark(viewState.dark, mAnimationFilter.animateDark, delay);
if (wasAdded) {
child.performAddAnimation(delay, mCurrentLength);
}
if (child instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) child;
row.startChildAnimation(finalState, this, delay, duration);
}
}
use of com.android.systemui.statusbar.ExpandableNotificationRow in project android_frameworks_base by DirtyUnicorns.
the class StackStateAnimator method processAnimationEvents.
/**
* Process the animationEvents for a new animation
*
* @param animationEvents the animation events for the animation to perform
* @param finalState the final state to animate to
*/
private void processAnimationEvents(ArrayList<NotificationStackScrollLayout.AnimationEvent> animationEvents, StackScrollState finalState) {
for (NotificationStackScrollLayout.AnimationEvent event : animationEvents) {
final ExpandableView changingView = (ExpandableView) event.changingView;
if (event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_ADD) {
// This item is added, initialize it's properties.
StackViewState viewState = finalState.getViewStateForView(changingView);
if (viewState == null) {
// The position for this child was never generated, let's continue.
continue;
}
finalState.applyState(changingView, viewState);
mNewAddChildren.add(changingView);
} else if (event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_REMOVE) {
if (changingView.getVisibility() == View.GONE) {
removeFromOverlay(changingView);
continue;
}
// Find the amount to translate up. This is needed in order to understand the
// direction of the remove animation (either downwards or upwards)
StackViewState viewState = finalState.getViewStateForView(event.viewAfterChangingView);
int actualHeight = changingView.getActualHeight();
// upwards by default
float translationDirection = -1.0f;
if (viewState != null) {
// there was a view after this one, Approximate the distance the next child
// travelled
translationDirection = ((viewState.yTranslation - (changingView.getTranslationY() + actualHeight / 2.0f)) * 2 / actualHeight);
translationDirection = Math.max(Math.min(translationDirection, 1.0f), -1.0f);
}
changingView.performRemoveAnimation(ANIMATION_DURATION_APPEAR_DISAPPEAR, translationDirection, new Runnable() {
@Override
public void run() {
// remove the temporary overlay
removeFromOverlay(changingView);
}
});
} else if (event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_REMOVE_SWIPED_OUT) {
// A race condition can trigger the view to be added to the overlay even though
// it was fully swiped out. So let's remove it
mHostLayout.getOverlay().remove(changingView);
if (Math.abs(changingView.getTranslation()) == changingView.getWidth() && changingView.getTransientContainer() != null) {
changingView.getTransientContainer().removeTransientView(changingView);
}
} else if (event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_GROUP_EXPANSION_CHANGED) {
ExpandableNotificationRow row = (ExpandableNotificationRow) event.changingView;
row.prepareExpansionChanged(finalState);
} else if (event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR) {
// This item is added, initialize it's properties.
StackViewState viewState = finalState.getViewStateForView(changingView);
mTmpState.copyFrom(viewState);
if (event.headsUpFromBottom) {
mTmpState.yTranslation = mHeadsUpAppearHeightBottom;
} else {
mTmpState.yTranslation = -mTmpState.height;
}
mHeadsUpAppearChildren.add(changingView);
finalState.applyState(changingView, mTmpState);
} else if (event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR || event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
mHeadsUpDisappearChildren.add(changingView);
if (changingView.getParent() == null) {
// This notification was actually removed, so we need to add it to the overlay
mHostLayout.getOverlay().add(changingView);
mTmpState.initFrom(changingView);
mTmpState.yTranslation = -changingView.getActualHeight();
// We temporarily enable Y animations, the real filter will be combined
// afterwards anyway
mAnimationFilter.animateY = true;
startViewAnimations(changingView, mTmpState, event.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK ? ANIMATION_DELAY_HEADS_UP : 0, ANIMATION_DURATION_HEADS_UP_DISAPPEAR);
mChildrenToClearFromOverlay.add(changingView);
}
}
mNewEvents.add(event);
}
}
use of com.android.systemui.statusbar.ExpandableNotificationRow in project android_frameworks_base by DirtyUnicorns.
the class NotificationStackScrollLayout method setUserExpandedChild.
/* Only ever called as a consequence of an expansion gesture in the shade. */
@Override
public void setUserExpandedChild(View v, boolean userExpanded) {
if (v instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) v;
if (userExpanded && onKeyguard()) {
// Due to a race when locking the screen while touching, a notification may be
// expanded even after we went back to keyguard. An example of this happens if
// you click in the empty space while expanding a group.
// We also need to un-user lock it here, since otherwise the content height
// calculated might be wrong. We also can't invert the two calls since
// un-userlocking it will trigger a layout switch in the content view.
row.setUserLocked(false);
updateContentHeight();
notifyHeightChangeListener(row);
return;
}
row.setUserExpanded(userExpanded, true);
row.onExpandedByGesture(userExpanded);
}
}
use of com.android.systemui.statusbar.ExpandableNotificationRow in project android_frameworks_base by DirtyUnicorns.
the class NotificationStackScrollLayout method clearHeadsUpDisappearRunning.
private void clearHeadsUpDisappearRunning() {
for (int i = 0; i < getChildCount(); i++) {
View view = getChildAt(i);
if (view instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
row.setHeadsupDisappearRunning(false);
if (row.isSummaryWithChildren()) {
for (ExpandableNotificationRow child : row.getNotificationChildren()) {
child.setHeadsupDisappearRunning(false);
}
}
}
}
}
use of com.android.systemui.statusbar.ExpandableNotificationRow in project android_frameworks_base by DirtyUnicorns.
the class NotificationStackScrollLayout method updateScrollPositionOnExpandInBottom.
private void updateScrollPositionOnExpandInBottom(ExpandableView view) {
if (view instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
if (row.isUserLocked() && row != getFirstChildNotGone()) {
if (row.isSummaryWithChildren()) {
return;
}
// We are actually expanding this view
float endPosition = row.getTranslationY() + row.getActualHeight();
if (row.isChildInGroup()) {
endPosition += row.getNotificationParent().getTranslationY();
}
int stackEnd = getStackEndPosition();
if (endPosition > stackEnd) {
setOwnScrollY((int) (mOwnScrollY + endPosition - stackEnd));
mDisallowScrollingInThisMotion = true;
}
}
}
}
Aggregations