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

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

Fixed the transformation into the shelf

The transformation was based on the intrinsic height but that doesn't
work since it can suddenly jump, i.e when swiping away the top notification.

Test: Add tall notifications, swipe top one away, observe no jumping.
Bug: 32437839
Change-Id: I68f83e167f73ca6c87a5838000b11029214e4ca3
parent 9458b19f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -673,6 +673,13 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBackgroundDimmed.setClipTopAmount(clipTopAmount);
    }

    @Override
    public void setClipBottomAmount(int clipBottomAmount) {
        super.setClipBottomAmount(clipBottomAmount);
        mBackgroundNormal.setClipBottomAmount(clipBottomAmount);
        mBackgroundDimmed.setClipBottomAmount(clipBottomAmount);
    }

    @Override
    public void performRemoveAnimation(long duration, float translationDirection,
            Runnable onFinishedRunnable) {
+10 −0
Original line number Diff line number Diff line
@@ -1607,6 +1607,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    @Override
    public void setClipBottomAmount(int clipBottomAmount) {
        super.setClipBottomAmount(clipBottomAmount);
        mPrivateLayout.setClipBottomAmount(clipBottomAmount);
        mPublicLayout.setClipBottomAmount(clipBottomAmount);
        if (mGuts != null) {
            mGuts.setClipBottomAmount(clipBottomAmount);
        }
    }

    public boolean isMaxExpandHeightInitialized() {
        return mMaxExpandHeight != 0;
    }
+19 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public abstract class ExpandableView extends FrameLayout {
    protected OnHeightChangedListener mOnHeightChangedListener;
    private int mActualHeight;
    protected int mClipTopAmount;
    private float mClipBottomAmount;
    private boolean mDark;
    private ArrayList<View> mMatchParentViews = new ArrayList<View>();
    private static Rect mClipRect = new Rect();
@@ -222,10 +223,26 @@ public abstract class ExpandableView extends FrameLayout {
        updateClipping();
    }

    /**
     * Set the amount the the notification is clipped on the bottom in addition to the regular
     * clipping. This is mainly used to clip something in a non-animated way without changing the
     * actual height of the notification and is purely visual.
     *
     * @param clipBottomAmount the amount to clip.
     */
    public void setClipBottomAmount(int clipBottomAmount) {
        mClipBottomAmount = clipBottomAmount;
        updateClipping();
    }

    public int getClipTopAmount() {
        return mClipTopAmount;
    }

    public float getClipBottomAmount() {
        return mClipBottomAmount;
    }

    public void setOnHeightChangedListener(OnHeightChangedListener listener) {
        mOnHeightChangedListener = listener;
    }
@@ -333,7 +350,8 @@ public abstract class ExpandableView extends FrameLayout {
            if (top >= getActualHeight()) {
                top = getActualHeight() - 1;
            }
            mClipRect.set(0, top, getWidth(), getActualHeight() + getExtraBottomPadding());
            mClipRect.set(0, top, getWidth(), (int) (getActualHeight() + getExtraBottomPadding()
                                - mClipBottomAmount));
            setClipBounds(mClipRect);
        } else {
            setClipBounds(null);
+9 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public class NotificationBackgroundView extends View {
    private Drawable mBackground;
    private int mClipTopAmount;
    private int mActualHeight;
    private int mClipBottomAmount;

    public NotificationBackgroundView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -44,8 +45,9 @@ public class NotificationBackgroundView extends View {
    }

    private void draw(Canvas canvas, Drawable drawable) {
        if (drawable != null && mActualHeight > mClipTopAmount) {
            drawable.setBounds(0, mClipTopAmount, getWidth(), mActualHeight);
        int bottom = mActualHeight - mClipBottomAmount;
        if (drawable != null && bottom > mClipTopAmount) {
            drawable.setBounds(0, mClipTopAmount, getWidth(), bottom);
            drawable.draw(canvas);
        }
    }
@@ -120,6 +122,11 @@ public class NotificationBackgroundView extends View {
        invalidate();
    }

    public void setClipBottomAmount(int clipBottomAmount) {
        mClipBottomAmount = clipBottomAmount;
        invalidate();
    }

    @Override
    public boolean hasOverlappingRendering() {

+11 −1
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ public class NotificationContentView extends FrameLayout {
    private boolean mFocusOnVisibilityChange;
    private boolean mHeadsupDisappearRunning;
    private boolean mIconsVisible;
    private int mClipBottomAmount;


    public NotificationContentView(Context context, AttributeSet attrs) {
@@ -588,9 +589,18 @@ public class NotificationContentView extends FrameLayout {
        updateClipping();
    }


    public void setClipBottomAmount(int clipBottomAmount) {
        mClipBottomAmount = clipBottomAmount;
        updateClipping();
    }

    private void updateClipping() {
        if (mClipToActualHeight) {
            mClipBounds.set(0, mClipTopAmount, getWidth(), mContentHeight);
            int top = mClipTopAmount;
            int bottom = mContentHeight - mClipBottomAmount;
            bottom = Math.max(top, bottom);
            mClipBounds.set(0, top, getWidth(), bottom);
            setClipBounds(mClipBounds);
        } else {
            setClipBounds(null);
Loading