Flatten notification hiearchy and remove glow.

Currently, the padding and the glow was inside the individual
notification. This no longer works if we want to adjust the
padding dynamically whether we are on Keyguard or not. This change
moves the padding outside of the individual notifications, and as
a side effect, removes the glow. The glow wasn't really visible with
the new layout, so it's not a breaking change. We have to discuss
with UX first what the new "glow" solution is going to be.

Change-Id: Iac16892cb3b7bb1de3001954b1428796b07950c1
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
index 8dd3f8d..c585a5b 100644
--- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
@@ -19,7 +19,6 @@
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.content.Context;
 import android.media.AudioManager;
@@ -81,8 +80,6 @@
     private boolean mHasPopped;
     private View mEventSource;
     private View mCurrView;
-    private View mCurrViewTopGlow;
-    private View mCurrViewBottomGlow;
     private float mOldHeight;
     private float mNaturalHeight;
     private float mInitialTouchFocusY;
@@ -99,9 +96,6 @@
     private ScaleGestureDetector mSGD;
     private ViewScaler mScaler;
     private ObjectAnimator mScaleAnimation;
-    private AnimatorSet mGlowAnimationSet;
-    private ObjectAnimator mGlowTopAnimation;
-    private ObjectAnimator mGlowBottomAnimation;
     private Vibrator mVibrator;
 
     private int mSmallSize;
@@ -223,14 +217,6 @@
             }
         };
 
-        mGlowTopAnimation = ObjectAnimator.ofFloat(null, "alpha", 0f);
-        mGlowTopAnimation.addListener(glowVisibilityController);
-        mGlowBottomAnimation = ObjectAnimator.ofFloat(null, "alpha", 0f);
-        mGlowBottomAnimation.addListener(glowVisibilityController);
-        mGlowAnimationSet = new AnimatorSet();
-        mGlowAnimationSet.play(mGlowTopAnimation).with(mGlowBottomAnimation);
-        mGlowAnimationSet.setDuration(GLOW_DURATION);
-
         final ViewConfiguration configuration = ViewConfiguration.get(mContext);
         mTouchSlop = configuration.getScaledTouchSlop();
 
@@ -251,7 +237,6 @@
         float newHeight = clamp(target);
         mScaler.setHeight(newHeight);
 
-        setGlow(calculateGlow(target, newHeight));
         mLastFocusY = mSGD.getFocusY();
         mLastSpanY = mSGD.getCurrentSpan();
     }
@@ -322,37 +307,6 @@
         return (GLOW_BASE + strength * (1f - GLOW_BASE));
     }
 
-    public void setGlow(float glow) {
-        if (!mGlowAnimationSet.isRunning() || glow == 0f) {
-            if (mGlowAnimationSet.isRunning()) {
-                mGlowAnimationSet.end();
-            }
-            if (mCurrViewTopGlow != null && mCurrViewBottomGlow != null) {
-                if (glow == 0f || mCurrViewTopGlow.getAlpha() == 0f) {
-                    // animate glow in and out
-                    mGlowTopAnimation.setTarget(mCurrViewTopGlow);
-                    mGlowBottomAnimation.setTarget(mCurrViewBottomGlow);
-                    mGlowTopAnimation.setFloatValues(glow);
-                    mGlowBottomAnimation.setFloatValues(glow);
-                    mGlowAnimationSet.setupStartValues();
-                    mGlowAnimationSet.start();
-                } else {
-                    // set it explicitly in reponse to touches.
-                    mCurrViewTopGlow.setAlpha(glow);
-                    mCurrViewBottomGlow.setAlpha(glow);
-                    handleGlowVisibility();
-                }
-            }
-        }
-    }
-
-    private void handleGlowVisibility() {
-        mCurrViewTopGlow.setVisibility(mCurrViewTopGlow.getAlpha() <= 0.0f ?
-                View.INVISIBLE : View.VISIBLE);
-        mCurrViewBottomGlow.setVisibility(mCurrViewBottomGlow.getAlpha() <= 0.0f ?
-                View.INVISIBLE : View.VISIBLE);
-    }
-
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
         final int action = ev.getAction();
@@ -466,9 +420,6 @@
 
                     if (mHasPopped) {
                         mScaler.setHeight(newHeight);
-                        setGlow(GLOW_BASE);
-                    } else {
-                        setGlow(calculateGlow(4f * pull, 0f));
                     }
 
                     final int x = (int) mSGD.getFocusX();
@@ -517,7 +468,6 @@
         if (DEBUG) Log.d(TAG, "scale type " + expandType + " beginning on view: " + v);
         mCallback.setUserLockedChild(v, true);
         setView(v);
-        setGlow(GLOW_BASE);
         mScaler.setView(v);
         mOldHeight = mScaler.getHeight();
         if (mCallback.canChildBeExpanded(v)) {
@@ -549,7 +499,6 @@
         if (mScaleAnimation.isRunning()) {
             mScaleAnimation.cancel();
         }
-        setGlow(0f);
         mCallback.setUserExpandedChild(mCurrView, h == mNaturalHeight);
         if (targetHeight != currentHeight) {
             mScaleAnimation.setFloatValues(targetHeight);
@@ -571,23 +520,11 @@
 
     private void clearView() {
         mCurrView = null;
-        mCurrViewTopGlow = null;
-        mCurrViewBottomGlow = null;
+
     }
 
     private void setView(View v) {
         mCurrView = v;
-        if (v instanceof ViewGroup) {
-            ViewGroup g = (ViewGroup) v;
-            mCurrViewTopGlow = g.findViewById(R.id.top_glow);
-            mCurrViewBottomGlow = g.findViewById(R.id.bottom_glow);
-            if (DEBUG) {
-                String debugLog = "Looking for glows: " +
-                        (mCurrViewTopGlow != null ? "found top " : "didn't find top") +
-                        (mCurrViewBottomGlow != null ? "found bottom " : "didn't find bottom");
-                Log.v(TAG,  debugLog);
-            }
-        }
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
similarity index 86%
rename from packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java
rename to packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 5e90084..d647dfa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/LatestItemView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2014 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License
  */
 
 package com.android.systemui.statusbar;
@@ -21,12 +21,15 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewConfiguration;
-import android.view.accessibility.AccessibilityEvent;
 import android.widget.FrameLayout;
 
 import com.android.internal.R;
 
-public class LatestItemView extends FrameLayout {
+/**
+ * Base class for both {@link ExpandableNotificationRow} and {@link NotificationOverflowContainer}
+ * to implement dimming/activating on Keyguard for the double-tap gesture
+ */
+public class ActivatableNotificationView extends FrameLayout {
 
     private static final long DOUBLETAP_TIMEOUT_MS = 1000;
 
@@ -48,11 +51,12 @@
 
     private OnActivatedListener mOnActivatedListener;
 
-    public LatestItemView(Context context, AttributeSet attrs) {
+    public ActivatableNotificationView(Context context, AttributeSet attrs) {
         super(context, attrs);
         mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
     }
 
+
     private final Runnable mTapTimeoutRunnable = new Runnable() {
         @Override
         public void run() {
@@ -66,20 +70,6 @@
     }
 
     @Override
-    public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
-        if (super.onRequestSendAccessibilityEvent(child, event)) {
-            // Add a record for the entire layout since its content is somehow small.
-            // The event comes from a leaf view that is interacted with.
-            AccessibilityEvent record = AccessibilityEvent.obtain();
-            onInitializeAccessibilityEvent(record);
-            dispatchPopulateAccessibilityEvent(record);
-            event.appendRecord(record);
-            return true;
-        }
-        return false;
-    }
-
-    @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (mLocked) {
             return handleTouchEventLocked(event);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 2ea5add..3f3383d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -83,7 +83,7 @@
 import java.util.Locale;
 
 public abstract class BaseStatusBar extends SystemUI implements
-        CommandQueue.Callbacks, LatestItemView.OnActivatedListener {
+        CommandQueue.Callbacks, ActivatableNotificationView.OnActivatedListener {
     public static final String TAG = "StatusBar";
     public static final boolean DEBUG = false;
     public static final boolean MULTIUSER_DEBUG = false;
@@ -759,20 +759,19 @@
         // NB: the large icon is now handled entirely by the template
 
         // bind the click event to the content area
-        ViewGroup content = (ViewGroup)row.findViewById(R.id.container);
         SizeAdaptiveLayout expanded = (SizeAdaptiveLayout)row.findViewById(R.id.expanded);
         SizeAdaptiveLayout expandedPublic
                 = (SizeAdaptiveLayout)row.findViewById(R.id.expandedPublic);
 
-        content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
+        row.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
 
         PendingIntent contentIntent = sbn.getNotification().contentIntent;
         if (contentIntent != null) {
             final View.OnClickListener listener = makeClicker(contentIntent,
                     sbn.getPackageName(), sbn.getTag(), sbn.getId(), isHeadsUp, sbn.getUserId());
-            content.setOnClickListener(listener);
+            row.setOnClickListener(listener);
         } else {
-            content.setOnClickListener(null);
+            row.setOnClickListener(null);
         }
 
         // set up the adaptive layout
@@ -882,7 +881,6 @@
         entry.row = row;
         entry.row.setHeightRange(mRowMinHeight, mRowMaxHeight);
         entry.row.setOnActivatedListener(this);
-        entry.content = content;
         entry.expanded = contentViewLocal;
         entry.expandedPublic = publicViewLocal;
         entry.setBigContentView(bigContentViewLocal);
@@ -1349,9 +1347,9 @@
             final View.OnClickListener listener = makeClicker(contentIntent,
                     notification.getPackageName(), notification.getTag(), notification.getId(),
                     isHeadsUp, notification.getUserId());
-            entry.content.setOnClickListener(listener);
+            entry.row.setOnClickListener(listener);
         } else {
-            entry.content.setOnClickListener(null);
+            entry.row.setOnClickListener(null);
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index bb481ec..35c02eb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -20,13 +20,12 @@
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.FrameLayout;
+import android.view.accessibility.AccessibilityEvent;
 
 import com.android.internal.widget.SizeAdaptiveLayout;
 import com.android.systemui.R;
 
-public class ExpandableNotificationRow extends FrameLayout
-        implements LatestItemView.OnActivatedListener {
+public class ExpandableNotificationRow extends ActivatableNotificationView {
     private int mRowMinHeight;
     private int mRowMaxHeight;
 
@@ -41,8 +40,6 @@
     /** Are we showing the "public" version */
     private boolean mShowingPublic;
 
-    private LatestItemView mLatestItemView;
-
     /**
      * Is this notification expanded by the system. The expansion state can be overridden by the
      * user expansion.
@@ -53,7 +50,6 @@
     private int mMaxExpandHeight;
     private boolean mMaxHeightNeedsUpdate;
     private NotificationActivator mActivator;
-    private LatestItemView.OnActivatedListener mOnActivatedListener;
     private boolean mSelfInitiatedLayout;
 
     public ExpandableNotificationRow(Context context, AttributeSet attrs) {
@@ -65,10 +61,22 @@
         super.onFinishInflate();
         mPublicLayout = (SizeAdaptiveLayout) findViewById(R.id.expandedPublic);
         mPrivateLayout = (SizeAdaptiveLayout) findViewById(R.id.expanded);
-        mLatestItemView = (LatestItemView) findViewById(R.id.container);
 
         mActivator = new NotificationActivator(this);
-        mLatestItemView.setOnActivatedListener(this);
+    }
+
+    @Override
+    public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
+        if (super.onRequestSendAccessibilityEvent(child, event)) {
+            // Add a record for the entire layout since its content is somehow small.
+            // The event comes from a leaf view that is interacted with.
+            AccessibilityEvent record = AccessibilityEvent.obtain();
+            onInitializeAccessibilityEvent(record);
+            dispatchPopulateAccessibilityEvent(record);
+            event.appendRecord(record);
+            return true;
+        }
+        return false;
     }
 
     public void setHeightRange(int rowMinHeight, int rowMaxHeight) {
@@ -220,7 +228,7 @@
      * Sets the notification as dimmed, meaning that it will appear in a more gray variant.
      */
     public void setDimmed(boolean dimmed) {
-        mLatestItemView.setDimmed(dimmed);
+        super.setDimmed(dimmed);
         mActivator.setDimmed(dimmed);
     }
 
@@ -232,46 +240,10 @@
         return mMaxExpandHeight;
     }
 
-    /**
-     * Sets the notification as locked. In the locked state, the first tap will produce a quantum
-     * ripple to make the notification brighter and only the second tap will cause a click.
-     */
-    public void setLocked(boolean locked) {
-        mLatestItemView.setLocked(locked);
-    }
-
-    public void setOnActivatedListener(LatestItemView.OnActivatedListener listener) {
-        mOnActivatedListener = listener;
-    }
-
     public NotificationActivator getActivator() {
         return mActivator;
     }
 
-    @Override
-    public void onActivated(View view) {
-        if (mOnActivatedListener != null) {
-            mOnActivatedListener.onActivated(this);
-        }
-    }
-
-    @Override
-    public void onReset(View view) {
-        if (mOnActivatedListener != null) {
-            mOnActivatedListener.onReset(this);
-        }
-    }
-
-    /**
-     * Sets the resource id for the background of this notification.
-     *
-     * @param bgResId The background resource to use in normal state.
-     * @param dimmedBgResId The background resource to use in dimmed state.
-     */
-    public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) {
-        mLatestItemView.setBackgroundResourceIds(bgResId, dimmedBgResId);
-    }
-
     /**
      * @return the potential height this view could expand in addition.
      */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
index d563968..6401695 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
@@ -107,7 +107,7 @@
            mBar.updateNotification(mSynKey, sbn);
         }
         final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey);
-        entry.content.setOnClickListener(mSynClickListener);
+        entry.row.setOnClickListener(mSynClickListener);
     }
 
     private final View.OnClickListener mSynClickListener = new View.OnClickListener() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index b9a59dd..6b6f55a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -33,7 +33,6 @@
         public StatusBarNotification notification;
         public StatusBarIconView icon;
         public ExpandableNotificationRow row; // the outer expanded view
-        public View content; // takes the click events and sends the PendingIntent
         public View expanded; // the inflated RemoteViews
         public View expandedPublic; // for insecure lockscreens
         public ImageView largeIcon;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java
index be58dad..af91314 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java
@@ -18,8 +18,6 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
-import android.view.View;
-import android.widget.FrameLayout;
 import android.widget.TextView;
 
 import com.android.systemui.R;
@@ -27,65 +25,30 @@
 /**
  * Container view for overflowing notification icons on Keyguard.
  */
-public class NotificationOverflowContainer extends FrameLayout
-        implements LatestItemView.OnActivatedListener {
+public class NotificationOverflowContainer extends ActivatableNotificationView {
 
     private NotificationOverflowIconsView mIconsView;
-    private LatestItemView.OnActivatedListener mOnActivatedListener;
     private NotificationActivator mActivator;
 
-    public NotificationOverflowContainer(Context context) {
-        super(context);
-    }
-
     public NotificationOverflowContainer(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
-    public NotificationOverflowContainer(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-    }
-
-    public NotificationOverflowContainer(Context context, AttributeSet attrs, int defStyleAttr,
-            int defStyleRes) {
-        super(context, attrs, defStyleAttr, defStyleRes);
-    }
-
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
         mIconsView = (NotificationOverflowIconsView) findViewById(R.id.overflow_icons_view);
         mIconsView.setMoreText((TextView) findViewById(R.id.more_text));
 
-        LatestItemView latestItemView = (LatestItemView) findViewById(R.id.container);
         mActivator = new NotificationActivator(this);
         mActivator.setDimmed(true);
-        latestItemView.setOnActivatedListener(this);
-        latestItemView.setLocked(true);
+        setLocked(true);
     }
 
     public NotificationOverflowIconsView getIconsView() {
         return mIconsView;
     }
 
-    public void setOnActivatedListener(LatestItemView.OnActivatedListener onActivatedListener) {
-        mOnActivatedListener = onActivatedListener;
-    }
-
-    @Override
-    public void onActivated(View view) {
-        if (mOnActivatedListener != null) {
-            mOnActivatedListener.onActivated(this);
-        }
-    }
-
-    @Override
-    public void onReset(View view) {
-        if (mOnActivatedListener != null) {
-            mOnActivatedListener.onReset(this);
-        }
-    }
-
     public NotificationActivator getActivator() {
         return mActivator;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index a274de6d..5337c11 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -2715,8 +2715,8 @@
         }
 
         mHeadsUpNotificationDecay = res.getInteger(R.integer.heads_up_notification_decay);
-        mRowMinHeight =  res.getDimensionPixelSize(R.dimen.notification_row_min_height);
-        mRowMaxHeight =  res.getDimensionPixelSize(R.dimen.notification_row_max_height);
+        mRowMinHeight =  res.getDimensionPixelSize(R.dimen.notification_min_height);
+        mRowMaxHeight =  res.getDimensionPixelSize(R.dimen.notification_max_height);
 
         mKeyguardMaxNotificationCount = res.getInteger(R.integer.keyguard_max_notification_count);
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index c5dae85..6b5ef5a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -69,8 +69,8 @@
         mStackScrollLayout = (NotificationStackScrollLayout) findViewById(
                 R.id.notification_stack_scroller);
         mNotificationPanel = (NotificationPanelView) findViewById(R.id.notification_panel);
-        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
-        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
+        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
+        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
         mExpandHelper = new ExpandHelper(getContext(), mStackScrollLayout,
                 minHeight, maxHeight);
         mExpandHelper.setEventSource(this);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 2dba669..c94c65f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -135,8 +135,8 @@
         mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
         mEdgeSwipeHelper = new EdgeSwipeHelper(touchSlop);
 
-        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
-        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
+        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
+        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
         mExpandHelper = new ExpandHelper(getContext(), this, minHeight, maxHeight);
 
         mContentHolder = (ViewGroup) findViewById(R.id.content_holder);
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 36d94a9..948ef90 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -145,13 +145,13 @@
         mSidePaddings = context.getResources()
                 .getDimensionPixelSize(R.dimen.notification_side_padding);
         mCollapsedSize = context.getResources()
-                .getDimensionPixelSize(R.dimen.notification_row_min_height);
+                .getDimensionPixelSize(R.dimen.notification_min_height);
         mBottomStackPeekSize = context.getResources()
                 .getDimensionPixelSize(R.dimen.bottom_stack_peek_amount);
         mEmptyMarginBottom = context.getResources().getDimensionPixelSize(
                 R.dimen.notification_stack_margin_bottom);
-        // currently the padding is in the elements themself
-        mPaddingBetweenElements = 0;
+        mPaddingBetweenElements = context.getResources()
+                .getDimensionPixelSize(R.dimen.notification_padding);
         mStackScrollAlgorithm = new StackScrollAlgorithm(context);
     }
 
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 d9e7f66..debe224 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -62,11 +62,10 @@
     }
 
     private void initConstants(Context context) {
-
-        // currently the padding is in the elements themself
-        mPaddingBetweenElements = 0;
+        mPaddingBetweenElements = context.getResources()
+                .getDimensionPixelSize(R.dimen.notification_padding);
         mCollapsedSize = context.getResources()
-                .getDimensionPixelSize(R.dimen.notification_row_min_height);
+                .getDimensionPixelSize(R.dimen.notification_min_height);
         mTopStackPeekSize = context.getResources()
                 .getDimensionPixelSize(R.dimen.top_stack_peek_amount);
         mBottomStackPeekSize = context.getResources()
@@ -323,7 +322,8 @@
         // the offset starting at the transitionPosition of the bottom stack
         float offset = mBottomStackIndentationFunctor.getValue(algorithmState.partialInBottom);
         algorithmState.itemsInBottomStack += algorithmState.partialInBottom;
-        childViewState.yTranslation = transitioningPositionStart + offset - childHeight;
+        childViewState.yTranslation = transitioningPositionStart + offset - childHeight
+                - mPaddingBetweenElements;
 
         // We want at least to be at the end of the top stack when collapsing
         clampPositionToTopStackEnd(childViewState, childHeight);
@@ -339,7 +339,8 @@
         if (algorithmState.itemsInBottomStack < MAX_ITEMS_IN_BOTTOM_STACK) {
             // We are visually entering the bottom stack
             currentYPosition = transitioningPositionStart
-                    + mBottomStackIndentationFunctor.getValue(algorithmState.itemsInBottomStack);
+                    + mBottomStackIndentationFunctor.getValue(algorithmState.itemsInBottomStack)
+                    - mPaddingBetweenElements;
             childViewState.location = StackScrollState.ViewState.LOCATION_BOTTOM_STACK_PEEKING;
         } else {
             // we are fully inside the stack
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 9742e65..6e2e87e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
@@ -197,18 +197,12 @@
      * @param clipHeight the desired clip height, the rest of the view will be clipped from the top
      */
     private void updateChildClip(View child, int height, float clipHeight) {
-        // The children currently have paddings inside themselfs because of the expansion
-        // visualization. In order for the clipping to work correctly we have to set the correct
-        // clip rect on the child.
-        View container = child.findViewById(R.id.container);
-        if (container != null) {
-            int clipInset = (int) (height - clipHeight);
-            mClipRect.set(0,
-                    clipInset,
-                    child.getWidth(),
-                    height);
-            child.setClipBounds(mClipRect);
-        }
+        int clipInset = (int) (height - clipHeight);
+        mClipRect.set(0,
+                clipInset,
+                child.getWidth(),
+                height);
+        child.setClipBounds(mClipRect);
     }
 
     /**
@@ -218,22 +212,15 @@
      * @param height the currently applied height of the view
      * @param outlineHeight the desired height of the outline, the outline ends on the bottom
      */
-    private void updateChildOutline(View child,
-            int height,
-            float outlineHeight) {
-        // The children currently have paddings inside themselfs because of the expansion
-        // visualization. In order for the shadows to work correctly we have to set the correct
-        // outline on the child.
-        View container = child.findViewById(R.id.container);
-        if (container != null) {
-            int shadowInset = (int) (height - outlineHeight);
-            getOutlineForSize(container.getLeft(),
-                    container.getTop() + shadowInset,
-                    container.getWidth(),
-                    container.getHeight() - shadowInset,
-                    mChildOutline);
-            child.setOutline(mChildOutline);
-        }
+    private void updateChildOutline(View child, int height,
+        float outlineHeight) {
+        int shadowInset = (int) (height - outlineHeight);
+        getOutlineForSize(child.getLeft(),
+                child.getTop() + shadowInset,
+                child.getWidth(),
+                child.getHeight() - shadowInset,
+                mChildOutline);
+        child.setOutline(mChildOutline);
     }
 
     private void getOutlineForSize(int leftInset, int topInset, int width, int height,