Search in sources :

Example 1 with ExpandableView

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

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

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

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

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

the class StackStateAnimator method startAnimationForEvents.

public void startAnimationForEvents(ArrayList<NotificationStackScrollLayout.AnimationEvent> mAnimationEvents, StackScrollState finalState, long additionalDelay) {
    processAnimationEvents(mAnimationEvents, finalState);
    int childCount = mHostLayout.getChildCount();
    mAnimationFilter.applyCombination(mNewEvents);
    mCurrentAdditionalDelay = additionalDelay;
    mCurrentLength = NotificationStackScrollLayout.AnimationEvent.combineLength(mNewEvents);
    mCurrentLastNotAddedIndex = findLastNotAddedIndex(finalState);
    for (int i = 0; i < childCount; i++) {
        final ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i);
        StackViewState viewState = finalState.getViewStateForView(child);
        if (viewState == null || child.getVisibility() == View.GONE || applyWithoutAnimation(child, viewState, finalState)) {
            continue;
        }
        startStackAnimations(child, viewState, finalState, i, -1);
    }
    if (!isRunning()) {
        // no child has preformed any animation, lets finish
        onAnimationFinished();
    }
    mHeadsUpAppearChildren.clear();
    mHeadsUpDisappearChildren.clear();
    mNewEvents.clear();
    mNewAddChildren.clear();
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView)

Example 4 with ExpandableView

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

the class RemoteInputView method findScrollContainer.

private void findScrollContainer() {
    if (mScrollContainer == null) {
        mScrollContainerChild = null;
        ViewParent p = this;
        while (p != null) {
            if (mScrollContainerChild == null && p instanceof ExpandableView) {
                mScrollContainerChild = (View) p;
            }
            if (p.getParent() instanceof ScrollContainer) {
                mScrollContainer = (ScrollContainer) p.getParent();
                if (mScrollContainerChild == null) {
                    mScrollContainerChild = (View) p;
                }
                break;
            }
            p = p.getParent();
        }
    }
}
Also used : ViewParent(android.view.ViewParent) ScrollContainer(com.android.systemui.statusbar.stack.ScrollContainer) ExpandableView(com.android.systemui.statusbar.ExpandableView)

Example 5 with ExpandableView

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

the class NotificationStackScrollLayout method setHideSensitive.

public void setHideSensitive(boolean hideSensitive, boolean animate) {
    if (hideSensitive != mAmbientState.isHideSensitive()) {
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            ExpandableView v = (ExpandableView) getChildAt(i);
            v.setHideSensitiveForIntrinsicHeight(hideSensitive);
        }
        mAmbientState.setHideSensitive(hideSensitive);
        if (animate && mAnimationsEnabled) {
            mHideSensitiveNeedsAnimation = true;
            mNeedsAnimation = true;
        }
        requestChildrenUpdate();
    }
}
Also used : ExpandableView(com.android.systemui.statusbar.ExpandableView) Paint(android.graphics.Paint)

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