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

Commit d5ab645f authored by Selim Cinek's avatar Selim Cinek
Browse files

Only doing the icon animations now when expanding slowly

Previously the animation was too distrating when expanding
fast.

Test: add notification, expand fast, observe no animations
Change-Id: I11658368b49094368886c64028c210a1dc95d938
Fixes: 33458094
parent 378053af
Loading
Loading
Loading
Loading
+18 −6
Original line number 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.NotificationStackScrollLayout;
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
@@ -200,7 +201,11 @@ public class NotificationShelf extends ActivatableNotificationView {
        int colorTwoBefore = NO_COLOR;
        int previousColor = NO_COLOR;
        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();
        while (notificationIndex < mHostLayout.getChildCount()) {
            ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex);
@@ -228,7 +233,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            }
            updateNotificationClipHeight(row, notificationClipEnd);
            float inShelfAmount = updateIconAppearance(row, expandAmount, scrollingFast,
                    isLastChild);
                    expandingAnimated, isLastChild);
            numViewsInShelf += inShelfAmount;
            int ownColorUntinted = row.getBackgroundColorWithoutTint();
            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;
     */
    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
        float viewStart = row.getTranslationY();
        int fullHeight = row.getActualHeight() + mPaddingBetweenElements;
@@ -316,12 +321,13 @@ public class NotificationShelf extends ActivatableNotificationView {
            iconTransitionAmount = 0.0f;
        }
        updateIconPositioning(row, iconTransitionAmount, fullTransitionAmount, scrollingFast,
                isLastChild);
                expandingAnimated, isLastChild);
        return fullTransitionAmount;
    }

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

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

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

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

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

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

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

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

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

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

                // 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()) {
                    setExpandedHeightInternal(newHeight);
                }

                trackMovement(event);
                break;

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

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

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

    public AmbientState(Context context) {
        reload(context);
@@ -260,4 +263,28 @@ public class AmbientState {
    public void setStatusBarState(int 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 Diff line number Diff line
@@ -3124,10 +3124,12 @@ public class NotificationStackScrollLayout extends ViewGroup

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

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

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

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

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

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