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

Commit e1ec2282 authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Merge "Fixed that notifications didn\'t fade away when brightness changed" into nyc-dev

am: 42a0cb31

* commit '42a0cb31':
  Fixed that notifications didn't fade away when brightness changed

Change-Id: I941ec921a2f611dbef6ac3363a1687f60a296a44
parents a31c675e 42a0cb31
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();
    }

@@ -1743,7 +1751,9 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

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

@@ -3421,6 +3431,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.
     */