Made notifications below speedbump grey.

Also fixed a small scrimming bug where headsup where
scrimmed.

Bug: 15408642
Change-Id: I8319ccb001a1d654af055276de3c64ae388a7e47
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 06a81b8..c02a598 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -132,6 +132,8 @@
     private boolean mShowingLegacyBackground;
     private final int mLegacyColor;
     private final int mNormalColor;
+    private final int mLowPriorityColor;
+    private boolean mIsBelowSpeedBump;
 
     public ActivatableNotificationView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -150,6 +152,8 @@
                 R.dimen.notification_material_rounded_rect_radius);
         mLegacyColor = getResources().getColor(R.color.notification_legacy_background_color);
         mNormalColor = getResources().getColor(R.color.notification_material_background_color);
+        mLowPriorityColor = getResources().getColor(
+                R.color.notification_material_background_low_priority_color);
     }
 
     @Override
@@ -162,6 +166,7 @@
         updateBackground();
         updateBackgroundTint();
         mScrimView = (NotificationScrimView) findViewById(R.id.scrim_view);
+        setScrimAmount(0);
     }
 
     private final Runnable mTapTimeoutRunnable = new Runnable() {
@@ -342,6 +347,15 @@
         updateBackgroundTint();
     }
 
+    @Override
+    public void setBelowSpeedBump(boolean below) {
+        super.setBelowSpeedBump(below);
+        if (below != mIsBelowSpeedBump) {
+            mIsBelowSpeedBump = below;
+            updateBackgroundTint();
+        }
+    }
+
     /**
      * Sets the tint color of the background
      */
@@ -589,6 +603,8 @@
             return mBgTint;
         } else if (mShowingLegacyBackground) {
             return mLegacyColor;
+        } else if (mIsBelowSpeedBump) {
+            return mLowPriorityColor;
         } else {
             return mNormalColor;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 5528e82..17757ff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -1071,7 +1071,6 @@
         entry.row = row;
         entry.row.setHeightRange(mRowMinHeight, maxHeight);
         entry.row.setOnActivatedListener(this);
-        entry.row.setIsBelowSpeedBump(isBelowSpeedBump(entry.notification));
         entry.expanded = contentViewLocal;
         entry.expandedPublic = publicViewLocal;
         entry.setBigContentView(bigContentViewLocal);
@@ -1548,19 +1547,9 @@
         } else {
             entry.row.setOnClickListener(null);
         }
-        boolean wasBelow = entry.row.isBelowSpeedBump();
-        boolean nowBelow = isBelowSpeedBump(notification);
-        if (wasBelow != nowBelow) {
-            entry.row.setIsBelowSpeedBump(nowBelow);
-        }
         entry.row.notifyContentUpdated();
     }
 
-    private boolean isBelowSpeedBump(StatusBarNotification notification) {
-        return notification.getNotification().priority ==
-                Notification.PRIORITY_MIN;
-    }
-
     protected void notifyHeadsUpScreenOn(boolean screenOn) {
         if (!screenOn) {
             scheduleHeadsUpEscalation();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 5981898..c6000af 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -52,7 +52,6 @@
     private NotificationContentView mPublicLayout;
     private NotificationContentView mPrivateLayout;
     private int mMaxExpandHeight;
-    private boolean mIsBelowSpeedBump;
     private View mVetoButton;
 
     public ExpandableNotificationRow(Context context, AttributeSet attrs) {
@@ -245,14 +244,6 @@
         mPublicLayout.setClipTopAmount(clipTopAmount);
     }
 
-    public boolean isBelowSpeedBump() {
-        return mIsBelowSpeedBump;
-    }
-
-    public void setIsBelowSpeedBump(boolean isBelow) {
-        this.mIsBelowSpeedBump = isBelow;
-    }
-
     public void notifyContentUpdated() {
         mPublicLayout.notifyContentUpdated();
         mPrivateLayout.notifyContentUpdated();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 0a5d138..bac65f8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -234,6 +234,9 @@
 
     public abstract void setScrimAmount(float scrimAmount);
 
+    public void setBelowSpeedBump(boolean below) {
+    }
+
     /**
      * A listener notifying when {@link #getActualHeight} changes.
      */
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 5dba2c4..7c522d3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -155,6 +155,17 @@
         updateDimmedActivated(ambientState, resultState, algorithmState);
         updateClipping(resultState, algorithmState);
         updateScrimAmount(resultState, algorithmState, ambientState.getScrimAmount());
+        updateSpeedBumpState(resultState, algorithmState, ambientState.getSpeedBumpIndex());
+    }
+
+    private void updateSpeedBumpState(StackScrollState resultState,
+            StackScrollAlgorithmState algorithmState, int speedBumpIndex) {
+        int childCount = algorithmState.visibleChildren.size();
+        for (int i = 0; i < childCount; i++) {
+            View child = algorithmState.visibleChildren.get(i);
+            StackScrollState.ViewState childViewState = resultState.getViewStateForView(child);
+            childViewState.belowSpeedBump = speedBumpIndex != -1 && i > speedBumpIndex;
+        }
     }
 
     private void updateScrimAmount(StackScrollState resultState,
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 9ae038a..f48739c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
@@ -151,6 +151,9 @@
                 // apply dark
                 child.setDark(state.dark, false /* animate */);
 
+                // apply speed bump state
+                child.setBelowSpeedBump(state.belowSpeedBump);
+
                 // apply scrimming
                 child.setScrimAmount(state.scrimAmount);
 
@@ -224,6 +227,7 @@
         float scale;
         boolean dimmed;
         boolean dark;
+        boolean belowSpeedBump;
 
         /**
          * A value between 0 and 1 indicating how much the view should be scrimmed.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
index f732cf0..0c84675 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
@@ -179,6 +179,9 @@
         // start dark animation
         child.setDark(viewState.dark, mAnimationFilter.animateDark);
 
+        // apply speed bump state
+        child.setBelowSpeedBump(viewState.belowSpeedBump);
+
         // apply scrimming
         child.setScrimAmount(viewState.scrimAmount);