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

Commit 5ad92c52 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Optimize alpha handling for stack scroller

Use a layer when an alpha is set. Currently, this breaks shadows
when alpha != 1f, however, b/15860114 will fix this.

Change-Id: I094d5896a5433ba9a0ecc17549ef2944f6b7881e
parent 3f2757a3
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -937,12 +937,16 @@ public class NotificationPanelView extends PanelView implements
    }
    private void updateNotificationTranslucency() {
        float alpha = (getNotificationsTopY() + mNotificationStackScroller.getItemHeight())
                / (mQsMinExpansionHeight + mNotificationStackScroller.getItemHeight() / 2);
                / (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize()
                        + mNotificationStackScroller.getCollapseSecondCardPadding());
        alpha = Math.max(0, Math.min(alpha, 1));
        alpha = (float) Math.pow(alpha, 0.75);

        // TODO: Draw a rect with DST_OUT over the notifications to achieve the same effect -
        // this would be much more efficient.
        if (alpha != 1f && mNotificationStackScroller.getLayerType() != LAYER_TYPE_HARDWARE) {
            mNotificationStackScroller.setLayerType(LAYER_TYPE_HARDWARE, null);
        } else if (alpha == 1f
                && mNotificationStackScroller.getLayerType() == LAYER_TYPE_HARDWARE) {
            mNotificationStackScroller.setLayerType(LAYER_TYPE_NONE, null);
        }
        mNotificationStackScroller.setAlpha(alpha);
    }

+8 −2
Original line number Diff line number Diff line
@@ -470,6 +470,10 @@ public class NotificationStackScrollLayout extends ViewGroup
        return mBottomStackPeekSize;
    }

    public int getCollapseSecondCardPadding() {
        return mCollapseSecondCardPadding;
    }

    public void setLongPressListener(SwipeHelper.LongPressListener listener) {
        mSwipeHelper.setLongPressListener(listener);
        mLongPressListener = listener;
@@ -1955,9 +1959,11 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public void setScrimAlpha(float progress) {
        if (progress != mAmbientState.getScrimAmount()) {
            mAmbientState.setScrimAmount(progress);
            requestChildrenUpdate();
        }
    }

    /**
     * See {@link AmbientState#setDark}.