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

Commit 31d37b91 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed that notifications didn't fade away when brightness changed

Because nothing was drawing there with SRC one would simply see
the old buffer there.

Change-Id: Ie7a8989a4af92a05b1e9be2430fd9704c26a125d
Fixes: 27317122
parent cde952c4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -25,12 +25,14 @@ import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.phone.StatusBarWindowView;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;

/**
 * Controls showing and hiding of the brightness mirror.
 */
public class BrightnessMirrorController {

    private final NotificationStackScrollLayout mStackScroller;
    public long TRANSITION_DURATION_OUT = 150;
    public long TRANSITION_DURATION_IN = 200;

@@ -45,10 +47,13 @@ public class BrightnessMirrorController {
        mScrimBehind = (ScrimView) statusBarWindow.findViewById(R.id.scrim_behind);
        mBrightnessMirror = statusBarWindow.findViewById(R.id.brightness_mirror);
        mNotificationPanel = statusBarWindow.findViewById(R.id.notification_panel);
        mStackScroller = (NotificationStackScrollLayout) statusBarWindow.findViewById(
                R.id.notification_stack_scroller);
    }

    public void showMirror() {
        mBrightnessMirror.setVisibility(View.VISIBLE);
        mStackScroller.setFadedOut(true);
        mScrimBehind.animateViewAlpha(0.0f, TRANSITION_DURATION_OUT, Interpolators.ALPHA_OUT);
        outAnimation(mNotificationPanel.animate())
                .withLayer();
@@ -62,6 +67,7 @@ public class BrightnessMirrorController {
                    @Override
                    public void run() {
                        mBrightnessMirror.setVisibility(View.INVISIBLE);
                        mStackScroller.setFadedOut(false);
                    }
                });
    }
@@ -69,7 +75,8 @@ public class BrightnessMirrorController {
    private ViewPropertyAnimator outAnimation(ViewPropertyAnimator a) {
        return a.alpha(0.0f)
                .setDuration(TRANSITION_DURATION_OUT)
                .setInterpolator(Interpolators.ALPHA_OUT);
                .setInterpolator(Interpolators.ALPHA_OUT)
                .withEndAction(null);
    }
    private ViewPropertyAnimator inAnimation(ViewPropertyAnimator a) {
        return a.alpha(1.0f)
+30 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.PropertyValuesHolder;
import android.animation.TimeAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.FloatRange;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
@@ -327,6 +328,8 @@ public class NotificationStackScrollLayout extends ViewGroup
    };
    private PorterDuffXfermode mSrcMode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
    private boolean mPulsing;
    private boolean mDrawBackgroundAsSrc;
    private boolean mFadedOut;

    public NotificationStackScrollLayout(Context context) {
        this(context, null);
@@ -439,7 +442,12 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public void setDrawBackgroundAsSrc(boolean asSrc) {
        mBackgroundPaint.setXfermode(asSrc ? mSrcMode : null);
        mDrawBackgroundAsSrc = asSrc;
        updateSrcDrawing();
    }

    private void updateSrcDrawing() {
        mBackgroundPaint.setXfermode(mDrawBackgroundAsSrc && !mFadedOut ? mSrcMode : null);
        invalidate();
    }

@@ -1741,7 +1749,9 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    private void applyCurrentBackgroundBounds() {
        if (!mFadedOut) {
            mScrimController.setExcludedBackgroundArea(mCurrentBounds);
        }
        invalidate();
    }

@@ -3419,6 +3429,24 @@ public class NotificationStackScrollLayout extends ViewGroup
        updateNotificationAnimationStates();
    }

    public void setFadedOut(boolean fadingOut) {
        if (fadingOut != mFadedOut) {
            mFadedOut = fadingOut;
            if (fadingOut) {
                mScrimController.setExcludedBackgroundArea(null);
            } else {
                applyCurrentBackgroundBounds();
            }
            updateSrcDrawing();
        }
    }

    @Override
    public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) {
        super.setAlpha(alpha);
        setFadedOut(alpha != 1.0f);
    }

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