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

Commit 7d062c45 authored by Adrian Roos's avatar Adrian Roos
Browse files

AOD: Only show actually pulsing entries

Fixes an issue where swiping away a notification on AOD2 would
expose the next notification.

Bug: 34716110
Test: receive notification while phone is off, swipe away notification, verify that the next notification does not become visible
Change-Id: I2f8cab37912e6b1edcc129c994a7138c80da7af9
parent d83e9999
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -5014,23 +5014,25 @@ public class StatusBar extends SystemUI implements DemoMode,
                @Override
                public void onPulseStarted() {
                    callback.onPulseStarted();
                    if (!mHeadsUpManager.getAllEntries().isEmpty()) {
                    Collection<HeadsUpManager.HeadsUpEntry> pulsingEntries =
                            mHeadsUpManager.getAllEntries();
                    if (!pulsingEntries.isEmpty()) {
                        // Only pulse the stack scroller if there's actually something to show.
                        // Otherwise just show the always-on screen.
                        setPulsing(true);
                        setPulsing(pulsingEntries);
                    }
                }

                @Override
                public void onPulseFinished() {
                    callback.onPulseFinished();
                    setPulsing(false);
                    setPulsing(null);
                }

                private void setPulsing(boolean pulsing) {
                private void setPulsing(Collection<HeadsUpManager.HeadsUpEntry> pulsing) {
                    mStackScroller.setPulsing(pulsing);
                    mNotificationPanel.setPulsing(pulsing);
                    mVisualStabilityManager.setPulsing(pulsing);
                    mNotificationPanel.setPulsing(pulsing != null);
                    mVisualStabilityManager.setPulsing(pulsing != null);
                }
            }, reason);
        }
+28 −9
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import com.android.systemui.statusbar.DismissView;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationGuts;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.StackScrollerDecorView;
@@ -86,6 +87,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.ScrollAdapter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -331,7 +333,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        }
    };
    private PorterDuffXfermode mSrcMode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
    private boolean mPulsing;
    private Collection<HeadsUpManager.HeadsUpEntry> mPulsing;
    private boolean mDrawBackgroundAsSrc;
    private boolean mFadingOut;
    private boolean mParentNotFullyVisible;
@@ -1917,15 +1919,19 @@ public class NotificationStackScrollLayout extends ViewGroup
        int numShownItems = 0;
        boolean finish = false;
        int maxDisplayedNotifications = mAmbientState.isDark()
                ? (mPulsing ? 1 : 0)
                ? (isPulsing() ? 1 : 0)
                : mMaxDisplayedNotifications;

        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView expandableView = (ExpandableView) getChildAt(i);
            if (expandableView.getVisibility() != View.GONE
                    && !expandableView.hasNoContentHeight()) {
                if (maxDisplayedNotifications != -1
                        && numShownItems >= maxDisplayedNotifications) {
                boolean limitReached = maxDisplayedNotifications != -1
                        && numShownItems >= maxDisplayedNotifications;
                boolean notificationOnAmbientThatIsNotPulsing = isPulsing()
                        && expandableView instanceof ExpandableNotificationRow
                        && !isPulsing(((ExpandableNotificationRow) expandableView).getEntry());
                if (limitReached || notificationOnAmbientThatIsNotPulsing) {
                    expandableView = mShelf;
                    finish = true;
                }
@@ -1971,6 +1977,19 @@ public class NotificationStackScrollLayout extends ViewGroup
        mAmbientState.setLayoutMaxHeight(mContentHeight);
    }

    private boolean isPulsing(NotificationData.Entry entry) {
        for (HeadsUpManager.HeadsUpEntry e : mPulsing) {
            if (e.entry == entry) {
                return true;
            }
        }
        return false;
    }

    private boolean isPulsing() {
        return mPulsing != null;
    }

    private void updateScrollability() {
        boolean scrollable = getScrollRange() > 0;
        if (scrollable != mScrollable) {
@@ -2784,7 +2803,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    private void updateNotificationAnimationStates() {
        boolean running = mAnimationsEnabled || mPulsing;
        boolean running = mAnimationsEnabled || isPulsing();
        mShelf.setAnimationsEnabled(running);
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
@@ -2795,7 +2814,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    private void updateAnimationState(View child) {
        updateAnimationState((mAnimationsEnabled || mPulsing)
        updateAnimationState((mAnimationsEnabled || isPulsing())
                && (mIsExpanded || isPinnedHeadsUp(child)), child);
    }

@@ -4055,12 +4074,12 @@ public class NotificationStackScrollLayout extends ViewGroup
        return mIsExpanded;
    }

    public void setPulsing(boolean pulsing) {
        if (mPulsing == pulsing) {
    public void setPulsing(Collection<HeadsUpManager.HeadsUpEntry> pulsing) {
        if (mPulsing == null && pulsing == null) {
            return;
        }
        mPulsing = pulsing;
        mAmbientState.setPulsing(pulsing);
        mAmbientState.setPulsing(isPulsing());
        updateNotificationAnimationStates();
        updateContentHeight();
        notifyHeightChangeListener(mShelf);