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

Commit 000e79b0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I92ef4715,Iebf64931 into rvc-dev am: 92f04af9

Change-Id: Ic1fbd357aa78a9446515866275467f06fac3ef8b
parents bd6c9640 92f04af9
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -2452,7 +2452,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        int numShownItems = 0;
        boolean finish = false;
        int maxDisplayedNotifications = mMaxDisplayedNotifications;

        ExpandableView previousView = null;
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView expandableView = (ExpandableView) getChildAt(i);
            boolean footerViewOnLockScreen = expandableView == mFooterView && onKeyguard();
@@ -2460,9 +2460,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                    && !expandableView.hasNoContentHeight() && !footerViewOnLockScreen) {
                boolean limitReached = maxDisplayedNotifications != -1
                        && numShownItems >= maxDisplayedNotifications;
                final float viewHeight;
                if (limitReached) {
                    expandableView = mShelf;
                    viewHeight = mShelf.getIntrinsicHeight();
                    finish = true;
                } else {
                    viewHeight = expandableView.getIntrinsicHeight();
                }
                float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount();
                float padding;
@@ -2493,9 +2496,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                if (height != 0) {
                    height += padding;
                }
                height += calculateGapHeight(previousView, expandableView, numShownItems);
                previousPaddingAmount = increasedPaddingAmount;
                height += expandableView.getIntrinsicHeight();
                height += viewHeight;
                numShownItems++;
                previousView = expandableView;
                if (finish) {
                    break;
                }
@@ -2511,6 +2516,25 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        mAmbientState.setLayoutMaxHeight(mContentHeight);
    }

    /**
     * Calculate the gap height between two different views
     *
     * @param previous the previousView
     * @param current the currentView
     * @param visibleIndex the visible index in the list
     *
     * @return the gap height needed before the current view
     */
    public float calculateGapHeight(
            ExpandableView previous,
            ExpandableView current,
            int visibleIndex
    ) {
       return mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager,
                mAmbientState.getAnchorViewIndex(), visibleIndex, current,
                previous);
    }

    @Override
    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public boolean hasPulsingNotifications() {
+39 −3
Original line number Diff line number Diff line
@@ -402,7 +402,8 @@ public class StackScrollAlgorithm {
        ExpandableView previousChild = i > 0 ? algorithmState.visibleChildren.get(i - 1) : null;
        final boolean applyGapHeight =
                childNeedsGapHeight(
                        ambientState.getSectionProvider(), algorithmState, i, child, previousChild);
                        ambientState.getSectionProvider(), algorithmState.anchorViewIndex, i,
                        child, previousChild);
        ExpandableViewState childViewState = child.getViewState();
        childViewState.location = ExpandableViewState.LOCATION_UNKNOWN;

@@ -463,9 +464,44 @@ public class StackScrollAlgorithm {
        return currentYPosition;
    }

    /**
     * Get the gap height needed for before a view
     *
     * @param sectionProvider the sectionProvider used to understand the sections
     * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not
     * @param visibleIndex the visible index of this view in the list
     * @param child the child asked about
     * @param previousChild the child right before it or null if none
     * @return the size of the gap needed or 0 if none is needed
     */
    public float getGapHeightForChild(
            SectionProvider sectionProvider,
            int anchorViewIndex,
            int visibleIndex,
            View child,
            View previousChild) {

        if (childNeedsGapHeight(sectionProvider, anchorViewIndex, visibleIndex, child,
                previousChild)) {
            return mGapHeight;
        } else {
            return 0;
        }
    }

    /**
     * Does a given child need a gap, i.e spacing before a view?
     *
     * @param sectionProvider the sectionProvider used to understand the sections
     * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not
     * @param visibleIndex the visible index of this view in the list
     * @param child the child asked about
     * @param previousChild the child right before it or null if none
     * @return if the child needs a gap height
     */
    private boolean childNeedsGapHeight(
            SectionProvider sectionProvider,
            StackScrollAlgorithmState algorithmState,
            int anchorViewIndex,
            int visibleIndex,
            View child,
            View previousChild) {
@@ -473,7 +509,7 @@ public class StackScrollAlgorithm {
        boolean needsGapHeight = sectionProvider.beginsSection(child, previousChild)
                && visibleIndex > 0;
        if (ANCHOR_SCROLLING) {
            needsGapHeight &= visibleIndex != algorithmState.anchorViewIndex;
            needsGapHeight &= visibleIndex != anchorViewIndex;
        }
        return needsGapHeight;
    }
+58 −19
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.phone;

import static android.view.View.GONE;

import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;

@@ -102,6 +104,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.MediaHeaderView;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
@@ -848,34 +851,25 @@ public class NotificationPanelViewController extends PanelViewController {
                        mIndicationBottomPadding, mAmbientIndicationBottomPadding)
                        - mKeyguardStatusView.getLogoutButtonHeight();
        int count = 0;
        ExpandableView previousView = null;
        for (int i = 0; i < mNotificationStackScroller.getChildCount(); i++) {
            ExpandableView child = (ExpandableView) mNotificationStackScroller.getChildAt(i);
            if (!(child instanceof ExpandableNotificationRow)) {
            if (!canShowViewOnLockscreen(child)) {
                continue;
            }
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            boolean
                    suppressedSummary =
                    mGroupManager != null && mGroupManager.isSummaryOfSuppressedGroup(
                            row.getEntry().getSbn());
            if (suppressedSummary) {
                continue;
            }
            if (!mLockscreenUserManager.shouldShowOnKeyguard(row.getEntry())) {
                continue;
            }
            if (row.isRemoved()) {
                continue;
            }
            availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */)
                    + notificationPadding;
            availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */);
            availableSpace -= count == 0 ? 0 : notificationPadding;
            availableSpace -= mNotificationStackScroller.calculateGapHeight(previousView, child,
                    count);
            previousView = child;
            if (availableSpace >= 0 && count < maximum) {
                count++;
            } else if (availableSpace > -shelfSize) {
                // if we are exactly the last view, then we can show us still!
                for (int j = i + 1; j < mNotificationStackScroller.getChildCount(); j++) {
                    if (mNotificationStackScroller.getChildAt(
                            j) instanceof ExpandableNotificationRow) {
                    ExpandableView view = (ExpandableView) mNotificationStackScroller.getChildAt(j);
                    if (view instanceof ExpandableNotificationRow &&
                            canShowViewOnLockscreen(view)) {
                        return count;
                    }
                }
@@ -888,6 +882,51 @@ public class NotificationPanelViewController extends PanelViewController {
        return count;
    }

    /**
     * Can a view be shown on the lockscreen when calculating the number of allowed notifications
     * to show?
     *
     * @param child the view in question
     * @return true if it can be shown
     */
    private boolean canShowViewOnLockscreen(ExpandableView child) {
        if (child.hasNoContentHeight()) {
            return false;
        }
        if (child instanceof ExpandableNotificationRow &&
                !canShowRowOnLockscreen((ExpandableNotificationRow) child)) {
            return false;
        } else if (child.getVisibility() == GONE) {
            // ENRs can be gone and count because their visibility is only set after
            // this calculation, but all other views should be up to date
            return false;
        }
        return true;
    }

    /**
     * Can a row be shown on the lockscreen when calculating the number of allowed notifications
     * to show?
     *
     * @param row the row in question
     * @return true if it can be shown
     */
    private boolean canShowRowOnLockscreen(ExpandableNotificationRow row) {
        boolean suppressedSummary =
                mGroupManager != null && mGroupManager.isSummaryOfSuppressedGroup(
                        row.getEntry().getSbn());
        if (suppressedSummary) {
            return false;
        }
        if (!mLockscreenUserManager.shouldShowOnKeyguard(row.getEntry())) {
            return false;
        }
        if (row.isRemoved()) {
            return false;
        }
        return true;
    }

    private void updateClock() {
        if (!mKeyguardStatusViewAnimating) {
            mKeyguardStatusView.setAlpha(mClockPositionResult.clockAlpha);