diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-07-28 21:07:32 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-07-29 22:07:21 +0000 |
commit | 5ad92c52781bf69f7e06c38c834421eecd943a23 (patch) | |
tree | 06be26ecda3b22b9bad605e1996bbef918c1ba1d | |
parent | 3f2757a3054fbbe11d69a68a67eb5f68fe3fb1b0 (diff) | |
download | frameworks_base-5ad92c52781bf69f7e06c38c834421eecd943a23.zip frameworks_base-5ad92c52781bf69f7e06c38c834421eecd943a23.tar.gz frameworks_base-5ad92c52781bf69f7e06c38c834421eecd943a23.tar.bz2 |
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
2 files changed, 16 insertions, 6 deletions
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 @@ public class NotificationPanelView extends PanelView implements } 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 9b819f2..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 @@ public class NotificationStackScrollLayout extends ViewGroup return mBottomStackPeekSize; } + public int getCollapseSecondCardPadding() { + return mCollapseSecondCardPadding; + } + public void setLongPressListener(SwipeHelper.LongPressListener listener) { mSwipeHelper.setLongPressListener(listener); mLongPressListener = listener; @@ -1955,8 +1959,10 @@ public class NotificationStackScrollLayout extends ViewGroup } public void setScrimAlpha(float progress) { - mAmbientState.setScrimAmount(progress); - requestChildrenUpdate(); + if (progress != mAmbientState.getScrimAmount()) { + mAmbientState.setScrimAmount(progress); + requestChildrenUpdate(); + } } /** |