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

Commit 31094df5 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed several bugs with the notification shade

Cleaned up the code around mMaxPanelHeight of the
PanelView which could lead to flickering during
peeking.
Changed the panel opening logic to account for lag
when we need to wait for a layout, which could lead
to inconsistent animations.
Fixed a bug where holes could appear in the shade
when notifications were updating.
This also improved the general updating behaviour
which is now done in a nicer animation.

Bug: 15942322
Bug: 15861506
Bug: 15168335
Change-Id: Ifd7ce51bea6b5e39c9b76fd0d766a7d2c42bf7a4
parent e8deca1a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -662,7 +662,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }

    public void reset() {
        super.reset();
        setTintColor(0);
        setShowingLegacyBackground(false);
        setBelowSpeedBump(false);
+3 −0
Original line number Diff line number Diff line
@@ -1737,6 +1737,9 @@ public abstract class BaseStatusBar extends SystemUI implements
                : null;

        // Reapply the RemoteViews
        if (entry.row != null) {
            entry.row.resetHeight();
        }
        contentView.reapply(mContext, entry.expanded, mOnClickHandler);
        if (bigContentView != null && entry.getBigContentView() != null) {
            bigContentView.reapply(mContext, entry.getBigContentView(),
+22 −12
Original line number Diff line number Diff line
@@ -88,9 +88,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mExpansionDisabled = false;
        mPublicLayout.reset();
        mPrivateLayout.reset();
        resetHeight();
        logExpansionEvent(false, wasExpanded);
    }

    public void resetHeight() {
        mMaxExpandHeight = 0;
        mWasReset = true;
        logExpansionEvent(false, wasExpanded);
        onHeightReset();
    }

    @Override
@@ -178,21 +183,27 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     * @param expand whether the system wants this notification to be expanded.
     */
    public void setSystemExpanded(boolean expand) {
        if (expand != mIsSystemExpanded) {
            final boolean wasExpanded = isExpanded();
            mIsSystemExpanded = expand;
            notifyHeightChanged();
            logExpansionEvent(false, wasExpanded);
        }
    }

    /**
     * @param expansionDisabled whether to prevent notification expansion
     */
    public void setExpansionDisabled(boolean expansionDisabled) {
        if (expansionDisabled != mExpansionDisabled) {
            final boolean wasExpanded = isExpanded();
            mExpansionDisabled = expansionDisabled;
            logExpansionEvent(false, wasExpanded);
            if (wasExpanded != isExpanded()) {
                notifyHeightChanged();
            }
        }
    }

    /**
     * @return Can the underlying notification be cleared?
@@ -368,9 +379,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mPrivateLayout.notifyContentUpdated();
    }

    public boolean isShowingLayoutLayouted() {
        NotificationContentView showingLayout = getShowingLayout();
        return showingLayout.getWidth() != 0;
    public boolean isMaxExpandHeightInitialized() {
        return mMaxExpandHeight != 0;
    }

    private NotificationContentView getShowingLayout() {
+1 −1
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ public abstract class ExpandableView extends FrameLayout {
    public void setBelowSpeedBump(boolean below) {
    }

    public void reset() {
    public void onHeightReset() {
        if (mOnHeightChangedListener != null) {
            mOnHeightChangedListener.onReset(this);
        }
+31 −30
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ public abstract class PanelView extends FrameLayout {
    private float mInitialOffsetOnTouch;
    private float mExpandedFraction = 0;
    protected float mExpandedHeight = 0;
    private boolean mPanelClosedOnDown;
    private boolean mHasLayoutedSinceDown;
    private float mUpdateFlingVelocity;
    private boolean mUpdateFlingOnLayout;
    private boolean mTouching;
    private boolean mJustPeeked;
    private boolean mClosing;
    protected boolean mTracking;
@@ -76,7 +81,6 @@ public abstract class PanelView extends FrameLayout {

    PanelBar mBar;

    protected int mMaxPanelHeight = -1;
    private String mViewName;
    private float mInitialTouchY;
    private float mInitialTouchX;
@@ -226,6 +230,10 @@ public abstract class PanelView extends FrameLayout {
                mInitialOffsetOnTouch = mExpandedHeight;
                mTouchSlopExceeded = false;
                mJustPeeked = false;
                mPanelClosedOnDown = mExpandedHeight == 0.0f;
                mHasLayoutedSinceDown = false;
                mUpdateFlingOnLayout = false;
                mTouching = true;
                if (mVelocityTracker == null) {
                    initVelocityTracker();
                }
@@ -316,6 +324,10 @@ public abstract class PanelView extends FrameLayout {
                    boolean expand = flingExpands(vel, vectorVel);
                    onTrackingStopped(expand);
                    fling(vel, expand);
                    mUpdateFlingOnLayout = expand && mPanelClosedOnDown && !mHasLayoutedSinceDown;
                    if (mUpdateFlingOnLayout) {
                        mUpdateFlingVelocity = vel;
                    }
                } else {
                    boolean expands = onEmptySpaceClick(mInitialTouchX);
                    onTrackingStopped(expands);
@@ -325,6 +337,7 @@ public abstract class PanelView extends FrameLayout {
                    mVelocityTracker.recycle();
                    mVelocityTracker = null;
                }
                mTouching = false;
                break;
        }
        return !waitForTouchSlop || mTracking;
@@ -383,6 +396,10 @@ public abstract class PanelView extends FrameLayout {
                mInitialTouchX = x;
                mTouchSlopExceeded = false;
                mJustPeeked = false;
                mPanelClosedOnDown = mExpandedHeight == 0.0f;
                mHasLayoutedSinceDown = false;
                mUpdateFlingOnLayout = false;
                mTouching = true;
                initVelocityTracker();
                trackMovement(event);
                break;
@@ -415,6 +432,10 @@ public abstract class PanelView extends FrameLayout {
                    }
                }
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                mTouching = false;
                break;
        }
        return false;
    }
@@ -444,7 +465,6 @@ public abstract class PanelView extends FrameLayout {
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        loadDimens();
        mMaxPanelHeight = -1;
    }

    /**
@@ -524,27 +544,6 @@ public abstract class PanelView extends FrameLayout {
        return mViewName;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        if (DEBUG) logf("onMeasure(%d, %d) -> (%d, %d)",
                widthMeasureSpec, heightMeasureSpec, getMeasuredWidth(), getMeasuredHeight());

        // Did one of our children change size?
        int newHeight = getMeasuredHeight();
        if (newHeight > mMaxPanelHeight) {
            // we only adapt the max height if it's bigger
            mMaxPanelHeight = newHeight;
            // If the user isn't actively poking us, let's rubberband to the content
            if (!mTracking && mHeightAnimator == null
                    && mExpandedHeight > 0 && mExpandedHeight != mMaxPanelHeight
                    && mMaxPanelHeight > 0 && mPeekAnimator == null) {
                mExpandedHeight = mMaxPanelHeight;
            }
        }
    }

    public void setExpandedHeight(float height) {
        if (DEBUG) logf("setExpandedHeight(%.1f)", height);
        setExpandedHeightInternal(height + getOverExpansionPixels());
@@ -552,10 +551,14 @@ public abstract class PanelView extends FrameLayout {

    @Override
    protected void onLayout (boolean changed, int left, int top, int right, int bottom) {
        if (DEBUG) logf("onLayout: changed=%s, bottom=%d eh=%d fh=%d", changed?"T":"f", bottom,
                (int)mExpandedHeight, mMaxPanelHeight);
        super.onLayout(changed, left, top, right, bottom);
        requestPanelHeightUpdate();
        mHasLayoutedSinceDown = true;
        if (mUpdateFlingOnLayout) {
            abortAnimations();
            fling(mUpdateFlingVelocity, true);
            mUpdateFlingOnLayout = false;
        }
    }

    protected void requestPanelHeightUpdate() {
@@ -567,7 +570,8 @@ public abstract class PanelView extends FrameLayout {
                && mExpandedHeight > 0
                && currentMaxPanelHeight != mExpandedHeight
                && !mPeekPending
                && mPeekAnimator == null) {
                && mPeekAnimator == null
                && !mTouching) {
            setExpandedHeight(currentMaxPanelHeight);
        }
    }
@@ -615,10 +619,7 @@ public abstract class PanelView extends FrameLayout {
     *
     * @return the default implementation simply returns the maximum height.
     */
    protected int getMaxPanelHeight() {
        mMaxPanelHeight = Math.max(mMaxPanelHeight, getHeight());
        return mMaxPanelHeight;
    }
    protected abstract int getMaxPanelHeight();

    public void setExpandedFraction(float frac) {
        setExpandedHeight(getMaxPanelHeight() * frac);
Loading