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

Commit 27d55cc0 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

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
parent 7e0a03f0
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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<OnSensitivityChangedListener> mOnSensitivityChangedListeners = new ArrayList<>();
    private ListenerSet<OnSensitivityChangedListener> 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. */
+22 −0
Original line number Diff line number Diff line
@@ -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<Integer> 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);