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 Original line Diff line number Diff line
@@ -2196,10 +2196,11 @@ public abstract class BaseStatusBar extends SystemUI implements


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


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


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

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


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


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


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


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


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


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


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


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

    public void onExpansionStarted() {
    public void onExpansionStarted() {
        mIsExpansionChanging = true;
        mIsExpansionChanging = true;
    }
    }
@@ -3756,7 +3761,7 @@ public class NotificationStackScrollLayout extends ViewGroup
                // fall through
                // fall through
            case android.R.id.accessibilityActionScrollUp:
            case android.R.id.accessibilityActionScrollUp:
                final int viewportHeight = getHeight() - mPaddingBottom - mTopPadding - mPaddingTop
                final int viewportHeight = getHeight() - mPaddingBottom - mTopPadding - mPaddingTop
                        - mBottomStackPeekSize - mBottomStackSlowDownHeight;
                        - mShelf.getIntrinsicHeight();
                final int targetScrollY = Math.max(0,
                final int targetScrollY = Math.max(0,
                        Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange()));
                        Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange()));
                if (targetScrollY != mOwnScrollY) {
                if (targetScrollY != mOwnScrollY) {
@@ -3925,6 +3930,14 @@ public class NotificationStackScrollLayout extends ViewGroup
        return mShelf;
        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.
     * A listener that is notified when some child locations might have changed.
     */
     */
Loading