Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be3b1aa6 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Only doing the icon animations now when expanding slowly"

parents 06457bb3 d5ab645f
Loading
Loading
Loading
Loading
+18 −6
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.statusbar.stack.AnimationProperties;
import com.android.systemui.statusbar.stack.ExpandableViewState;
import com.android.systemui.statusbar.stack.ExpandableViewState;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackScrollState;
import com.android.systemui.statusbar.stack.StackScrollState;
import com.android.systemui.statusbar.stack.ViewState;


/**
/**
 * A notification shelf view that is placed inside the notification scroller. It manages the
 * A notification shelf view that is placed inside the notification scroller. It manages the
@@ -200,7 +201,11 @@ public class NotificationShelf extends ActivatableNotificationView {
        int colorTwoBefore = NO_COLOR;
        int colorTwoBefore = NO_COLOR;
        int previousColor = NO_COLOR;
        int previousColor = NO_COLOR;
        float transitionAmount = 0.0f;
        float transitionAmount = 0.0f;
        boolean scrollingFast = mAmbientState.getCurrentScrollVelocity() > mScrollFastThreshold;
        boolean scrollingFast = mAmbientState.getCurrentScrollVelocity() > mScrollFastThreshold
                || (mAmbientState.isExpansionChanging()
                        && Math.abs(mAmbientState.getExpandingVelocity()) > mScrollFastThreshold);
        boolean expandingAnimated = mAmbientState.isExpansionChanging()
                && !mAmbientState.isPanelTracking();
        int baseZHeight = mAmbientState.getBaseZHeight();
        int baseZHeight = mAmbientState.getBaseZHeight();
        while (notificationIndex < mHostLayout.getChildCount()) {
        while (notificationIndex < mHostLayout.getChildCount()) {
            ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex);
            ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex);
@@ -228,7 +233,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            }
            }
            updateNotificationClipHeight(row, notificationClipEnd);
            updateNotificationClipHeight(row, notificationClipEnd);
            float inShelfAmount = updateIconAppearance(row, expandAmount, scrollingFast,
            float inShelfAmount = updateIconAppearance(row, expandAmount, scrollingFast,
                    isLastChild);
                    expandingAnimated, isLastChild);
            numViewsInShelf += inShelfAmount;
            numViewsInShelf += inShelfAmount;
            int ownColorUntinted = row.getBackgroundColorWithoutTint();
            int ownColorUntinted = row.getBackgroundColorWithoutTint();
            if (rowTranslationY >= shelfStart && mNotGoneIndex == -1) {
            if (rowTranslationY >= shelfStart && mNotGoneIndex == -1) {
@@ -278,7 +283,7 @@ public class NotificationShelf extends ActivatableNotificationView {
     * @return the icon amount how much this notification is in the shelf;
     * @return the icon amount how much this notification is in the shelf;
     */
     */
    private float updateIconAppearance(ExpandableNotificationRow row, float expandAmount,
    private float updateIconAppearance(ExpandableNotificationRow row, float expandAmount,
            boolean scrollingFast, boolean isLastChild) {
            boolean scrollingFast, boolean expandingAnimated, boolean isLastChild) {
        // Let calculate how much the view is in the shelf
        // Let calculate how much the view is in the shelf
        float viewStart = row.getTranslationY();
        float viewStart = row.getTranslationY();
        int fullHeight = row.getActualHeight() + mPaddingBetweenElements;
        int fullHeight = row.getActualHeight() + mPaddingBetweenElements;
@@ -316,12 +321,13 @@ public class NotificationShelf extends ActivatableNotificationView {
            iconTransitionAmount = 0.0f;
            iconTransitionAmount = 0.0f;
        }
        }
        updateIconPositioning(row, iconTransitionAmount, fullTransitionAmount, scrollingFast,
        updateIconPositioning(row, iconTransitionAmount, fullTransitionAmount, scrollingFast,
                isLastChild);
                expandingAnimated, isLastChild);
        return fullTransitionAmount;
        return fullTransitionAmount;
    }
    }


    private void updateIconPositioning(ExpandableNotificationRow row, float iconTransitionAmount,
    private void updateIconPositioning(ExpandableNotificationRow row, float iconTransitionAmount,
            float fullTransitionAmount, boolean scrollingFast, boolean isLastChild) {
            float fullTransitionAmount, boolean scrollingFast, boolean expandingAnimated,
            boolean isLastChild) {
        StatusBarIconView icon = row.getEntry().expandedIcon;
        StatusBarIconView icon = row.getEntry().expandedIcon;
        NotificationIconContainer.IconState iconState = getIconState(icon);
        NotificationIconContainer.IconState iconState = getIconState(icon);
        if (iconState == null) {
        if (iconState == null) {
@@ -332,10 +338,16 @@ public class NotificationShelf extends ActivatableNotificationView {
            iconState.keepClampedPosition = false;
            iconState.keepClampedPosition = false;
        }
        }
        if (clampedAmount == fullTransitionAmount) {
        if (clampedAmount == fullTransitionAmount) {
            iconState.useFullTransitionAmount = fullTransitionAmount == 0.0f || scrollingFast;
            iconState.useFullTransitionAmount = fullTransitionAmount == 0.0f || scrollingFast
                    || expandingAnimated;
            iconState.translateContent = mMaxLayoutHeight - getTranslationY()
            iconState.translateContent = mMaxLayoutHeight - getTranslationY()
                    - getIntrinsicHeight() > 0;
                    - getIntrinsicHeight() > 0;
        }
        }
        if (scrollingFast || (expandingAnimated && iconState.useFullTransitionAmount
                && !ViewState.isAnimatingY(icon))) {
            iconState.cancelAnimations(icon);
            iconState.useFullTransitionAmount = true;
        }
        float transitionAmount;
        float transitionAmount;
        boolean needCannedAnimation = iconState.clampedAppearAmount == 1.0f
        boolean needCannedAnimation = iconState.clampedAppearAmount == 1.0f
                && clampedAmount == 0.0f;
                && clampedAmount == 0.0f;
+17 −14
Original line number Original line Diff line number Diff line
@@ -105,7 +105,7 @@ public class NotificationPanelView extends PanelView implements
    private boolean mAnimateNextTopPaddingChange;
    private boolean mAnimateNextTopPaddingChange;


    private int mTrackingPointer;
    private int mTrackingPointer;
    private VelocityTracker mVelocityTracker;
    private VelocityTracker mQsVelocityTracker;
    private boolean mQsTracking;
    private boolean mQsTracking;


    /**
    /**
@@ -688,7 +688,7 @@ public class NotificationPanelView extends PanelView implements
    }
    }


    private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) {
    private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) {
        float vel = getCurrentVelocity();
        float vel = getCurrentQSVelocity();
        final boolean expandsQs = flingExpandsQs(vel);
        final boolean expandsQs = flingExpandsQs(vel);
        if (expandsQs) {
        if (expandsQs) {
            logQsSwipeDown(y);
            logQsSwipeDown(y);
@@ -697,7 +697,7 @@ public class NotificationPanelView extends PanelView implements
    }
    }


    private void logQsSwipeDown(float y) {
    private void logQsSwipeDown(float y) {
        float vel = getCurrentVelocity();
        float vel = getCurrentQSVelocity();
        final int gesture = mStatusBarState == StatusBarState.KEYGUARD
        final int gesture = mStatusBarState == StatusBarState.KEYGUARD
                ? EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DOWN_QS
                ? EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DOWN_QS
                : EventLogConstants.SYSUI_SHADE_GESTURE_SWIPE_DOWN_QS;
                : EventLogConstants.SYSUI_SHADE_GESTURE_SWIPE_DOWN_QS;
@@ -926,9 +926,9 @@ public class NotificationPanelView extends PanelView implements
                    flingQsWithCurrentVelocity(y,
                    flingQsWithCurrentVelocity(y,
                            event.getActionMasked() == MotionEvent.ACTION_CANCEL);
                            event.getActionMasked() == MotionEvent.ACTION_CANCEL);
                }
                }
                if (mVelocityTracker != null) {
                if (mQsVelocityTracker != null) {
                    mVelocityTracker.recycle();
                    mQsVelocityTracker.recycle();
                    mVelocityTracker = null;
                    mQsVelocityTracker = null;
                }
                }
                break;
                break;
        }
        }
@@ -1290,24 +1290,24 @@ public class NotificationPanelView extends PanelView implements
    }
    }


    private void trackMovement(MotionEvent event) {
    private void trackMovement(MotionEvent event) {
        if (mVelocityTracker != null) mVelocityTracker.addMovement(event);
        if (mQsVelocityTracker != null) mQsVelocityTracker.addMovement(event);
        mLastTouchX = event.getX();
        mLastTouchX = event.getX();
        mLastTouchY = event.getY();
        mLastTouchY = event.getY();
    }
    }


    private void initVelocityTracker() {
    private void initVelocityTracker() {
        if (mVelocityTracker != null) {
        if (mQsVelocityTracker != null) {
            mVelocityTracker.recycle();
            mQsVelocityTracker.recycle();
        }
        }
        mVelocityTracker = VelocityTracker.obtain();
        mQsVelocityTracker = VelocityTracker.obtain();
    }
    }


    private float getCurrentVelocity() {
    private float getCurrentQSVelocity() {
        if (mVelocityTracker == null) {
        if (mQsVelocityTracker == null) {
            return 0;
            return 0;
        }
        }
        mVelocityTracker.computeCurrentVelocity(1000);
        mQsVelocityTracker.computeCurrentVelocity(1000);
        return mVelocityTracker.getYVelocity();
        return mQsVelocityTracker.getYVelocity();
    }
    }


    private void cancelQsAnimation() {
    private void cancelQsAnimation() {
@@ -2282,6 +2282,9 @@ public class NotificationPanelView extends PanelView implements
    }
    }


    protected void updateExpandedHeight(float expandedHeight) {
    protected void updateExpandedHeight(float expandedHeight) {
        if (mTracking) {
            mNotificationStackScroller.setExpandingVelocity(getCurrentExpandVelocity());
        }
        mNotificationStackScroller.setExpandedHeight(expandedHeight);
        mNotificationStackScroller.setExpandedHeight(expandedHeight);
        updateKeyguardBottomAreaAlpha();
        updateKeyguardBottomAreaAlpha();
        setOpening(expandedHeight <= getOpeningHeight());
        setOpening(expandedHeight <= getOpeningHeight());
+9 −2
Original line number Original line Diff line number Diff line
@@ -306,6 +306,7 @@ public abstract class PanelView extends FrameLayout {
                }
                }
                break;
                break;
            case MotionEvent.ACTION_MOVE:
            case MotionEvent.ACTION_MOVE:
                trackMovement(event);
                float h = y - mInitialTouchY;
                float h = y - mInitialTouchY;


                // If the panel was collapsed when touching, we only need to check for the
                // If the panel was collapsed when touching, we only need to check for the
@@ -346,8 +347,6 @@ public abstract class PanelView extends FrameLayout {
                        !isTrackingBlocked()) {
                        !isTrackingBlocked()) {
                    setExpandedHeightInternal(newHeight);
                    setExpandedHeightInternal(newHeight);
                }
                }

                trackMovement(event);
                break;
                break;


            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_UP:
@@ -449,6 +448,14 @@ public abstract class PanelView extends FrameLayout {
        mPeekTouching = false;
        mPeekTouching = false;
    }
    }


    protected float getCurrentExpandVelocity() {
        if (mVelocityTracker == null) {
            return 0;
        }
        mVelocityTracker.computeCurrentVelocity(1000);
        return mVelocityTracker.getYVelocity();
    }

    private int getFalsingThreshold() {
    private int getFalsingThreshold() {
        float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
        float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
        return (int) (mUnlockFalsingThreshold * factor);
        return (int) (mUnlockFalsingThreshold * factor);
+27 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,9 @@ public class AmbientState {
    private ActivatableNotificationView mLastVisibleBackgroundChild;
    private ActivatableNotificationView mLastVisibleBackgroundChild;
    private float mCurrentScrollVelocity;
    private float mCurrentScrollVelocity;
    private int mStatusBarState;
    private int mStatusBarState;
    private float mExpandingVelocity;
    private boolean mPanelTracking;
    private boolean mExpansionChanging;


    public AmbientState(Context context) {
    public AmbientState(Context context) {
        reload(context);
        reload(context);
@@ -260,4 +263,28 @@ public class AmbientState {
    public void setStatusBarState(int statusBarState) {
    public void setStatusBarState(int statusBarState) {
        mStatusBarState = statusBarState;
        mStatusBarState = statusBarState;
    }
    }

    public void setExpandingVelocity(float expandingVelocity) {
        mExpandingVelocity = expandingVelocity;
    }

    public void setExpansionChanging(boolean expansionChanging) {
        mExpansionChanging = expansionChanging;
    }

    public boolean isExpansionChanging() {
        return mExpansionChanging;
    }

    public float getExpandingVelocity() {
        return mExpandingVelocity;
    }

    public void setPanelTracking(boolean panelTracking) {
        mPanelTracking = panelTracking;
    }

    public boolean isPanelTracking() {
        return mPanelTracking;
    }
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -3124,10 +3124,12 @@ public class NotificationStackScrollLayout extends ViewGroup


    public void onExpansionStarted() {
    public void onExpansionStarted() {
        mIsExpansionChanging = true;
        mIsExpansionChanging = true;
        mAmbientState.setExpansionChanging(true);
    }
    }


    public void onExpansionStopped() {
    public void onExpansionStopped() {
        mIsExpansionChanging = false;
        mIsExpansionChanging = false;
        mAmbientState.setExpansionChanging(false);
        if (!mIsExpanded) {
        if (!mIsExpanded) {
            setOwnScrollY(0);
            setOwnScrollY(0);
            mPhoneStatusBar.resetUserExpandedStates();
            mPhoneStatusBar.resetUserExpandedStates();
@@ -3155,9 +3157,11 @@ public class NotificationStackScrollLayout extends ViewGroup


    public void onPanelTrackingStarted() {
    public void onPanelTrackingStarted() {
        mPanelTracking = true;
        mPanelTracking = true;
        mAmbientState.setPanelTracking(true);
    }
    }
    public void onPanelTrackingStopped() {
    public void onPanelTrackingStopped() {
        mPanelTracking = false;
        mPanelTracking = false;
        mAmbientState.setPanelTracking(false);
    }
    }


    public void resetScrollPosition() {
    public void resetScrollPosition() {
@@ -3987,6 +3991,10 @@ public class NotificationStackScrollLayout extends ViewGroup
        mAmbientState.setStatusBarState(statusBarState);
        mAmbientState.setStatusBarState(statusBarState);
    }
    }


    public void setExpandingVelocity(float expandingVelocity) {
        mAmbientState.setExpandingVelocity(expandingVelocity);
    }

    /**
    /**
     * A listener that is notified when some child locations might have changed.
     * A listener that is notified when some child locations might have changed.
     */
     */
Loading