diff options
4 files changed, 130 insertions, 36 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index f56d29d123c4..9177f4b4a159 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -205,6 +205,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { private boolean mIsLastChild; private Runnable mOnDismissRunnable; private boolean mIsLowPriority; + private boolean mIsColorized; @Override public boolean isGroupExpansionChanging() { @@ -297,6 +298,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { for (NotificationContentView l : mLayouts) { l.onNotificationUpdated(entry); } + mIsColorized = mStatusBarNotification.getNotification().isColorized(); mShowingPublicInitialized = false; updateNotificationColor(); if (mIsSummaryWithChildren) { @@ -1865,10 +1867,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { } else if (isUserLocked()) { return mChildrenContainer.getGroupExpandFraction(); } + } else if (isColorized()) { + return -1.0f; } return 0.0f; } + private boolean isColorized() { + return mIsColorized; + } + @Override protected boolean disallowSingleClick(MotionEvent event) { float x = event.getX(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java index 37a900e52e86..6a1f470c846a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java @@ -404,7 +404,9 @@ public abstract class ExpandableView extends FrameLayout { } /** - * @return an amount between 0 and 1 of increased padding that this child needs + * @return an amount between -1 and 1 of increased padding that this child needs. 1 means it + * needs a full increased padding while -1 means it needs no padding at all. For 0.0f the normal + * padding is applied. */ public float getIncreasedPaddingAmount() { return 0.0f; 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 b5ec398ffdd7..5d48df974842 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -612,9 +612,9 @@ public class NotificationStackScrollLayout extends ViewGroup ExpandableView child = (ExpandableView) getChildAt(i); if (mChildrenToAddAnimated.contains(child)) { int startingPosition = getPositionInLinearLayout(child); - int padding = child.getIncreasedPaddingAmount() == 1.0f - ? mIncreasedPaddingBetweenElements : - mPaddingBetweenElements; + float increasedPaddingAmount = child.getIncreasedPaddingAmount(); + int padding = increasedPaddingAmount == 1.0f ? mIncreasedPaddingBetweenElements + : increasedPaddingAmount == -1.0f ? 0 : mPaddingBetweenElements; int childHeight = getIntrinsicHeight(child) + padding; if (startingPosition < mOwnScrollY) { // This child starts off screen, so let's keep it offscreen to keep the others visible @@ -1886,7 +1886,8 @@ public class NotificationStackScrollLayout extends ViewGroup private void updateContentHeight() { int height = 0; - float previousIncreasedAmount = 0.0f; + float previousPaddingRequest = mPaddingBetweenElements; + float previousPaddingAmount = 0.0f; int numShownItems = 0; boolean finish = false; int maxDisplayedNotifications = mAmbientState.isDark() @@ -1903,13 +1904,35 @@ public class NotificationStackScrollLayout extends ViewGroup finish = true; } float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount(); - if (height != 0) { - height += (int) NotificationUtils.interpolate( + float padding; + if (increasedPaddingAmount >= 0.0f) { + padding = (int) NotificationUtils.interpolate( + previousPaddingRequest, + mIncreasedPaddingBetweenElements, + increasedPaddingAmount); + previousPaddingRequest = (int) NotificationUtils.interpolate( mPaddingBetweenElements, mIncreasedPaddingBetweenElements, - Math.max(previousIncreasedAmount, increasedPaddingAmount)); + increasedPaddingAmount); + } else { + int ownPadding = (int) NotificationUtils.interpolate( + 0, + mPaddingBetweenElements, + 1.0f + increasedPaddingAmount); + if (previousPaddingAmount > 0.0f) { + padding = (int) NotificationUtils.interpolate( + ownPadding, + mIncreasedPaddingBetweenElements, + previousPaddingAmount); + } else { + padding = ownPadding; + } + previousPaddingRequest = ownPadding; } - previousIncreasedAmount = increasedPaddingAmount; + if (height != 0) { + height += padding; + } + previousPaddingAmount = increasedPaddingAmount; height += expandableView.getIntrinsicHeight(); numShownItems++; if (finish) { @@ -2572,10 +2595,19 @@ public class NotificationStackScrollLayout extends ViewGroup */ private void updateScrollStateForRemovedChild(ExpandableView removedChild) { int startingPosition = getPositionInLinearLayout(removedChild); - int padding = (int) NotificationUtils.interpolate( - mPaddingBetweenElements, - mIncreasedPaddingBetweenElements, - removedChild.getIncreasedPaddingAmount()); + float increasedPaddingAmount = removedChild.getIncreasedPaddingAmount(); + int padding; + if (increasedPaddingAmount >= 0) { + padding = (int) NotificationUtils.interpolate( + mPaddingBetweenElements, + mIncreasedPaddingBetweenElements, + increasedPaddingAmount); + } else { + padding = (int) NotificationUtils.interpolate( + 0, + mPaddingBetweenElements, + 1.0f + increasedPaddingAmount); + } int childHeight = getIntrinsicHeight(removedChild) + padding; int endPosition = startingPosition + childHeight; if (endPosition <= mOwnScrollY) { @@ -2607,19 +2639,42 @@ public class NotificationStackScrollLayout extends ViewGroup requestedView = requestedRow = childInGroup.getNotificationParent(); } int position = 0; - float previousIncreasedAmount = 0.0f; + float previousPaddingRequest = mPaddingBetweenElements; + float previousPaddingAmount = 0.0f; for (int i = 0; i < getChildCount(); i++) { ExpandableView child = (ExpandableView) getChildAt(i); boolean notGone = child.getVisibility() != View.GONE; if (notGone && !child.hasNoContentHeight()) { float increasedPaddingAmount = child.getIncreasedPaddingAmount(); - if (position != 0) { - position += (int) NotificationUtils.interpolate( + float padding; + if (increasedPaddingAmount >= 0.0f) { + padding = (int) NotificationUtils.interpolate( + previousPaddingRequest, + mIncreasedPaddingBetweenElements, + increasedPaddingAmount); + previousPaddingRequest = (int) NotificationUtils.interpolate( mPaddingBetweenElements, mIncreasedPaddingBetweenElements, - Math.max(previousIncreasedAmount, increasedPaddingAmount)); + increasedPaddingAmount); + } else { + int ownPadding = (int) NotificationUtils.interpolate( + 0, + mPaddingBetweenElements, + 1.0f + increasedPaddingAmount); + if (previousPaddingAmount > 0.0f) { + padding = (int) NotificationUtils.interpolate( + ownPadding, + mIncreasedPaddingBetweenElements, + previousPaddingAmount); + } else { + padding = ownPadding; + } + previousPaddingRequest = ownPadding; + } + if (position != 0) { + position += padding; } - previousIncreasedAmount = increasedPaddingAmount; + previousPaddingAmount = increasedPaddingAmount; } if (child == requestedView) { if (requestedRow != null) { 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 7ff100081677..ba91ffd04c0e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -27,7 +27,6 @@ import com.android.systemui.statusbar.EmptyShadeView; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.ExpandableView; import com.android.systemui.statusbar.NotificationShelf; -import com.android.systemui.statusbar.StackScrollerDecorView; import com.android.systemui.statusbar.notification.NotificationUtils; import java.util.ArrayList; @@ -244,7 +243,7 @@ public class StackScrollAlgorithm { int childCount = hostView.getChildCount(); state.visibleChildren.clear(); state.visibleChildren.ensureCapacity(childCount); - state.increasedPaddingMap.clear(); + state.paddingMap.clear(); int notGoneIndex = 0; ExpandableView lastView = null; for (int i = 0; i < childCount; i++) { @@ -254,16 +253,31 @@ public class StackScrollAlgorithm { continue; } notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v); - float increasedPadding = v.getIncreasedPaddingAmount(); + float increasedPadding = v.getIncreasedPaddingAmount();; if (increasedPadding != 0.0f) { - state.increasedPaddingMap.put(v, increasedPadding); + state.paddingMap.put(v, increasedPadding); if (lastView != null) { - Float prevValue = state.increasedPaddingMap.get(lastView); - float newValue = prevValue != null - ? Math.max(prevValue, increasedPadding) - : increasedPadding; - state.increasedPaddingMap.put(lastView, newValue); + Float prevValue = state.paddingMap.get(lastView); + float newValue = getPaddingForValue(increasedPadding); + if (prevValue != null) { + float prevPadding = getPaddingForValue(prevValue); + if (increasedPadding > 0) { + newValue = NotificationUtils.interpolate( + prevPadding, + newValue, + increasedPadding); + } else if (prevValue > 0) { + newValue = NotificationUtils.interpolate( + newValue, + prevPadding, + prevValue); + } + } + state.paddingMap.put(lastView, newValue); } + } else if (lastView != null) { + float newValue = getPaddingForValue(state.paddingMap.get(lastView)); + state.paddingMap.put(lastView, newValue); } if (v instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) v; @@ -287,6 +301,22 @@ public class StackScrollAlgorithm { } } + private float getPaddingForValue(Float increasedPadding) { + if (increasedPadding == null) { + return mPaddingBetweenElements; + } else if (increasedPadding >= 0.0f) { + return NotificationUtils.interpolate( + mPaddingBetweenElements, + mIncreasedPaddingBetweenElements, + increasedPadding); + } else { + return NotificationUtils.interpolate( + 0, + mPaddingBetweenElements, + 1.0f + increasedPadding); + } + } + private int updateNotGoneIndex(StackScrollState resultState, StackScrollAlgorithmState state, int notGoneIndex, ExpandableView v) { @@ -527,18 +557,17 @@ public class StackScrollAlgorithm { public final ArrayList<ExpandableView> visibleChildren = new ArrayList<ExpandableView>(); /** - * The children from the host that need an increased padding after them. A value of 0 means - * no increased padding, a value of 1 means full padding. + * The padding after each child measured in pixels. */ - public final HashMap<ExpandableView, Float> increasedPaddingMap = new HashMap<>(); + public final HashMap<ExpandableView, Float> paddingMap = new HashMap<>(); public int getPaddingAfterChild(ExpandableView child) { - Float paddingValue = increasedPaddingMap.get(child); - return paddingValue == null - ? mPaddingBetweenElements - : (int) NotificationUtils.interpolate(mPaddingBetweenElements, - mIncreasedPaddingBetweenElements, - paddingValue); + Float padding = paddingMap.get(child); + if (padding == null) { + // Should only happen for the last view + return mPaddingBetweenElements; + } + return (int) padding.floatValue(); } } |