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

Commit 62ae0c89 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Reset the alpha value of ALL notification content views

* After a hideSensitive change
* After the appear animation
* After an activity launch expand animation

This is intended to solve a bug where the notification would appear as a persistently blank rectangle.  From bugreports, it seems clear that the content view of the notification is having its alpha left at 0 (or something low in at least 1 case).  The best explanation for this bug at the moment is that one of these 3 animations (most likely either the appear animation) has a race condition whereby the content view which is set to 0 or less for the animation is no longer the active content view when the animation continues/ends, resulting in the alpha being left with a value other than 1.  When another change results in this content view showing again, that change assumes the content view has the correct alpha, so the alpha is left incorrect.

Bug: 188770583
Test: manual testing of all 3 animations listed above
Change-Id: I9e9aeb5dd3643bde1dc9f2ffe8b32d7d993b29f2
parent 535795b3
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -579,14 +579,24 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        if (contentView.hasOverlappingRendering()) {
            int layerType = contentAlpha == 0.0f || contentAlpha == 1.0f ? LAYER_TYPE_NONE
                    : LAYER_TYPE_HARDWARE;
            int currentLayerType = contentView.getLayerType();
            if (currentLayerType != layerType) {
            contentView.setLayerType(layerType, null);
        }
        }
        contentView.setAlpha(contentAlpha);
        // After updating the current view, reset all views.
        if (contentAlpha == 1f) {
            resetAllContentAlphas();
        }
    }

    /**
     * If a subclass's {@link #getContentView()} returns different views depending on state,
     * this method is an opportunity to reset the alpha of ALL content views, not just the
     * current one, which may prevent a content view that is temporarily hidden from being reset.
     *
     * This should setAlpha(1.0f) and setLayerType(LAYER_TYPE_NONE) for all content views.
     */
    protected void resetAllContentAlphas() {}

    @Override
    protected void applyRoundness() {
        super.applyRoundness();
+19 −22
Original line number Diff line number Diff line
@@ -2130,15 +2130,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    public void setExpandAnimationRunning(boolean expandAnimationRunning) {
        View contentView;
        if (mIsSummaryWithChildren) {
            contentView =  mChildrenContainer;
        } else {
            contentView = getShowingLayout();
        }
        if (mGuts != null && mGuts.isExposed()) {
            contentView = mGuts;
        }
        if (expandAnimationRunning) {
            setAboveShelf(true);
            mExpandAnimationRunning = true;
@@ -2151,9 +2142,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            if (mGuts != null) {
                mGuts.setAlpha(1.0f);
            }
            if (contentView != null) {
                contentView.setAlpha(1.0f);
            }
            resetAllContentAlphas();
            setExtraWidthForClipping(0.0f);
            if (mNotificationParent != null) {
                mNotificationParent.setExtraWidthForClipping(0.0f);
@@ -2601,10 +2590,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mPrivateLayout.animate().cancel();
            if (mChildrenContainer != null) {
                mChildrenContainer.animate().cancel();
                mChildrenContainer.setAlpha(1f);
            }
            mPublicLayout.setAlpha(1f);
            mPrivateLayout.setAlpha(1f);
            resetAllContentAlphas();
            mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
            updateChildrenVisibility();
        } else {
@@ -2631,7 +2618,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                    .alpha(0f)
                    .setStartDelay(delay)
                    .setDuration(duration)
                    .withEndAction(() -> hiddenView.setVisibility(View.INVISIBLE));
                    .withEndAction(() -> {
                        hiddenView.setVisibility(View.INVISIBLE);
                        resetAllContentAlphas();
                    });
        }
        for (View showView : shownChildren) {
            showView.setVisibility(View.VISIBLE);
@@ -2754,12 +2744,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (wasAppearing) {
            // During the animation the visible view might have changed, so let's make sure all
            // alphas are reset
            if (mChildrenContainer != null) {
                mChildrenContainer.setAlpha(1.0f);
            }
            for (NotificationContentView l : mLayouts) {
                l.setAlpha(1.0f);
            }
            resetAllContentAlphas();
            if (FADE_LAYER_OPTIMIZATION_ENABLED) {
                setNotificationFaded(false);
            } else {
@@ -2770,6 +2755,18 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    @Override
    protected void resetAllContentAlphas() {
        mPrivateLayout.setAlpha(1f);
        mPrivateLayout.setLayerType(LAYER_TYPE_NONE, null);
        mPublicLayout.setAlpha(1f);
        mPublicLayout.setLayerType(LAYER_TYPE_NONE, null);
        if (mChildrenContainer != null) {
            mChildrenContainer.setAlpha(1f);
            mChildrenContainer.setLayerType(LAYER_TYPE_NONE, null);
        }
    }

    /** Gets the last value set with {@link #setNotificationFaded(boolean)} */
    @Override
    public boolean isNotificationFaded() {