Search in sources :

Example 56 with ExpandableView

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

the class NotificationStackScrollLayout method getPositionInLinearLayout.

private int getPositionInLinearLayout(View requestedView) {
    ExpandableNotificationRow childInGroup = null;
    ExpandableNotificationRow requestedRow = null;
    if (isChildInGroup(requestedView)) {
        // We're asking for a child in a group. Calculate the position of the parent first,
        // then within the parent.
        childInGroup = (ExpandableNotificationRow) requestedView;
        requestedView = requestedRow = childInGroup.getNotificationParent();
    }
    int position = 0;
    float previousIncreasedAmount = 0.0f;
    for (int i = 0; i < getChildCount(); i++) {
        ExpandableView child = (ExpandableView) getChildAt(i);
        boolean notGone = child.getVisibility() != View.GONE;
        if (notGone) {
            float increasedPaddingAmount = child.getIncreasedPaddingAmount();
            if (position != 0) {
                position += (int) NotificationUtils.interpolate(mPaddingBetweenElements, mIncreasedPaddingBetweenElements, Math.max(previousIncreasedAmount, increasedPaddingAmount));
            }
            previousIncreasedAmount = increasedPaddingAmount;
        }
        if (child == requestedView) {
            if (requestedRow != null) {
                position += requestedRow.getPositionOfChild(childInGroup);
            }
            return position;
        }
        if (notGone) {
            position += getIntrinsicHeight(child);
        }
    }
    return 0;
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) Paint(android.graphics.Paint) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 57 with ExpandableView

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

the class HeadsUpTouchHelper method onInterceptTouchEvent.

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    if (!mTouchingHeadsUpView && event.getActionMasked() != MotionEvent.ACTION_DOWN) {
        return false;
    }
    int pointerIndex = event.findPointerIndex(mTrackingPointer);
    if (pointerIndex < 0) {
        pointerIndex = 0;
        mTrackingPointer = event.getPointerId(pointerIndex);
    }
    final float x = event.getX(pointerIndex);
    final float y = event.getY(pointerIndex);
    switch(event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mInitialTouchY = y;
            mInitialTouchX = x;
            setTrackingHeadsUp(false);
            ExpandableView child = mStackScroller.getChildAtRawPosition(x, y);
            mTouchingHeadsUpView = false;
            if (child instanceof ExpandableNotificationRow) {
                mPickedChild = (ExpandableNotificationRow) child;
                mTouchingHeadsUpView = !mStackScroller.isExpanded() && mPickedChild.isHeadsUp() && mPickedChild.isPinned();
            }
            break;
        case MotionEvent.ACTION_POINTER_UP:
            final int upPointer = event.getPointerId(event.getActionIndex());
            if (mTrackingPointer == upPointer) {
                // gesture is ongoing, find a new pointer to track
                final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1;
                mTrackingPointer = event.getPointerId(newIndex);
                mInitialTouchX = event.getX(newIndex);
                mInitialTouchY = event.getY(newIndex);
            }
            break;
        case MotionEvent.ACTION_MOVE:
            final float h = y - mInitialTouchY;
            if (mTouchingHeadsUpView && Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
                setTrackingHeadsUp(true);
                mCollapseSnoozes = h < 0;
                mInitialTouchX = x;
                mInitialTouchY = y;
                int expandedHeight = mPickedChild.getActualHeight();
                mPanel.setPanelScrimMinFraction((float) expandedHeight / mPanel.getMaxPanelHeight());
                mPanel.startExpandMotion(x, y, true, /* startTracking */
                expandedHeight);
                // This call needs to be after the expansion start otherwise we will get a
                // flicker of one frame as it's not expanded yet.
                mHeadsUpManager.unpinAll();
                mPanel.clearNotificationEffects();
                return true;
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            if (mPickedChild != null && mTouchingHeadsUpView) {
                // We may swallow this click if the heads up just came in.
                if (mHeadsUpManager.shouldSwallowClick(mPickedChild.getStatusBarNotification().getKey())) {
                    endMotion();
                    return true;
                }
            }
            endMotion();
            break;
    }
    return false;
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 58 with ExpandableView

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

the class StackScrollAlgorithm method getNotificationChildrenStates.

private void getNotificationChildrenStates(StackScrollState resultState, StackScrollAlgorithmState algorithmState) {
    int childCount = algorithmState.visibleChildren.size();
    for (int i = 0; i < childCount; i++) {
        ExpandableView v = algorithmState.visibleChildren.get(i);
        if (v instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
            row.getChildrenStates(resultState);
        }
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 59 with ExpandableView

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

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

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

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

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