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

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

Merge "Fixed that views could be stuck transiently at times" into pi-dev

parents c46279aa 9dd0d04e
Loading
Loading
Loading
Loading
+9 −12
Original line number Original line Diff line number Diff line
@@ -292,7 +292,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    private int[] mTempInt2 = new int[2];
    private int[] mTempInt2 = new int[2];
    private boolean mGenerateChildOrderChangedEvent;
    private boolean mGenerateChildOrderChangedEvent;
    private HashSet<Runnable> mAnimationFinishedRunnables = new HashSet<>();
    private HashSet<Runnable> mAnimationFinishedRunnables = new HashSet<>();
    private HashSet<View> mClearOverlayViewsWhenFinished = new HashSet<>();
    private HashSet<ExpandableView> mClearTransientViewsWhenFinished = new HashSet<>();
    private HashSet<Pair<ExpandableNotificationRow, Boolean>> mHeadsUpChangeAnimations
    private HashSet<Pair<ExpandableNotificationRow, Boolean>> mHeadsUpChangeAnimations
            = new HashSet<>();
            = new HashSet<>();
    private HeadsUpManagerPhone mHeadsUpManager;
    private HeadsUpManagerPhone mHeadsUpManager;
@@ -2831,8 +2831,8 @@ public class NotificationStackScrollLayout extends ViewGroup
            return false;
            return false;
        }
        }
        if (isClickedHeadsUp(child)) {
        if (isClickedHeadsUp(child)) {
            // An animation is already running, add it to the Overlay
            // An animation is already running, add it transiently
            mClearOverlayViewsWhenFinished.add(child);
            mClearTransientViewsWhenFinished.add((ExpandableView) child);
            return true;
            return true;
        }
        }
        if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) {
        if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) {
@@ -3622,7 +3622,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }
    }


    private void clearTemporaryViews() {
    private void clearTemporaryViews() {
        // lets make sure nothing is in the overlay / transient anymore
        // lets make sure nothing is transient anymore
        clearTemporaryViewsInGroup(this);
        clearTemporaryViewsInGroup(this);
        for (int i = 0; i < getChildCount(); i++) {
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView child = (ExpandableView) getChildAt(i);
            ExpandableView child = (ExpandableView) getChildAt(i);
@@ -3637,9 +3637,6 @@ public class NotificationStackScrollLayout extends ViewGroup
        while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
        while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
            viewGroup.removeTransientView(viewGroup.getTransientView(0));
            viewGroup.removeTransientView(viewGroup.getTransientView(0));
        }
        }
        if (viewGroup != null) {
            viewGroup.getOverlay().clear();
        }
    }
    }


    public void onPanelTrackingStarted() {
    public void onPanelTrackingStarted() {
@@ -3747,7 +3744,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        setAnimationRunning(false);
        setAnimationRunning(false);
        requestChildrenUpdate();
        requestChildrenUpdate();
        runAnimationFinishedRunnables();
        runAnimationFinishedRunnables();
        clearViewOverlays();
        clearTransient();
        clearHeadsUpDisappearRunning();
        clearHeadsUpDisappearRunning();
    }
    }


@@ -3766,11 +3763,11 @@ public class NotificationStackScrollLayout extends ViewGroup
        }
        }
    }
    }


    private void clearViewOverlays() {
    private void clearTransient() {
        for (View view : mClearOverlayViewsWhenFinished) {
        for (ExpandableView view : mClearTransientViewsWhenFinished) {
            StackStateAnimator.removeFromOverlay(view);
            StackStateAnimator.removeTransientView(view);
        }
        }
        mClearOverlayViewsWhenFinished.clear();
        mClearTransientViewsWhenFinished.clear();
    }
    }


    private void runAnimationFinishedRunnables() {
    private void runAnimationFinishedRunnables() {
+5 −17
Original line number Original line Diff line number Diff line
@@ -419,9 +419,6 @@ public class StackStateAnimator {
                }, null);
                }, null);
            } else if (event.animationType ==
            } else if (event.animationType ==
                NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_REMOVE_SWIPED_OUT) {
                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()
                if (Math.abs(changingView.getTranslation()) == changingView.getWidth()
                        && changingView.getTransientContainer() != null) {
                        && changingView.getTransientContainer() != null) {
                    changingView.getTransientContainer().removeTransientView(changingView);
                    changingView.getTransientContainer().removeTransientView(changingView);
@@ -469,8 +466,9 @@ public class StackStateAnimator {
                        ? ANIMATION_DELAY_HEADS_UP_CLICKED
                        ? ANIMATION_DELAY_HEADS_UP_CLICKED
                        : 0;
                        : 0;
                if (changingView.getParent() == null) {
                if (changingView.getParent() == null) {
                    // This notification was actually removed, so we need to add it to the overlay
                    // This notification was actually removed, so we need to add it transiently
                    mHostLayout.getOverlay().add(changingView);
                    mHostLayout.addTransientView(changingView, 0);
                    changingView.setTransientContainer(mHostLayout);
                    mTmpState.initFrom(changingView);
                    mTmpState.initFrom(changingView);
                    mTmpState.yTranslation = 0;
                    mTmpState.yTranslation = 0;
                    // We temporarily enable Y animations, the real filter will be combined
                    // We temporarily enable Y animations, the real filter will be combined
@@ -479,10 +477,7 @@ public class StackStateAnimator {
                    mAnimationProperties.delay = extraDelay + ANIMATION_DELAY_HEADS_UP;
                    mAnimationProperties.delay = extraDelay + ANIMATION_DELAY_HEADS_UP;
                    mAnimationProperties.duration = ANIMATION_DURATION_HEADS_UP_DISAPPEAR;
                    mAnimationProperties.duration = ANIMATION_DURATION_HEADS_UP_DISAPPEAR;
                    mTmpState.animateTo(changingView, mAnimationProperties);
                    mTmpState.animateTo(changingView, mAnimationProperties);
                    endRunnable = () -> {
                    endRunnable = () -> removeTransientView(changingView);
                        // remove the temporary overlay
                        removeFromOverlay(changingView);
                    };
                }
                }
                float targetLocation = 0;
                float targetLocation = 0;
                boolean needsAnimation = true;
                boolean needsAnimation = true;
@@ -517,19 +512,12 @@ public class StackStateAnimator {
        }
        }
    }
    }


    private static void removeTransientView(ExpandableView viewToRemove) {
    public static void removeTransientView(ExpandableView viewToRemove) {
        if (viewToRemove.getTransientContainer() != null) {
        if (viewToRemove.getTransientContainer() != null) {
            viewToRemove.getTransientContainer().removeTransientView(viewToRemove);
            viewToRemove.getTransientContainer().removeTransientView(viewToRemove);
        }
        }
    }
    }


    public static void removeFromOverlay(View changingView) {
        ViewGroup parent = (ViewGroup) changingView.getParent();
        if (parent != null) {
            parent.removeView(changingView);
        }
    }

    public void animateOverScrollToAmount(float targetAmount, final boolean onTop,
    public void animateOverScrollToAmount(float targetAmount, final boolean onTop,
            final boolean isRubberbanded) {
            final boolean isRubberbanded) {
        final float startOverScrollAmount = mHostLayout.getCurrentOverScrollAmount(onTop);
        final float startOverScrollAmount = mHostLayout.getCurrentOverScrollAmount(onTop);