Limit notifications on lockscreen to a maximum 4.
All the other notifications are going to be collapsed in a "n more"
card.
Bug: 13635952
Change-Id: I18471c7b18d05d27e92c49ee8214605f1a151927
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 4745f3b..47c7c79 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -22,6 +22,8 @@
import android.view.ViewGroup;
import com.android.systemui.R;
+import java.util.ArrayList;
+
/**
* The Algorithm of the {@link com.android.systemui.statusbar.stack
* .NotificationStackScrollLayout} which can be queried for {@link com.android.systemui.statusbar
@@ -92,6 +94,7 @@
algorithmState.lastTopStackIndex = 0;
algorithmState.scrollY = resultState.getScrollY();
algorithmState.itemsInBottomStack = 0.0f;
+ updateVisibleChildren(resultState, algorithmState);
// Phase 1:
findNumberOfItemsInTopStackAndUpdateState(resultState, algorithmState);
@@ -107,6 +110,23 @@
}
/**
+ * Update the visible children on the state.
+ */
+ private void updateVisibleChildren(StackScrollState resultState,
+ StackScrollAlgorithmState state) {
+ ViewGroup hostView = resultState.getHostView();
+ int childCount = hostView.getChildCount();
+ state.visibleChildren.clear();
+ state.visibleChildren.ensureCapacity(childCount);
+ for (int i = 0; i < childCount; i++) {
+ View v = hostView.getChildAt(i);
+ if (v.getVisibility() != View.GONE) {
+ state.visibleChildren.add(v);
+ }
+ }
+ }
+
+ /**
* Determine the positions for the views. This is the main part of the algorithm.
*
* @param resultState The result state to update if a change to the properties of a child occurs
@@ -126,11 +146,10 @@
// How far in is the element currently transitioning into the bottom stack.
float yPositionInScrollView = 0.0f;
- ViewGroup hostView = resultState.getHostView();
- int childCount = hostView.getChildCount();
+ int childCount = algorithmState.visibleChildren.size();
int numberOfElementsCompletelyIn = (int) algorithmState.itemsInTopStack;
for (int i = 0; i < childCount; i++) {
- View child = hostView.getChildAt(i);
+ View child = algorithmState.visibleChildren.get(i);
StackScrollState.ViewState childViewState = resultState.getViewStateForView(child);
childViewState.yTranslation = currentYPosition;
childViewState.location = StackScrollState.ViewState.LOCATION_UNKNOWN;
@@ -282,12 +301,11 @@
// The y Position if the element would be in a regular scrollView
float yPositionInScrollView = 0.0f;
- ViewGroup hostView = resultState.getHostView();
- int childCount = hostView.getChildCount();
+ int childCount = algorithmState.visibleChildren.size();
// find the number of elements in the top stack.
for (int i = 0; i < childCount; i++) {
- View child = hostView.getChildAt(i);
+ View child = algorithmState.visibleChildren.get(i);
StackScrollState.ViewState childViewState = resultState.getViewStateForView(child);
int childHeight = child.getHeight();
float yPositionInScrollViewAfterElement = yPositionInScrollView
@@ -353,9 +371,10 @@
private void updateZValuesForState(StackScrollState resultState,
StackScrollAlgorithmState algorithmState) {
ViewGroup hostView = resultState.getHostView();
- int childCount = hostView.getChildCount();
+ int childCount = algorithmState.visibleChildren.size();
for (int i = 0; i < childCount; i++) {
- View child = hostView.getChildAt(i);
+ View child = algorithmState.visibleChildren.get(i);
+ if (child.getVisibility() == View.GONE) continue;
StackScrollState.ViewState childViewState = resultState.getViewStateForView(child);
if (i < algorithmState.itemsInTopStack) {
float stackIndex = algorithmState.itemsInTopStack - i;
@@ -415,6 +434,11 @@
* how far in is the element currently transitioning into the bottom stack
*/
public float partialInBottom;
+
+ /**
+ * The children from the host view which are not gone.
+ */
+ public final ArrayList<View> visibleChildren = new ArrayList<View>();
}
}