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

This commit is contained in:
Selim Cinek
2016-04-27 22:38:35 +00:00
committed by Android (Google) Code Review
2 changed files with 38 additions and 3 deletions

View File

@@ -25,12 +25,14 @@ import com.android.systemui.Interpolators;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.statusbar.ScrimView; import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.phone.StatusBarWindowView; import com.android.systemui.statusbar.phone.StatusBarWindowView;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
/** /**
* Controls showing and hiding of the brightness mirror. * Controls showing and hiding of the brightness mirror.
*/ */
public class BrightnessMirrorController { public class BrightnessMirrorController {
private final NotificationStackScrollLayout mStackScroller;
public long TRANSITION_DURATION_OUT = 150; public long TRANSITION_DURATION_OUT = 150;
public long TRANSITION_DURATION_IN = 200; public long TRANSITION_DURATION_IN = 200;
@@ -45,10 +47,13 @@ public class BrightnessMirrorController {
mScrimBehind = (ScrimView) statusBarWindow.findViewById(R.id.scrim_behind); mScrimBehind = (ScrimView) statusBarWindow.findViewById(R.id.scrim_behind);
mBrightnessMirror = statusBarWindow.findViewById(R.id.brightness_mirror); mBrightnessMirror = statusBarWindow.findViewById(R.id.brightness_mirror);
mNotificationPanel = statusBarWindow.findViewById(R.id.notification_panel); mNotificationPanel = statusBarWindow.findViewById(R.id.notification_panel);
mStackScroller = (NotificationStackScrollLayout) statusBarWindow.findViewById(
R.id.notification_stack_scroller);
} }
public void showMirror() { public void showMirror() {
mBrightnessMirror.setVisibility(View.VISIBLE); mBrightnessMirror.setVisibility(View.VISIBLE);
mStackScroller.setFadedOut(true);
mScrimBehind.animateViewAlpha(0.0f, TRANSITION_DURATION_OUT, Interpolators.ALPHA_OUT); mScrimBehind.animateViewAlpha(0.0f, TRANSITION_DURATION_OUT, Interpolators.ALPHA_OUT);
outAnimation(mNotificationPanel.animate()) outAnimation(mNotificationPanel.animate())
.withLayer(); .withLayer();
@@ -62,6 +67,7 @@ public class BrightnessMirrorController {
@Override @Override
public void run() { public void run() {
mBrightnessMirror.setVisibility(View.INVISIBLE); mBrightnessMirror.setVisibility(View.INVISIBLE);
mStackScroller.setFadedOut(false);
} }
}); });
} }
@@ -69,7 +75,8 @@ public class BrightnessMirrorController {
private ViewPropertyAnimator outAnimation(ViewPropertyAnimator a) { private ViewPropertyAnimator outAnimation(ViewPropertyAnimator a) {
return a.alpha(0.0f) return a.alpha(0.0f)
.setDuration(TRANSITION_DURATION_OUT) .setDuration(TRANSITION_DURATION_OUT)
.setInterpolator(Interpolators.ALPHA_OUT); .setInterpolator(Interpolators.ALPHA_OUT)
.withEndAction(null);
} }
private ViewPropertyAnimator inAnimation(ViewPropertyAnimator a) { private ViewPropertyAnimator inAnimation(ViewPropertyAnimator a) {
return a.alpha(1.0f) return a.alpha(1.0f)

View File

@@ -23,6 +23,7 @@ import android.animation.PropertyValuesHolder;
import android.animation.TimeAnimator; import android.animation.TimeAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener; import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.FloatRange;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
@@ -327,6 +328,8 @@ public class NotificationStackScrollLayout extends ViewGroup
}; };
private PorterDuffXfermode mSrcMode = new PorterDuffXfermode(PorterDuff.Mode.SRC); private PorterDuffXfermode mSrcMode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
private boolean mPulsing; private boolean mPulsing;
private boolean mDrawBackgroundAsSrc;
private boolean mFadedOut;
public NotificationStackScrollLayout(Context context) { public NotificationStackScrollLayout(Context context) {
this(context, null); this(context, null);
@@ -439,7 +442,12 @@ public class NotificationStackScrollLayout extends ViewGroup
} }
public void setDrawBackgroundAsSrc(boolean asSrc) { public void setDrawBackgroundAsSrc(boolean asSrc) {
mBackgroundPaint.setXfermode(asSrc ? mSrcMode : null); mDrawBackgroundAsSrc = asSrc;
updateSrcDrawing();
}
private void updateSrcDrawing() {
mBackgroundPaint.setXfermode(mDrawBackgroundAsSrc && !mFadedOut ? mSrcMode : null);
invalidate(); invalidate();
} }
@@ -1743,7 +1751,9 @@ public class NotificationStackScrollLayout extends ViewGroup
} }
private void applyCurrentBackgroundBounds() { private void applyCurrentBackgroundBounds() {
mScrimController.setExcludedBackgroundArea(mCurrentBounds); if (!mFadedOut) {
mScrimController.setExcludedBackgroundArea(mCurrentBounds);
}
invalidate(); invalidate();
} }
@@ -3421,6 +3431,24 @@ public class NotificationStackScrollLayout extends ViewGroup
updateNotificationAnimationStates(); 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. * A listener that is notified when some child locations might have changed.
*/ */