Merge "Fixed that notifications didn\'t fade away when brightness changed" into nyc-dev
am: 42a0cb3
* commit '42a0cb3188ad1eaadf5cdcf3fe7f1d1fb6189a61':
Fixed that notifications didn't fade away when brightness changed
Change-Id: I9284cb92a68f3bcb05cb9aedc9f70f51f56b2326
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
mScrimController.setExcludedBackgroundArea(mCurrentBounds);
|
||||
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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user