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

Commit e7cfe80a authored by Yuri Lin's avatar Yuri Lin
Browse files

Add isParentGroupExpanded method to ExpandableNotificationRow

There are parts of NotificationContentView that used isGroupExpanded() to determine if a notification is a child in an unexpanded group, in which case it should be displayed as a single line and its (min) height is set accordingly. This is incorrect in the case of nested groups (for instance, a group inside a bundle), where isGroupExpanded() checks the expansion state of the group itself and not its parent.

Bug: 440448363
Test: manual, by turning off "show sensitive content" for notifications on the lock screen and then verifying that the notifications show at the expected height
Flag: EXEMPT bugfix
Change-Id: Id5e7e99b4c9d69ea6a4e4194d415a51ff9f9d72d
parent 25daa65e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -3392,6 +3392,20 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return mGroupExpansionManager.isGroupExpanded(getEntryLegacy());
    }

    /**
     * If this notification is a child of a group, returns whether the parent group is expanded.
     * This is distinct from isGroupExpanded() specifically in the case of nested groups (for
     * example, if a group is contained inside a bundle).
     *
     * Returns false if the notification is not a child of a group.
     */
    public boolean isParentGroupExpanded() {
        if (isChildInGroup()) {
            return getNotificationParent().isGroupExpanded();
        }
        return false;
    }

    @VisibleForTesting
    boolean isGroupRoot() {
        return NotificationBundleUi.isEnabled()
+12 −6
Original line number Diff line number Diff line
@@ -902,7 +902,7 @@ public class NotificationContentView extends FrameLayout implements Notification
    }

    public int getMinHeight(boolean likeGroupExpanded) {
        if (likeGroupExpanded || !mIsChildInGroup || isGroupExpanded()) {
        if (likeGroupExpanded || !mIsChildInGroup || isParentGroupExpanded()) {
            return mContractedChild != null
                    ? getViewHeight(VISIBLE_TYPE_CONTRACTED) : mMinContractedHeight;
        } else {
@@ -928,6 +928,10 @@ public class NotificationContentView extends FrameLayout implements Notification
        return mContainingNotification.isGroupExpanded();
    }

    private boolean isParentGroupExpanded() {
        return mContainingNotification.isParentGroupExpanded();
    }

    public void setClipTopAmount(int clipTopAmount) {
        mClipTopAmount = clipTopAmount;
        updateClipping();
@@ -1264,6 +1268,10 @@ public class NotificationContentView extends FrameLayout implements Notification
        }
    }

    private boolean shouldShowSingleLineView() {
        return mIsChildInGroup && !isParentGroupExpanded();
    }

    /**
     * @return one of the static enum types in this view, calculated from the current state
     */
@@ -1277,14 +1285,13 @@ public class NotificationContentView extends FrameLayout implements Notification
                height = mContentHeight;
            }
            int expandedVisualType = getVisualTypeForHeight(height);
            final boolean shouldShowSingleLineView = mIsChildInGroup && !isGroupExpanded();
            final boolean isSingleLineViewPresent = mSingleLineView != null;

            if (shouldShowSingleLineView && !isSingleLineViewPresent) {
            if (shouldShowSingleLineView() && !isSingleLineViewPresent) {
                Log.wtf(TAG, "calculateVisibleType: SingleLineView is not available!");
            }

            final int collapsedVisualType = shouldShowSingleLineView && isSingleLineViewPresent
            final int collapsedVisualType = shouldShowSingleLineView() && isSingleLineViewPresent
                    ? VISIBLE_TYPE_SINGLELINE
                    : getVisualTypeForHeight(mContainingNotification.getCollapsedHeight());
            return mTransformationStartVisibleType == collapsedVisualType
@@ -1305,10 +1312,9 @@ public class NotificationContentView extends FrameLayout implements Notification
        if (!noExpandedChild && viewHeight == getViewHeight(VISIBLE_TYPE_EXPANDED)) {
            return VISIBLE_TYPE_EXPANDED;
        }
        final boolean shouldShowSingleLineView = mIsChildInGroup && !isGroupExpanded();
        final boolean isSingleLinePresent =  mSingleLineView != null;

        if (!mUserExpanding && shouldShowSingleLineView && isSingleLinePresent) {
        if (!mUserExpanding && shouldShowSingleLineView() && isSingleLinePresent) {
            return VISIBLE_TYPE_SINGLELINE;
        }