From 27d55cc098f4664d84c7646e0696010e5534e1c8 Mon Sep 17 00:00:00 2001 From: Johannes Gallmann Date: Tue, 14 Mar 2023 14:52:53 +0100 Subject: [PATCH] Add child sensitivity change listener to NotificationStackScrollLayout With this change, the animation has still issues when the notification resize causes the shelf to appear and/or notifications to disappear. This is addressed in subsequent CL's. Bug: 243634602 Flag: SENSITIVE_REVEAL_ANIM Test: Manual, i.e. checking sensitive reveal animation when face unlocking. Change-Id: I9f563a973e72c2789ee1cb3a4f26e361be9df411 --- .../collection/NotificationEntry.java | 11 ++++++---- .../stack/NotificationStackScrollLayout.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index bc531da0ec402..3399f9df7fd56 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -71,6 +71,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowController; import com.android.systemui.statusbar.notification.row.NotificationGuts; import com.android.systemui.statusbar.notification.stack.PriorityBucket; +import com.android.systemui.util.ListenerSet; import java.util.ArrayList; import java.util.List; @@ -163,7 +164,8 @@ public final class NotificationEntry extends ListEntry { private boolean hasSentReply; private boolean mSensitive = true; - private List mOnSensitivityChangedListeners = new ArrayList<>(); + private ListenerSet mOnSensitivityChangedListeners = + new ListenerSet<>(); private boolean mAutoHeadsUp; private boolean mPulseSupressed; @@ -932,8 +934,9 @@ public final class NotificationEntry extends ListEntry { getRow().setSensitive(sensitive, deviceSensitive); if (sensitive != mSensitive) { mSensitive = sensitive; - for (int i = 0; i < mOnSensitivityChangedListeners.size(); i++) { - mOnSensitivityChangedListeners.get(i).onSensitivityChanged(this); + for (NotificationEntry.OnSensitivityChangedListener listener : + mOnSensitivityChangedListeners) { + listener.onSensitivityChanged(this); } } } @@ -944,7 +947,7 @@ public final class NotificationEntry extends ListEntry { /** Add a listener to be notified when the entry's sensitivity changes. */ public void addOnSensitivityChangedListener(OnSensitivityChangedListener listener) { - mOnSensitivityChangedListeners.add(listener); + mOnSensitivityChangedListeners.addIfAbsent(listener); } /** Remove a listener that was registered above. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index c0aed7a9f983c..a2de3c38d0909 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -200,6 +200,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private final boolean mDebugRemoveAnimation; private final boolean mSimplifiedAppearFraction; private final boolean mUseRoundnessSourceTypes; + private final boolean mSensitiveRevealAnimEndabled; private boolean mAnimatedInsets; private int mContentHeight; @@ -580,6 +581,18 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } }; + private final NotificationEntry.OnSensitivityChangedListener + mOnChildSensitivityChangedListener = + new NotificationEntry.OnSensitivityChangedListener() { + @Override + public void onSensitivityChanged(NotificationEntry entry) { + if (mAnimationsEnabled) { + mHideSensitiveNeedsAnimation = true; + requestChildrenUpdate(); + } + } + }; + private Consumer mScrollListener; private final ScrollAdapter mScrollAdapter = new ScrollAdapter() { @Override @@ -611,6 +624,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mDebugRemoveAnimation = featureFlags.isEnabled(Flags.NSSL_DEBUG_REMOVE_ANIMATION); mSimplifiedAppearFraction = featureFlags.isEnabled(Flags.SIMPLIFIED_APPEAR_FRACTION); mUseRoundnessSourceTypes = featureFlags.isEnabled(Flags.USE_ROUNDNESS_SOURCETYPES); + mSensitiveRevealAnimEndabled = featureFlags.isEnabled(Flags.SENSITIVE_REVEAL_ANIM); setAnimatedInsetsEnabled(featureFlags.isEnabled(Flags.ANIMATED_NOTIFICATION_SHADE_INSETS)); mSectionsManager = Dependency.get(NotificationSectionsManager.class); mScreenOffAnimationController = @@ -2860,6 +2874,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable return; } child.setOnHeightChangedListener(null); + if (child instanceof ExpandableNotificationRow && mSensitiveRevealAnimEndabled) { + NotificationEntry entry = ((ExpandableNotificationRow) child).getEntry(); + entry.removeOnSensitivityChangedListener(mOnChildSensitivityChangedListener); + } updateScrollStateForRemovedChild(child); boolean animationGenerated = container != null && generateRemoveAnimation(child); if (animationGenerated) { @@ -3121,6 +3139,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private void onViewAddedInternal(ExpandableView child) { updateHideSensitiveForChild(child); child.setOnHeightChangedListener(mOnChildHeightChangedListener); + if (child instanceof ExpandableNotificationRow && mSensitiveRevealAnimEndabled) { + NotificationEntry entry = ((ExpandableNotificationRow) child).getEntry(); + entry.addOnSensitivityChangedListener(mOnChildSensitivityChangedListener); + } generateAddAnimation(child, false /* fromMoreCard */); updateAnimationState(child); updateChronometerForChild(child);