Search in sources :

Example 51 with ExpandableNotificationRow

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);
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 52 with ExpandableNotificationRow

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);
    }
}
Also used : ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 53 with ExpandableNotificationRow

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);
                }
            }
        }
    }
}
Also used : EmptyShadeView(com.android.systemui.statusbar.EmptyShadeView) ActivatableNotificationView(com.android.systemui.statusbar.ActivatableNotificationView) FakeShadowView(com.android.systemui.statusbar.notification.FakeShadowView) View(android.view.View) StackScrollerDecorView(com.android.systemui.statusbar.StackScrollerDecorView) ExpandableView(com.android.systemui.statusbar.ExpandableView) DismissView(com.android.systemui.statusbar.DismissView) ScrollView(android.widget.ScrollView) Paint(android.graphics.Paint) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 54 with ExpandableNotificationRow

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;
            }
        }
    }
}
Also used : Paint(android.graphics.Paint) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 55 with ExpandableNotificationRow

use of com.android.systemui.statusbar.ExpandableNotificationRow in project android_frameworks_base by DirtyUnicorns.

the class StackScrollAlgorithm method initAlgorithmState.

/**
     * Initialize the algorithm state like updating the visible children.
     */
private void initAlgorithmState(StackScrollState resultState, StackScrollAlgorithmState state, AmbientState ambientState) {
    state.itemsInBottomStack = 0.0f;
    state.partialInBottom = 0.0f;
    float bottomOverScroll = ambientState.getOverScrollAmount(false);
    int scrollY = ambientState.getScrollY();
    // Due to the overScroller, the stackscroller can have negative scroll state. This is
    // already accounted for by the top padding and doesn't need an additional adaption
    scrollY = Math.max(0, scrollY);
    state.scrollY = (int) (scrollY + bottomOverScroll);
    //now init the visible children and update paddings
    ViewGroup hostView = resultState.getHostView();
    int childCount = hostView.getChildCount();
    state.visibleChildren.clear();
    state.visibleChildren.ensureCapacity(childCount);
    state.increasedPaddingMap.clear();
    int notGoneIndex = 0;
    ExpandableView lastView = null;
    for (int i = 0; i < childCount; i++) {
        ExpandableView v = (ExpandableView) hostView.getChildAt(i);
        if (v.getVisibility() != View.GONE) {
            notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v);
            float increasedPadding = v.getIncreasedPaddingAmount();
            if (increasedPadding != 0.0f) {
                state.increasedPaddingMap.put(v, increasedPadding);
                if (lastView != null) {
                    Float prevValue = state.increasedPaddingMap.get(lastView);
                    float newValue = prevValue != null ? Math.max(prevValue, increasedPadding) : increasedPadding;
                    state.increasedPaddingMap.put(lastView, newValue);
                }
            }
            if (v instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) v;
                // handle the notgoneIndex for the children as well
                List<ExpandableNotificationRow> children = row.getNotificationChildren();
                if (row.isSummaryWithChildren() && children != null) {
                    for (ExpandableNotificationRow childRow : children) {
                        if (childRow.getVisibility() != View.GONE) {
                            StackViewState childState = resultState.getViewStateForView(childRow);
                            childState.notGoneIndex = notGoneIndex;
                            notGoneIndex++;
                        }
                    }
                }
            }
            lastView = v;
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ExpandableView(com.android.systemui.statusbar.ExpandableView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Aggregations

ExpandableNotificationRow (com.android.systemui.statusbar.ExpandableNotificationRow)290 View (android.view.View)75 ExpandableView (com.android.systemui.statusbar.ExpandableView)75 TextView (android.widget.TextView)55 ActivatableNotificationView (com.android.systemui.statusbar.ActivatableNotificationView)45 DismissView (com.android.systemui.statusbar.DismissView)45 EmptyShadeView (com.android.systemui.statusbar.EmptyShadeView)45 Paint (android.graphics.Paint)40 ImageView (android.widget.ImageView)35 Point (android.graphics.Point)30 BatteryMeterView (com.android.systemui.BatteryMeterView)30 BackDropView (com.android.systemui.statusbar.BackDropView)30 ScrimView (com.android.systemui.statusbar.ScrimView)30 SignalClusterView (com.android.systemui.statusbar.SignalClusterView)30 NotificationHeaderView (android.view.NotificationHeaderView)25 BatteryLevelTextView (com.android.systemui.BatteryLevelTextView)24 KeyButtonView (com.android.systemui.statusbar.policy.KeyButtonView)24 StackScrollerDecorView (com.android.systemui.statusbar.StackScrollerDecorView)20 FakeShadowView (com.android.systemui.statusbar.notification.FakeShadowView)20 HybridNotificationView (com.android.systemui.statusbar.notification.HybridNotificationView)20