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

Commit ad7fac06 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed the appearance of the shelf on the lockscreen

Previously the shelf algorithm wasn't applied properly
on the lockscreen.

Test: Add notifications, observe shelf on the lockscreen when collapsing
Bug: 32437839
Change-Id: I7c768e1450a86b5a8731c998ef58212550dfb4bc
parent 281c2027
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2196,10 +2196,11 @@ public abstract class BaseStatusBar extends SystemUI implements

        int visibleNotifications = 0;
        boolean onKeyguard = mState == StatusBarState.KEYGUARD;
        int maxNotifications = 0;
        int maxNotifications = -1;
        if (onKeyguard) {
            maxNotifications = getMaxKeyguardNotifications(true /* recompute */);
        }
        mStackScroller.setMaxDisplayedNotifications(maxNotifications);
        for (int i = 0; i < N; i++) {
            NotificationData.Entry entry = activeNotifications.get(i);
            boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
@@ -2218,8 +2219,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
            if (suppressedSummary
                    || (isLockscreenPublicMode(userId) && !mShowLockscreenNotifications)
                    || (onKeyguard && !childWithVisibleSummary
                            && (visibleNotifications >= maxNotifications || !showOnKeyguard))) {
                    || (onKeyguard && !showOnKeyguard)) {
                entry.row.setVisibility(View.GONE);
            } else {
                boolean wasGone = entry.row.getVisibility() == View.GONE;
+12 −4
Original line number Diff line number Diff line
@@ -97,13 +97,21 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        if (mCustomOutline) {
            return;
        }
        boolean hasOutline = true;
        boolean hasOutline = needsOutline();
        setOutlineProvider(hasOutline ? mProvider : null);
    }

    /**
     * @return whether the view currently needs an outline. This is usually false in case it doesn't
     * have a background.
     */
    protected boolean needsOutline() {
        if (isChildInGroup()) {
            hasOutline = isGroupExpanded() && !isGroupExpansionChanging();
            return isGroupExpanded() && !isGroupExpansionChanging();
        } else if (isSummaryWithChildren()) {
            hasOutline = !isGroupExpanded() || isGroupExpansionChanging();
            return !isGroupExpanded() || isGroupExpansionChanging();
        }
        setOutlineProvider(hasOutline ? mProvider : null);
        return true;
    }

    public boolean isOutlineShowing() {
+9 −6
Original line number Diff line number Diff line
@@ -112,10 +112,7 @@ public class NotificationShelf extends ActivatableNotificationView {
    public void updateState(StackScrollState resultState,
            StackScrollAlgorithm.StackScrollAlgorithmState algorithmState,
            AmbientState ambientState) {
        int shelfIndex = ambientState.getShelfIndex();
        shelfIndex = shelfIndex == -1
                ? algorithmState.visibleChildren.size() - 1
                : shelfIndex - 1;
        int shelfIndex = ambientState.getShelfIndex() - 1;
        if (shelfIndex != -1) {
            float maxShelfEnd = ambientState.getInnerHeight() + ambientState.getTopPadding()
                    + ambientState.getStackTranslation();
@@ -134,7 +131,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            mShelfState.isBottomClipped = false;
            mShelfState.hideSensitive = false;

            mShelfState.resetState();
            mShelfState.resetIcons();
            float numIconsInShelf = 0.0f;
            float viewStart;
            float maxShelfStart = maxShelfEnd - mShelfState.height;
@@ -240,6 +237,12 @@ public class NotificationShelf extends ActivatableNotificationView {
    private void setHideBackground(boolean hideBackground) {
        mHideBackground = hideBackground;
        updateBackground();
        updateOutline();
    }

    @Override
    protected boolean needsOutline() {
        return !mHideBackground && super.needsOutline();
    }

    @Override
@@ -258,7 +261,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            setHideBackground(hideBackground);
        }

        public void resetState() {
        public void resetIcons() {
            mNotificationIconContainer.resetViewStates(iconStates);
        }
    }
+3 −0
Original line number Diff line number Diff line
@@ -2005,6 +2005,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            }
            currentIndex++;
        }
        if (shelfIndex == -1) {
            shelfIndex = currentIndex;
        }
        mStackScroller.updateShelfIndex(shelfIndex);
    }

+23 −10
Original line number Diff line number Diff line
@@ -354,6 +354,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    private boolean mForwardScrollable;
    private boolean mBackwardScrollable;
    private NotificationShelf mShelf;
    private int mMaxDisplayedNotifications = -1;

    public NotificationStackScrollLayout(Context context) {
        this(context, null);
@@ -533,8 +534,7 @@ public class NotificationStackScrollLayout extends ViewGroup

    public void updateShelfIndex(int newIndex) {
        mAmbientState.setShelfIndex(newIndex);
        int iconIndex = newIndex == -1 ? getChildCount() - 3 : newIndex;
        changeViewPosition(mShelf, iconIndex);
        changeViewPosition(mShelf, newIndex);
    }

    public void setChildLocationsChangedListener(OnChildLocationsChangedListener listener) {
@@ -1847,10 +1847,17 @@ public class NotificationStackScrollLayout extends ViewGroup
    private void updateContentHeight() {
        int height = 0;
        float previousIncreasedAmount = 0.0f;
        int numShownItems = 0;
        boolean finish = false;
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView expandableView = (ExpandableView) getChildAt(i);
            if (expandableView.getVisibility() != View.GONE
                    && !expandableView.hasNoContentHeight()) {
                if (mMaxDisplayedNotifications != -1
                        && numShownItems >= mMaxDisplayedNotifications) {
                    expandableView = mShelf;
                    finish = true;
                }
                float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount();
                if (height != 0) {
                    height += (int) NotificationUtils.interpolate(
@@ -1860,6 +1867,10 @@ public class NotificationStackScrollLayout extends ViewGroup
                }
                previousIncreasedAmount = increasedPaddingAmount;
                height += expandableView.getIntrinsicHeight();
                numShownItems++;
                if (finish) {
                    break;
                }
            }
        }
        mContentHeight = height + mTopPadding;
@@ -3083,16 +3094,10 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public int getEmptyBottomMargin() {
        int emptyMargin = mMaxLayoutHeight - mContentHeight - mBottomStackPeekSize
                - mBottomStackSlowDownHeight;
        int emptyMargin = mMaxLayoutHeight - mContentHeight;
        return Math.max(emptyMargin, 0);
    }

    public float getKeyguardBottomStackSize() {
        return mBottomStackPeekSize + getResources().getDimensionPixelSize(
                R.dimen.bottom_stack_slow_down_length);
    }

    public void onExpansionStarted() {
        mIsExpansionChanging = true;
    }
@@ -3756,7 +3761,7 @@ public class NotificationStackScrollLayout extends ViewGroup
                // fall through
            case android.R.id.accessibilityActionScrollUp:
                final int viewportHeight = getHeight() - mPaddingBottom - mTopPadding - mPaddingTop
                        - mBottomStackPeekSize - mBottomStackSlowDownHeight;
                        - mShelf.getIntrinsicHeight();
                final int targetScrollY = Math.max(0,
                        Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange()));
                if (targetScrollY != mOwnScrollY) {
@@ -3925,6 +3930,14 @@ public class NotificationStackScrollLayout extends ViewGroup
        return mShelf;
    }

    public void setMaxDisplayedNotifications(int maxDisplayedNotifications) {
        if (mMaxDisplayedNotifications != maxDisplayedNotifications) {
            mMaxDisplayedNotifications = maxDisplayedNotifications;
            updateContentHeight();
            notifyHeightChangeListener(mShelf);
        }
    }

    /**
     * A listener that is notified when some child locations might have changed.
     */
Loading