From 2e34ec3cbbe595b646bd7f319fb369a37191847f Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 1 Jul 2014 03:17:05 +0200 Subject: [PATCH] Fix clipping of notifications on lockscreen. Bug: 15942321 Change-Id: I5838c24987de9ed4d1df550df408536271b047f1 --- .../statusbar/stack/StackScrollAlgorithm.java | 20 ++++++++++--------- .../statusbar/stack/StackScrollState.java | 8 ++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index 4956fe8c99342..a8c25d83c75d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -176,14 +176,14 @@ public class StackScrollAlgorithm { for (int i = 0; i < childCount; i++) { ExpandableView child = algorithmState.visibleChildren.get(i); StackScrollState.ViewState state = resultState.getViewStateForView(child); - float newYTranslation = state.yTranslation; - int newHeight = state.height; + float newYTranslation = state.yTranslation + state.height * (1f - state.scale) / 2f; + float newHeight = state.height * state.scale; // apply clipping and shadow float newNotificationEnd = newYTranslation + newHeight; // In the unlocked shade we have to clip a little bit higher because of the rounded // corners of the notifications. - float clippingCorrection = state.dimmed ? 0 : mRoundedRectCornerRadius; + float clippingCorrection = state.dimmed ? 0 : mRoundedRectCornerRadius * state.scale; // When the previous notification is swiped, we don't clip the content to the // bottom of it. @@ -192,12 +192,12 @@ public class StackScrollAlgorithm { : newNotificationEnd - (previousNotificationEnd - clippingCorrection); updateChildClippingAndBackground(state, newHeight, clipHeight, - (int) (newHeight - (previousNotificationStart - newYTranslation))); + newHeight - (previousNotificationStart - newYTranslation)); if (!child.isTransparent()) { // Only update the previous values if we are not transparent, // otherwise we would clip to a transparent view. - previousNotificationStart = newYTranslation + state.clipTopAmount; + previousNotificationStart = newYTranslation + state.clipTopAmount * state.scale; previousNotificationEnd = newNotificationEnd; previousNotificationIsSwiped = child.getTranslationX() != 0; } @@ -213,15 +213,17 @@ public class StackScrollAlgorithm { * @param backgroundHeight the desired background height. The shadows of the view will be * based on this height and the content will be clipped from the top */ - private void updateChildClippingAndBackground(StackScrollState.ViewState state, int realHeight, - float clipHeight, int backgroundHeight) { + private void updateChildClippingAndBackground(StackScrollState.ViewState state, + float realHeight, float clipHeight, float backgroundHeight) { if (realHeight > clipHeight) { - state.topOverLap = (int) (realHeight - clipHeight); + // Rather overlap than create a hole. + state.topOverLap = (int) Math.floor((realHeight - clipHeight) / state.scale); } else { state.topOverLap = 0; } if (realHeight > backgroundHeight) { - state.clipTopAmount = (realHeight - backgroundHeight); + // Rather overlap than create a hole. + state.clipTopAmount = (int) Math.floor((realHeight - backgroundHeight) / state.scale); } else { state.clipTopAmount = 0; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java index d8407d56ef081..9ae038ad26c2b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java @@ -154,16 +154,12 @@ public class StackScrollState { // apply scrimming child.setScrimAmount(state.scrimAmount); + // apply clipping float oldClipTopAmount = child.getClipTopAmount(); if (oldClipTopAmount != state.clipTopAmount) { child.setClipTopAmount(state.clipTopAmount); } - - if (state.topOverLap != 0) { - updateChildClip(child, newHeight, state.topOverLap); - } else { - child.setClipBounds(null); - } + updateChildClip(child, newHeight, state.topOverLap); if(child instanceof SpeedBumpView) { float lineEnd = newYTranslation + newHeight / 2;