Optimize alpha handling for stack scroller
Use a layer when an alpha is set. Currently, this breaks shadows
when alpha != 1f, however, b/15860114 will fix this.
Change-Id: I094d5896a5433ba9a0ecc17549ef2944f6b7881e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index b80a33b..1932843 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -937,12 +937,16 @@
}
private void updateNotificationTranslucency() {
float alpha = (getNotificationsTopY() + mNotificationStackScroller.getItemHeight())
- / (mQsMinExpansionHeight + mNotificationStackScroller.getItemHeight() / 2);
+ / (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize()
+ + mNotificationStackScroller.getCollapseSecondCardPadding());
alpha = Math.max(0, Math.min(alpha, 1));
alpha = (float) Math.pow(alpha, 0.75);
-
- // TODO: Draw a rect with DST_OUT over the notifications to achieve the same effect -
- // this would be much more efficient.
+ if (alpha != 1f && mNotificationStackScroller.getLayerType() != LAYER_TYPE_HARDWARE) {
+ mNotificationStackScroller.setLayerType(LAYER_TYPE_HARDWARE, null);
+ } else if (alpha == 1f
+ && mNotificationStackScroller.getLayerType() == LAYER_TYPE_HARDWARE) {
+ mNotificationStackScroller.setLayerType(LAYER_TYPE_NONE, null);
+ }
mNotificationStackScroller.setAlpha(alpha);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 9b819f2b..e0167e9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -470,6 +470,10 @@
return mBottomStackPeekSize;
}
+ public int getCollapseSecondCardPadding() {
+ return mCollapseSecondCardPadding;
+ }
+
public void setLongPressListener(SwipeHelper.LongPressListener listener) {
mSwipeHelper.setLongPressListener(listener);
mLongPressListener = listener;
@@ -1955,8 +1959,10 @@
}
public void setScrimAlpha(float progress) {
- mAmbientState.setScrimAmount(progress);
- requestChildrenUpdate();
+ if (progress != mAmbientState.getScrimAmount()) {
+ mAmbientState.setScrimAmount(progress);
+ requestChildrenUpdate();
+ }
}
/**