Search in sources :

Example 6 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project platform_frameworks_base by android.

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)

Example 7 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project platform_frameworks_base by android.

the class StackScrollAlgorithm method updateZValuesForState.

/**
     * Calculate the Z positions for all children based on the number of items in both stacks and
     * save it in the resultState
     *  @param resultState The result state to update the zTranslation values
     * @param algorithmState The state in which the current pass of the algorithm is currently in
     * @param ambientState The ambient state of the algorithm
     */
private void updateZValuesForState(StackScrollState resultState, StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
    int childCount = algorithmState.visibleChildren.size();
    float childrenOnTop = 0.0f;
    for (int i = childCount - 1; i >= 0; i--) {
        ExpandableView child = algorithmState.visibleChildren.get(i);
        StackViewState childViewState = resultState.getViewStateForView(child);
        if (i > (childCount - 1 - algorithmState.itemsInBottomStack)) {
            // We are in the bottom stack
            float numItemsAbove = i - (childCount - 1 - algorithmState.itemsInBottomStack);
            float zSubtraction;
            if (numItemsAbove <= 1.0f) {
                float factor = 0.2f;
                // Lets fade in slower to the threshold to make the shadow fade in look nicer
                if (numItemsAbove <= factor) {
                    zSubtraction = FakeShadowView.SHADOW_SIBLING_TRESHOLD * numItemsAbove * (1.0f / factor);
                } else {
                    zSubtraction = FakeShadowView.SHADOW_SIBLING_TRESHOLD + (numItemsAbove - factor) * (1.0f / (1.0f - factor)) * (mZDistanceBetweenElements - FakeShadowView.SHADOW_SIBLING_TRESHOLD);
                }
            } else {
                zSubtraction = numItemsAbove * mZDistanceBetweenElements;
            }
            childViewState.zTranslation = mZBasicHeight - zSubtraction;
        } else if (child.mustStayOnScreen() && childViewState.yTranslation < ambientState.getTopPadding() + ambientState.getStackTranslation()) {
            if (childrenOnTop != 0.0f) {
                childrenOnTop++;
            } else {
                float overlap = ambientState.getTopPadding() + ambientState.getStackTranslation() - childViewState.yTranslation;
                childrenOnTop += Math.min(1.0f, overlap / childViewState.height);
            }
            childViewState.zTranslation = mZBasicHeight + childrenOnTop * mZDistanceBetweenElements;
        } else {
            childViewState.zTranslation = mZBasicHeight;
        }
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView)

Example 8 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project platform_frameworks_base by android.

the class StackScrollAlgorithm method updateClipping.

private void updateClipping(StackScrollState resultState, StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
    float drawStart = ambientState.getTopPadding() + ambientState.getStackTranslation();
    float previousNotificationEnd = 0;
    float previousNotificationStart = 0;
    int childCount = algorithmState.visibleChildren.size();
    for (int i = 0; i < childCount; i++) {
        ExpandableView child = algorithmState.visibleChildren.get(i);
        StackViewState state = resultState.getViewStateForView(child);
        if (!child.mustStayOnScreen()) {
            previousNotificationEnd = Math.max(drawStart, previousNotificationEnd);
            previousNotificationStart = Math.max(drawStart, previousNotificationStart);
        }
        float newYTranslation = state.yTranslation;
        float newHeight = state.height;
        float newNotificationEnd = newYTranslation + newHeight;
        boolean isHeadsUp = (child instanceof ExpandableNotificationRow) && ((ExpandableNotificationRow) child).isPinned();
        if (newYTranslation < previousNotificationEnd && (!isHeadsUp || ambientState.isShadeExpanded())) {
            // The previous view is overlapping on top, clip!
            float overlapAmount = previousNotificationEnd - newYTranslation;
            state.clipTopAmount = (int) overlapAmount;
        } else {
            state.clipTopAmount = 0;
        }
        if (!child.isTransparent()) {
            // Only update the previous values if we are not transparent,
            // otherwise we would clip to a transparent view.
            previousNotificationEnd = newNotificationEnd;
            previousNotificationStart = newYTranslation;
        }
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 9 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project platform_frameworks_base by android.

the class StackScrollState method resetViewStates.

public void resetViewStates() {
    int numChildren = mHostView.getChildCount();
    for (int i = 0; i < numChildren; i++) {
        ExpandableView child = (ExpandableView) mHostView.getChildAt(i);
        resetViewState(child);
        // handling reset for child notifications
        if (child instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            List<ExpandableNotificationRow> children = row.getNotificationChildren();
            if (row.isSummaryWithChildren() && children != null) {
                for (ExpandableNotificationRow childRow : children) {
                    resetViewState(childRow);
                }
            }
        }
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 10 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project platform_frameworks_base by android.

the class StackScrollState method apply.

/**
     * Apply the properties saved in {@link #mStateMap} to the children of the {@link #mHostView}.
     * The properties are only applied if they effectively changed.
     */
public void apply() {
    int numChildren = mHostView.getChildCount();
    for (int i = 0; i < numChildren; i++) {
        ExpandableView child = (ExpandableView) mHostView.getChildAt(i);
        StackViewState state = mStateMap.get(child);
        if (!applyState(child, state)) {
            continue;
        }
        if (child instanceof DismissView) {
            DismissView dismissView = (DismissView) child;
            boolean visible = state.clipTopAmount < mClearAllTopPadding;
            dismissView.performVisibilityAnimation(visible && !dismissView.willBeGone());
        } else if (child instanceof EmptyShadeView) {
            EmptyShadeView emptyShadeView = (EmptyShadeView) child;
            boolean visible = state.clipTopAmount <= 0;
            emptyShadeView.performVisibilityAnimation(visible && !emptyShadeView.willBeGone());
        }
    }
}
Also used : EmptyShadeView(com.android.systemui.statusbar.EmptyShadeView) DismissView(com.android.systemui.statusbar.DismissView) ExpandableView(com.android.systemui.statusbar.ExpandableView)

Aggregations

ExpandableView (com.android.systemui.statusbar.ExpandableView)172 Paint (android.graphics.Paint)92 ExpandableNotificationRow (com.android.systemui.statusbar.ExpandableNotificationRow)55 StackScrollerDecorView (com.android.systemui.statusbar.StackScrollerDecorView)15 DismissView (com.android.systemui.statusbar.DismissView)10 EmptyShadeView (com.android.systemui.statusbar.EmptyShadeView)10 View (android.view.View)5 ViewGroup (android.view.ViewGroup)5 ViewParent (android.view.ViewParent)5 ScrollView (android.widget.ScrollView)5 ActivatableNotificationView (com.android.systemui.statusbar.ActivatableNotificationView)5 FakeShadowView (com.android.systemui.statusbar.notification.FakeShadowView)5 ScrollContainer (com.android.systemui.statusbar.stack.ScrollContainer)5