Search in sources :

Example 31 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project android_frameworks_base by ResurrectionRemix.

the class StackScrollAlgorithm method updatePositionsForState.

/**
     * Determine the positions for the views. This is the main part of the algorithm.
     *
     * @param resultState The result state to update if a change to the properties of a child occurs
     * @param algorithmState The state in which the current pass of the algorithm is currently in
     * @param ambientState The current ambient state
     */
private void updatePositionsForState(StackScrollState resultState, StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
    // The starting position of the bottom stack peek
    float bottomPeekStart = ambientState.getInnerHeight() - mBottomStackPeekSize;
    // The position where the bottom stack starts.
    float bottomStackStart = bottomPeekStart - mBottomStackSlowDownLength;
    // The y coordinate of the current child.
    float currentYPosition = -algorithmState.scrollY;
    int childCount = algorithmState.visibleChildren.size();
    int paddingAfterChild;
    for (int i = 0; i < childCount; i++) {
        ExpandableView child = algorithmState.visibleChildren.get(i);
        StackViewState childViewState = resultState.getViewStateForView(child);
        childViewState.location = StackViewState.LOCATION_UNKNOWN;
        paddingAfterChild = getPaddingAfterChild(algorithmState, child);
        int childHeight = getMaxAllowedChildHeight(child);
        int collapsedHeight = child.getCollapsedHeight();
        childViewState.yTranslation = currentYPosition;
        if (i == 0) {
            updateFirstChildHeight(child, childViewState, childHeight, ambientState);
        }
        // The y position after this element
        float nextYPosition = currentYPosition + childHeight + paddingAfterChild;
        if (nextYPosition >= bottomStackStart) {
            // We are in the bottom stack.
            if (currentYPosition >= bottomStackStart) {
                // According to the regular scroll view we are fully translated out of the
                // bottom of the screen so we are fully in the bottom stack
                updateStateForChildFullyInBottomStack(algorithmState, bottomStackStart, childViewState, collapsedHeight, ambientState, child);
            } else {
                // According to the regular scroll view we are currently translating out of /
                // into the bottom of the screen
                updateStateForChildTransitioningInBottom(algorithmState, bottomStackStart, child, currentYPosition, childViewState, childHeight);
            }
        } else {
            // Case 2:
            // We are in the regular scroll area.
            childViewState.location = StackViewState.LOCATION_MAIN_AREA;
            clampPositionToBottomStackStart(childViewState, childViewState.height, childHeight, ambientState);
        }
        if (i == 0 && ambientState.getScrollY() <= 0) {
            // The first card can get into the bottom stack if it's the only one
            // on the lockscreen which pushes it up. Let's make sure that doesn't happen and
            // it stays at the top
            childViewState.yTranslation = Math.max(0, childViewState.yTranslation);
        }
        currentYPosition = childViewState.yTranslation + childHeight + paddingAfterChild;
        if (currentYPosition <= 0) {
            childViewState.location = StackViewState.LOCATION_HIDDEN_TOP;
        }
        if (childViewState.location == StackViewState.LOCATION_UNKNOWN) {
            Log.wtf(LOG_TAG, "Failed to assign location for child " + i);
        }
        childViewState.yTranslation += ambientState.getTopPadding() + ambientState.getStackTranslation();
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView)

Example 32 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project android_frameworks_base by ResurrectionRemix.

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 33 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project android_frameworks_base by ResurrectionRemix.

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 34 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project android_frameworks_base by ResurrectionRemix.

the class NotificationStackScrollLayout method changeViewPosition.

/**
     * Change the position of child to a new location
     *
     * @param child the view to change the position for
     * @param newIndex the new index
     */
public void changeViewPosition(View child, int newIndex) {
    int currentIndex = indexOfChild(child);
    if (child != null && child.getParent() == this && currentIndex != newIndex) {
        mChangePositionInProgress = true;
        ((ExpandableView) child).setChangingPosition(true);
        removeView(child);
        addView(child, newIndex);
        ((ExpandableView) child).setChangingPosition(false);
        mChangePositionInProgress = false;
        if (mIsExpanded && mAnimationsEnabled && child.getVisibility() != View.GONE) {
            mChildrenChangingPositions.add(child);
            mNeedsAnimation = true;
        }
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) Paint(android.graphics.Paint)

Example 35 with ExpandableView

use of com.android.systemui.statusbar.ExpandableView in project android_frameworks_base by ResurrectionRemix.

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)

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