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

Commit c7d65b4e authored by Mady Mellor's avatar Mady Mellor
Browse files

Adds alpha to dimmed backgrounds

If you're on the lock screen and a child background needs
to be shown (e.g. custom background and user expanding) the
background should fade in from 0 alpha otherwise looks odd
visually.

Bug: 27591195
Change-Id: I1f46831fd8b46eca5b54e7bd964af35752c4fa2f
parent 31e49b09
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private boolean mDark;

    private int mBgTint = 0;
    private float mBgAlpha = 1f;

    /**
     * Flag to indicate that the notification has been touched once and the second touch will
@@ -392,6 +393,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    public void setDimmed(boolean dimmed, boolean fade) {
        if (mDimmed != dimmed) {
            mDimmed = dimmed;
            resetBackgroundAlpha();
            if (fade) {
                fadeDimmedBackground();
            } else {
@@ -594,14 +596,28 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBackgroundAnimator.start();
    }

    protected void updateBackgroundAlpha(float transformationAmount) {
        mBgAlpha = isChildInGroup() && mDimmed ? transformationAmount : 1f;
        mBackgroundDimmed.setAlpha(mBgAlpha);
    }

    protected void resetBackgroundAlpha() {
        updateBackgroundAlpha(0f /* transformationAmount */);
    }

    protected void updateBackground() {
        cancelFadeAnimations();
        if (shouldHideBackground()) {
            mBackgroundDimmed.setVisibility(View.INVISIBLE);
            mBackgroundNormal.setVisibility(View.INVISIBLE);
        } else if (mDimmed) {
            mBackgroundDimmed.setVisibility(View.VISIBLE);
            mBackgroundNormal.setVisibility(mActivated ? View.VISIBLE : View.INVISIBLE);
            // When groups are animating to the expanded state from the lockscreen, show the
            // normal background instead of the dimmed background
            final boolean dontShowDimmed = isGroupExpansionChanging() && isChildInGroup();
            mBackgroundDimmed.setVisibility(dontShowDimmed ? View.INVISIBLE : View.VISIBLE);
            mBackgroundNormal.setVisibility((mActivated || dontShowDimmed)
                    ? View.VISIBLE
                    : View.INVISIBLE);
        } else {
            mBackgroundDimmed.setVisibility(View.INVISIBLE);
            mBackgroundNormal.setVisibility(View.VISIBLE);
@@ -876,6 +892,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

    public void reset() {
        setTintColor(0);
        resetBackgroundAlpha();
        setShowingLegacyBackground(false);
        setBelowSpeedBump(false);
    }
+2 −1
Original line number Diff line number Diff line
@@ -373,6 +373,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        boolean childInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup;
        mNotificationParent = childInGroup ? parent : null;
        mPrivateLayout.setIsChildInGroup(childInGroup);
        resetBackgroundAlpha();
        updateBackgroundForGroupState();
        if (mNotificationParent != null) {
            mNotificationParent.updateBackgroundForGroupState();
@@ -1038,7 +1039,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mPrivateLayout.setUserExpanding(userLocked);
        if (mIsSummaryWithChildren) {
            mChildrenContainer.setUserLocked(userLocked);
            if (userLocked) {
            if (userLocked || (!userLocked && !isGroupExpanded())) {
                updateBackgroundForGroupState();
            }
        }
+2 −0
Original line number Diff line number Diff line
@@ -454,6 +454,7 @@ public class NotificationContentView extends FrameLayout {
            endColor = NotificationUtils.interpolateColors(startColor, endColor,
                    transformationAmount);
        }
        mContainingNotification.updateBackgroundAlpha(transformationAmount);
        mContainingNotification.setContentBackground(endColor, false, this);
    }

@@ -586,6 +587,7 @@ public class NotificationContentView extends FrameLayout {

    public void updateBackgroundColor(boolean animate) {
        int customBackgroundColor = getBackgroundColor(mVisibleType);
        mContainingNotification.resetBackgroundAlpha();
        mContainingNotification.setContentBackground(customBackgroundColor, animate, this);
    }