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

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

Continuously clip notifications according to their sibblings

Notifications now avoid overlapping each other by clipping its
background and content if they overlap. In particular with
physics based animations as well as the row transparency this
was particularly visible, but it could also happen previously

Fixes: 403531742
Flag: com.android.systemui.physical_notification_movement
Test: atest SystemUITests
Change-Id: I1dfd57fce521635218300de6ed015e92fc84b9fc
parent 86ca9821
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -823,9 +823,15 @@
    <!-- The alpha of the dividing line between child notifications of a notification group. -->
    <item name="notification_divider_alpha" format="float" type="dimen">1</item>


    <!-- The minimum spacing to ensure between notifications in case they overlap -->
    <dimen name="notification_minimum_spacing_between_children">0.5dp</dimen>

    <!-- The height of the divider between the individual notifications in a notification
         group. -->
    <dimen name="notification_children_container_divider_height">0.5dp</dimen>
    <dimen name="notification_children_container_divider_height">
        @dimen/notification_minimum_spacing_between_children
    </dimen>

    <!-- The height of the divider between the individual notifications within a bundle -->
    <dimen name="bundle_children_container_divider_height">2dp</dimen>
+4 −3
Original line number Diff line number Diff line
@@ -370,7 +370,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            right = isLayoutRtl() ? containerWidth : shelfWidth;
        }

        final float top = mClipTopAmount;
        final float top = Math.max(mClipTopAmount, mTopOverlap);
        final float bottom = getActualHeight();

        return isXInView(localX, slop, left, right)
@@ -670,9 +670,10 @@ public class NotificationShelf extends ActivatableNotificationView {

    private void updateIconClipAmount(ExpandableNotificationRow row) {
        float maxTop = row.getTranslationY();
        if (getClipTopAmount() != 0) {
        int clipTopAmount = Math.max(getClipTopAmount(), mTopOverlap);
        if (clipTopAmount != 0) {
            // if the shelf is clipped, lets make sure we also clip the icon
            maxTop = Math.max(maxTop, getTranslationY() + getClipTopAmount());
            maxTop = Math.max(maxTop, getTranslationY() + clipTopAmount);
        }
        StatusBarIconView icon = NotificationBundleUi.isEnabled()
                ? row.getEntryAdapter().getIcons().getShelfIcon()
+3 −1
Original line number Diff line number Diff line
@@ -86,7 +86,9 @@ class NotificationTransitionAnimatorController(

    override fun createAnimatorState(): TransitionAnimator.State {
        // If the notification panel is collapsed, the clip may be larger than the height.
        val height = max(0, notification.actualHeight - notification.clipBottomAmount)
        val clipBottomAmount =
            notification.clipBottomAmount.coerceAtLeast(notification.bottomOverlap)
        val height = max(0, notification.actualHeight - clipBottomAmount)
        val location = notification.locationOnScreen

        val clipStartLocation = notificationListContainer.topClippingStartLocation
+21 −0
Original line number Diff line number Diff line
@@ -371,6 +371,18 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBackgroundNormal.setClipBottomAmount(clipBottomAmount);
    }

    @Override
    public void setBottomOverlap(int bottomOverlap) {
        super.setBottomOverlap(bottomOverlap);
        mBackgroundNormal.setBottomOverlap(bottomOverlap);
    }

    @Override
    public void setTopOverlap(int topOverlap) {
        super.setTopOverlap(topOverlap);
        mBackgroundNormal.setTopOverlap(topOverlap);
    }

    @Override
    public long performRemoveAnimation(long duration, long delay, float translationDirection,
            boolean isHeadsUpAnimation, boolean isHeadsUpCycling, Runnable onStartedRunnable,
@@ -519,6 +531,15 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
                }, delay);
    }

    @Override
    public int getBackgroundBottom() {
        int backgroundBottom = super.getBackgroundBottom();
        if (mDrawingAppearAnimation) {
            backgroundBottom += (int) mAppearAnimationTranslation;
        }
        return backgroundBottom;
    }

    private int getCujType(boolean isAppearing) {
        if (mIsHeadsUpAnimation) {
            return isAppearing
+39 −0
Original line number Diff line number Diff line
@@ -1932,6 +1932,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    public float getChildRenderingStartPosition() {
        if (!isSummaryWithChildren()) {
            return 0;
        }
        return getChildrenContainerNonNull().getChildRenderingStartPosition();
    }

    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
        boolean wasAboveShelf = isAboveShelf();
        boolean changed = headsUpAnimatingAway != mHeadsupDisappearRunning;
@@ -2516,6 +2523,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mGutsStub.setOnInflateListener((stub, inflated) -> {
            mGuts = (NotificationGuts) inflated;
            mGuts.setClipTopAmount(getClipTopAmount());
            mGuts.setClipBottomAmount(getClipBottomAmount());
            mGuts.setTopOverlap(mTopOverlap);
            mGuts.setBottomOverlap(mBottomOverlap);
            mGuts.setActualHeight(getActualHeight());
            mGutsStub = null;
        });
@@ -4056,6 +4066,35 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    @Override
    public void setTopOverlap(int topOverlap) {
        if (mTopOverlap != topOverlap) {
            super.setTopOverlap(topOverlap);
            for (NotificationContentView l : mLayouts) {
                l.setTopOverlap(topOverlap);
            }
            if (mGuts != null) {
                mGuts.setTopOverlap(topOverlap);
            }
        }
    }

    @Override
    public void setBottomOverlap(int bottomOverlap) {
        if (mExpandAnimationRunning) {
            return;
        }
        if (bottomOverlap != mBottomOverlap) {
            super.setBottomOverlap(bottomOverlap);
            for (NotificationContentView l : mLayouts) {
                l.setBottomOverlap(bottomOverlap);
            }
            if (mGuts != null) {
                mGuts.setBottomOverlap(bottomOverlap);
            }
        }
    }

    @Override
    public void setClipBottomAmount(int clipBottomAmount) {
        if (mExpandAnimationRunning) {
Loading