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

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

Fixed layer trashing when opening / closing the shade

Bug: 21445574
Change-Id: I67ed5f28581a366a4fa7fdc6355371c1fdd0dac3
parent 04fb2587
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ public class NotificationPanelView extends PanelView implements
    private boolean mCollapsedOnDown;
    private int mPositionMinSideMargin;
    private int mLastOrientation = -1;
    private boolean mClosingWithAlphaFadeOut;

    private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() {
        @Override
@@ -527,6 +528,7 @@ public class NotificationPanelView extends PanelView implements
    protected void flingToHeight(float vel, boolean expand, float target,
            float collapseSpeedUpFactor, boolean expandBecauseOfFalsing) {
        mHeadsUpTouchHelper.notifyFling(!expand);
        setClosingWithAlphaFadeout(!expand && getFadeoutAlpha() == 1.0f);
        super.flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing);
    }

@@ -1584,24 +1586,20 @@ public class NotificationPanelView extends PanelView implements
        }
    }
    private void updateNotificationTranslucency() {
        float alpha;
        if (mExpandingFromHeadsUp || mHeadsUpManager.hasPinnedHeadsUp()) {
            alpha = 1f;
        } else {
            alpha = (getNotificationsTopY() + mNotificationStackScroller.getItemHeight())
        float alpha = 1f;
        if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp && !mHeadsUpManager.hasPinnedHeadsUp()) {
            alpha = getFadeoutAlpha();
        }
        mNotificationStackScroller.setAlpha(alpha);
    }

    private float getFadeoutAlpha() {
        float alpha = (getNotificationsTopY() + mNotificationStackScroller.getItemHeight())
                / (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize()
                - mNotificationStackScroller.getCollapseSecondCardPadding());
        alpha = Math.max(0, Math.min(alpha, 1));
        alpha = (float) Math.pow(alpha, 0.75);
        }

        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);
        return alpha;
    }

    @Override
@@ -2260,6 +2258,12 @@ public class NotificationPanelView extends PanelView implements
    protected void onClosingFinished() {
        super.onClosingFinished();
        resetVerticalPanelPosition();
        setClosingWithAlphaFadeout(false);
    }

    private void setClosingWithAlphaFadeout(boolean closing) {
        mClosingWithAlphaFadeOut = closing;
        mNotificationStackScroller.forceNoOverlappingRendering(closing);
    }

    /**
+10 −0
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    private HeadsUpManager mHeadsUpManager;
    private boolean mTrackingHeadsUp;
    private ScrimController mScrimController;
    private boolean mForceNoOverlappingRendering;

    public NotificationStackScrollLayout(Context context) {
        this(context, null);
@@ -2732,6 +2733,15 @@ public class NotificationStackScrollLayout extends ViewGroup
        mScrimController = scrimController;
    }

    public void forceNoOverlappingRendering(boolean force) {
        mForceNoOverlappingRendering = force;
    }

    @Override
    public boolean hasOverlappingRendering() {
        return !mForceNoOverlappingRendering && super.hasOverlappingRendering();
    }

    /**
     * A listener that is notified when some child locations might have changed.
     */