From 9dd0d04e2f03f6e25bca6bd2f74f53e18ce9eb1f Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 14 May 2018 18:12:42 -0700 Subject: [PATCH] Fixed that views could be stuck transiently at times Removed all references to overlay from the stackscroller and always using transient views now. We were using the overlay in places where we shouldn't have been and therefore views could become stuck. Change-Id: I8bf455e2d1c4d065d0b3c441606d51b3b96eab9f Fixes: 78493499 Test: add hun, click on it, observe no transient view stuck behind --- .../stack/NotificationStackScrollLayout.java | 22 ++++++++----------- .../statusbar/stack/StackStateAnimator.java | 22 +++++-------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index eeaa6cb586810..2981a5400cf0d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -113,7 +113,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.function.BiConsumer; /** @@ -295,7 +294,7 @@ public class NotificationStackScrollLayout extends ViewGroup private int[] mTempInt2 = new int[2]; private boolean mGenerateChildOrderChangedEvent; private HashSet mAnimationFinishedRunnables = new HashSet<>(); - private HashSet mClearOverlayViewsWhenFinished = new HashSet<>(); + private HashSet mClearTransientViewsWhenFinished = new HashSet<>(); private HashSet> mHeadsUpChangeAnimations = new HashSet<>(); private HeadsUpManagerPhone mHeadsUpManager; @@ -2830,8 +2829,8 @@ public class NotificationStackScrollLayout extends ViewGroup return false; } if (isClickedHeadsUp(child)) { - // An animation is already running, add it to the Overlay - mClearOverlayViewsWhenFinished.add(child); + // An animation is already running, add it transiently + mClearTransientViewsWhenFinished.add((ExpandableView) child); return true; } if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) { @@ -3613,7 +3612,7 @@ public class NotificationStackScrollLayout extends ViewGroup } private void clearTemporaryViews() { - // lets make sure nothing is in the overlay / transient anymore + // lets make sure nothing is transient anymore clearTemporaryViewsInGroup(this); for (int i = 0; i < getChildCount(); i++) { ExpandableView child = (ExpandableView) getChildAt(i); @@ -3628,9 +3627,6 @@ public class NotificationStackScrollLayout extends ViewGroup while (viewGroup != null && viewGroup.getTransientViewCount() != 0) { viewGroup.removeTransientView(viewGroup.getTransientView(0)); } - if (viewGroup != null) { - viewGroup.getOverlay().clear(); - } } public void onPanelTrackingStarted() { @@ -3738,7 +3734,7 @@ public class NotificationStackScrollLayout extends ViewGroup setAnimationRunning(false); requestChildrenUpdate(); runAnimationFinishedRunnables(); - clearViewOverlays(); + clearTransient(); clearHeadsUpDisappearRunning(); } @@ -3757,11 +3753,11 @@ public class NotificationStackScrollLayout extends ViewGroup } } - private void clearViewOverlays() { - for (View view : mClearOverlayViewsWhenFinished) { - StackStateAnimator.removeFromOverlay(view); + private void clearTransient() { + for (ExpandableView view : mClearTransientViewsWhenFinished) { + StackStateAnimator.removeTransientView(view); } - mClearOverlayViewsWhenFinished.clear(); + mClearTransientViewsWhenFinished.clear(); } private void runAnimationFinishedRunnables() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java index d01db148c366a..4e8fcac664300 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java @@ -419,9 +419,6 @@ public class StackStateAnimator { }, null); } 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); @@ -469,8 +466,9 @@ public class StackStateAnimator { ? ANIMATION_DELAY_HEADS_UP_CLICKED : 0; if (changingView.getParent() == null) { - // This notification was actually removed, so we need to add it to the overlay - mHostLayout.getOverlay().add(changingView); + // This notification was actually removed, so we need to add it transiently + mHostLayout.addTransientView(changingView, 0); + changingView.setTransientContainer(mHostLayout); mTmpState.initFrom(changingView); mTmpState.yTranslation = 0; // 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.duration = ANIMATION_DURATION_HEADS_UP_DISAPPEAR; mTmpState.animateTo(changingView, mAnimationProperties); - endRunnable = () -> { - // remove the temporary overlay - removeFromOverlay(changingView); - }; + endRunnable = () -> removeTransientView(changingView); } float targetLocation = 0; 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) { 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, final boolean isRubberbanded) { final float startOverScrollAmount = mHostLayout.getCurrentOverScrollAmount(onTop);