Migrated the systemUI based notification header

Previously the notification header had a seperate implementation
in SystemUI from which the platform implementation was derived.
Now that everything is in the framework, we’re migrating the
implementation for notification groups.ß

Change-Id: Ia61a75bd6c85e1805d4364a9e7e4587a020c1271
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index f49c77d..6c0c3e8 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -58,7 +58,6 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.reflect.Constructor;
-import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -2986,7 +2985,7 @@
         }
 
         private void resetStandardTemplate(RemoteViews contentView) {
-            resetHeader(contentView);
+            resetNotificationHeader(contentView);
             resetContentMargins(contentView);
             contentView.setViewVisibility(R.id.right_icon, View.GONE);
             contentView.setTextViewText(R.id.title, null);
@@ -2996,7 +2995,10 @@
             contentView.setViewVisibility(R.id.progress, View.GONE);
         }
 
-        private void resetHeader(RemoteViews contentView) {
+        /**
+         * Resets the notification header to its original state
+         */
+        private void resetNotificationHeader(RemoteViews contentView) {
             contentView.setImageViewResource(R.id.icon, 0);
             contentView.setTextViewText(R.id.app_name_text, null);
             contentView.setViewVisibility(R.id.chronometer, View.GONE);
@@ -3091,6 +3093,7 @@
 
         private void bindNotificationHeader(RemoteViews contentView) {
             bindSmallIcon(contentView);
+            bindChildCountColor(contentView);
             bindHeaderAppName(contentView);
             bindHeaderSubText(contentView);
             bindContentInfo(contentView);
@@ -3098,6 +3101,10 @@
             bindExpandButton(contentView);
         }
 
+        private void bindChildCountColor(RemoteViews contentView) {
+            contentView.setTextColor(R.id.number_of_children, resolveColor());
+        }
+
         private void bindContentInfo(RemoteViews contentView) {
             boolean visible = false;
             if (mN.extras.getCharSequence(EXTRA_INFO_TEXT) != null) {
@@ -3251,6 +3258,19 @@
             return result;
         }
 
+        /**
+         * Construct a RemoteViews for the final notification header only
+         *
+         * @hide
+         */
+        public RemoteViews makeNotificationHeader() {
+            RemoteViews header = new BuilderRemoteViews(mContext.getApplicationInfo(),
+                    R.layout.notification_template_header);
+            resetNotificationHeader(header);
+            bindNotificationHeader(header);
+            return header;
+        }
+
         private void hideLine1Text(RemoteViews result) {
             result.setViewVisibility(R.id.text_line_1, View.GONE);
         }
diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java
index 46cd7ae..82f6c7f 100644
--- a/core/java/android/view/NotificationHeaderView.java
+++ b/core/java/android/view/NotificationHeaderView.java
@@ -23,6 +23,7 @@
 import android.util.AttributeSet;
 import android.widget.LinearLayout;
 import android.widget.RemoteViews;
+import android.widget.TextView;
 
 import java.util.ArrayList;
 
@@ -40,6 +41,7 @@
     private HeaderTouchListener mTouchListener = new HeaderTouchListener();
     private View mExpandButton;
     private View mIcon;
+    private TextView mChildCount;
 
     public NotificationHeaderView(Context context) {
         this(context, null);
@@ -66,6 +68,7 @@
         mSubTextView = findViewById(com.android.internal.R.id.header_sub_text);
         mExpandButton = findViewById(com.android.internal.R.id.expand_button);
         mIcon = findViewById(com.android.internal.R.id.icon);
+        mChildCount = (TextView) findViewById(com.android.internal.R.id.number_of_children);
     }
 
     @Override
@@ -132,6 +135,17 @@
         updateTouchListener();
     }
 
+    public void setChildCount(int childCount) {
+        if (childCount > 0) {
+            mChildCount.setText(getContext().getString(
+                    com.android.internal.R.string.notification_children_count_bracketed,
+                    childCount));
+            mChildCount.setVisibility(VISIBLE);
+        } else {
+            mChildCount.setVisibility(GONE);
+        }
+    }
+
     public class HeaderTouchListener implements View.OnTouchListener {
 
         private final ArrayList<Rect> mTouchRects = new ArrayList<>();
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 08e6d61..d6dd842 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -531,6 +531,9 @@
          [CHAR LIMIT=4] -->
     <string name="status_bar_notification_info_overflow">999+</string>
 
+    <!-- The number of notifications in the notification header. An example would be (2) or (12) -->
+    <string name="notification_children_count_bracketed">(<xliff:g id="notificationCount" example="1">%d</xliff:g>)</string>
+
     <!-- The divider symbol between different parts of the notification header. not translatable [CHAR LIMIT=1] -->
     <string name="notification_header_divider_symbol" translatable="false">•</string>
 
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 7be697a..9dbdaaa 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2345,6 +2345,7 @@
   <java-symbol type="id" name="addToDictionaryButton" />
   <java-symbol type="id" name="deleteButton" />
 
+  <java-symbol type="string" name="notification_children_count_bracketed" />
   <java-symbol type="id" name="app_name_text" />
   <java-symbol type="id" name="number_of_children" />
   <java-symbol type="id" name="header_sub_text" />
@@ -2356,6 +2357,7 @@
   <java-symbol type="id" name="content_info_divider" />
   <java-symbol type="id" name="text_line_1" />
   <java-symbol type="drawable" name="ic_arrow_up_14dp" />
+  <java-symbol type="dimen" name="notification_header_height" />
   <java-symbol type="dimen" name="notification_big_picture_content_min_height_with_picture" />
   <java-symbol type="dimen" name="notification_header_shrink_min_width" />
   <java-symbol type="dimen" name="notification_content_margin_start" />
diff --git a/packages/SystemUI/res/layout/notification_header.xml b/packages/SystemUI/res/layout/notification_header.xml
deleted file mode 100644
index 3475d00..0000000
--- a/packages/SystemUI/res/layout/notification_header.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2015 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.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ 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
-  -->
-
-<com.android.systemui.statusbar.notification.NotificationHeaderView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="@dimen/notification_header_height"
-    android:clipChildren="false">
-    <LinearLayout
-        android:orientation="horizontal"
-        android:layout_width="wrap_content"
-        android:layout_height="@dimen/notification_header_height"
-        android:layout_gravity="start"
-        android:gravity="center_vertical"
-        android:paddingStart="@dimen/notification_content_margin_start">
-        <ImageView
-            android:id="@+id/header_notification_icon"
-            android:layout_width="24dp"
-            android:layout_height="24dp"
-            android:layout_marginEnd="4dp"
-            />
-        <TextView
-            android:id="@+id/number_of_children"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="@*android:style/TextAppearance.Material.Notification"
-            android:layout_marginEnd="2dp"
-            android:layout_marginStart="1dp"
-            />
-        <TextView
-            android:id="@+id/app_name_text"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="@style/TextAppearance.Material.Notification.HeaderTitle"
-            android:layout_marginStart="4dp"
-            android:layout_marginEnd="8dp"
-            />
-        <TextView
-            android:id="@+id/app_title_sub_text_divider"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="@style/TextAppearance.Material.Notification.HeaderTitle"
-            android:layout_marginEnd="8dp"
-            android:text="@string/notification_header_divider_symbol"/>
-        <TextView
-            android:id="@+id/title_sub_text"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="@style/TextAppearance.Material.Notification.HeaderTitle"
-            android:layout_marginEnd="8dp" />
-        <TextView
-            android:id="@+id/post_time"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="end|center_vertical"
-            android:textAppearance="@*android:style/TextAppearance.Material.Notification.Time"
-            android:paddingEnd="8dp"
-            />
-    </LinearLayout>
-    <ImageButton
-        android:id="@+id/notification_expand_button"
-        android:background="@null"
-        android:layout_width="48dp"
-        android:layout_height="48dp"
-        android:layout_gravity="end|center_vertical"
-        android:src="@drawable/notification_expand_more"
-        android:layout_marginEnd="8dp"
-        />
-</com.android.systemui.statusbar.notification.NotificationHeaderView>
diff --git a/packages/SystemUI/res/layout/status_bar_notification_row.xml b/packages/SystemUI/res/layout/status_bar_notification_row.xml
index b9088ec..0cea7ae 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_row.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_row.xml
@@ -61,14 +61,6 @@
         />
 
     <ViewStub
-        android:layout="@layout/notification_header"
-        android:id="@+id/notification_header_stub"
-        android:inflatedId="@+id/notification_header"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/notification_header_height"
-        />
-
-    <ViewStub
         android:layout="@layout/notification_guts"
         android:id="@+id/notification_guts_stub"
         android:inflatedId="@+id/notification_guts"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 69f45ed..086e9f4 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -351,9 +351,6 @@
     <!-- radius of the corners of the material rounded rect background but negative-->
     <dimen name="notification_material_rounded_rect_radius_negative">-2dp</dimen>
 
-    <!-- height of notification header view if present -->
-    <dimen name="notification_header_height">32dp</dimen>
-
     <!-- The padding between notification children -->
     <dimen name="notification_children_padding">2dp</dimen>
 
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 04233ba..d6a361c 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -753,9 +753,6 @@
     <!-- Text for overflow card on Keyguard when there is not enough space for all notifications on Keyguard. [CHAR LIMIT=1] -->
     <string name="keyguard_more_overflow_text">+<xliff:g id="number_of_notifications" example="5">%d</xliff:g></string>
 
-    <!-- The divider symbol between different parts of the notification header. not translatable [CHAR LIMIT=1] -->
-    <string name="notification_header_divider_symbol" translatable="false">•</string>
-
     <!-- An explanation for the visual speed bump in the notifications, which will appear when you click on it. [CHAR LIMIT=50] -->
     <string name="speed_bump_explanation">Less urgent notifications below</string>
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index a0cb890..da2281e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -25,16 +25,17 @@
 import android.service.notification.StatusBarNotification;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
+import android.view.NotificationHeaderView;
 import android.view.View;
 import android.view.ViewStub;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.LinearInterpolator;
 import android.widget.Chronometer;
 import android.widget.ImageView;
+import android.widget.RemoteViews;
 
 import com.android.systemui.R;
 import com.android.systemui.classifier.FalsingManager;
-import com.android.systemui.statusbar.notification.NotificationHeaderView;
 import com.android.systemui.statusbar.phone.NotificationGroupManager;
 import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
 import com.android.systemui.statusbar.stack.StackScrollState;
@@ -89,14 +90,12 @@
     private boolean mIsHeadsUp;
     private boolean mLastChronometerRunning = true;
     private NotificationHeaderView mNotificationHeader;
-    private ViewStub mNotificationHeaderStub;
     private ViewStub mChildrenContainerStub;
     private NotificationGroupManager mGroupManager;
     private boolean mChildrenExpanded;
     private boolean mIsSummaryWithChildren;
     private NotificationChildrenContainer mChildrenContainer;
     private ViewStub mGutsStub;
-    private boolean mHasNotificationHeader;
     private boolean mIsSystemChildExpanded;
     private boolean mIsPinned;
     private FalsingManager mFalsingManager;
@@ -105,6 +104,17 @@
     private NotificationData.Entry mEntry;
     private boolean mShowNoBackground;
     private ExpandableNotificationRow mNotificationParent;
+    private OnClickListener mExpandClickListener = new OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            if (mGroupManager.isSummaryOfGroup(mStatusBarNotification)) {
+                mGroupManager.toggleGroupExpansion(mStatusBarNotification);
+            } else {
+                setUserExpanded(!isExpanded());
+                notifyHeightChanged(true);
+            }
+        }
+    };
 
     public NotificationContentView getPrivateLayout() {
         return mPrivateLayout;
@@ -452,8 +462,8 @@
         super.onFinishInflate();
         mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
         mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
-        mPublicLayout.setContainingNotification(this);
-        mPrivateLayout.setContainingNotification(this);
+        mPrivateLayout.setExpandClickListener(mExpandClickListener);
+        mPublicLayout.setExpandClickListener(mExpandClickListener);
         mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
         mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
             @Override
@@ -464,15 +474,6 @@
                 mGutsStub = null;
             }
         });
-        mNotificationHeaderStub = (ViewStub) findViewById(R.id.notification_header_stub);
-        mNotificationHeaderStub.setOnInflateListener(new ViewStub.OnInflateListener() {
-            @Override
-            public void onInflate(ViewStub stub, View inflated) {
-                mNotificationHeader = (NotificationHeaderView) inflated;
-                mNotificationHeader.setGroupManager(mGroupManager);
-                mNotificationHeader.bind(mEntry);
-            }
-        });
         mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub);
         mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() {
 
@@ -496,6 +497,7 @@
             return;
         }
         mChildrenContainer.setVisibility(mIsSummaryWithChildren ? VISIBLE : INVISIBLE);
+        mNotificationHeader.setVisibility(mIsSummaryWithChildren ? VISIBLE : INVISIBLE);
         mPrivateLayout.setVisibility(!mIsSummaryWithChildren ? VISIBLE : INVISIBLE);
     }
 
@@ -538,7 +540,7 @@
 
     public void setExpandable(boolean expandable) {
         mExpandable = expandable;
-        mPrivateLayout.updateExpandButtons();
+        mPrivateLayout.updateExpandButtons(isExpandable());
     }
 
     /**
@@ -659,8 +661,7 @@
         if (mSensitive && mHideSensitiveForIntrinsicHeight) {
             return mRowMinHeight;
         } else if (mIsSummaryWithChildren && !mOnKeyguard) {
-            return mChildrenContainer.getIntrinsicHeight()
-                    + mNotificationHeader.getHeight();
+            return mChildrenContainer.getIntrinsicHeight();
         } else if (mIsHeadsUp) {
             if (inExpansionState) {
                 return Math.max(mMaxExpandHeight, mHeadsUpHeight);
@@ -686,13 +687,19 @@
     }
 
     private void onChildrenCountChanged() {
-        mIsSummaryWithChildren  = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
+        final boolean isSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
                 && mGroupManager.hasGroupChildren(mStatusBarNotification);
-        if (mIsSummaryWithChildren && mChildrenContainer == null) {
-            mChildrenContainerStub.inflate();
+        if (isSummaryWithChildren) {
+            if (mChildrenContainer == null) {
+                mChildrenContainerStub.inflate();
+            }
+            if (!mIsSummaryWithChildren) {
+                recreateNotificationHeader();
+            }
         }
-        mPrivateLayout.updateExpandButtons();
-        updateNotificationHeader();
+        mIsSummaryWithChildren  = isSummaryWithChildren;
+        mPrivateLayout.updateExpandButtons(isExpandable());
+        updateHeaderChildCount();
         updateChildrenVisibility(true);
     }
 
@@ -777,7 +784,7 @@
             animateShowingPublic(delay, duration);
         }
 
-        mPrivateLayout.updateExpandButtons();
+        mPrivateLayout.updateExpandButtons(isExpandable());
         updateVetoButton();
         mShowingPublicInitialized = true;
     }
@@ -818,23 +825,11 @@
         }
     }
 
-    public void updateNotificationHeader() {
-        boolean hasHeader = hasNotificationHeader();
-        if (hasHeader != mHasNotificationHeader) {
-            if (hasHeader) {
-                if (mNotificationHeader == null) {
-                    mNotificationHeaderStub.inflate();
-                }
-                mNotificationHeader.setVisibility(View.VISIBLE);
-            } else if (mNotificationHeader != null) {
-                mNotificationHeader.setVisibility(View.GONE);
-            }
-            notifyHeightChanged(true  /* needsAnimation */);
+    public void updateHeaderChildCount() {
+        if (mIsSummaryWithChildren) {
+            mNotificationHeader.setChildCount(
+                    mChildrenContainer.getNotificationChildren().size());
         }
-        if (hasHeader) {
-            mNotificationHeader.bind(mEntry);
-        }
-        mHasNotificationHeader = hasHeader;
     }
 
     public static void applyTint(View v, int color) {
@@ -883,8 +878,7 @@
     @Override
     public int getMaxContentHeight() {
         if (mIsSummaryWithChildren && !mShowingPublic) {
-            return mChildrenContainer.getMaxContentHeight()
-                    + mNotificationHeader.getHeight();
+            return mChildrenContainer.getMaxContentHeight();
         }
         NotificationContentView showingLayout = getShowingLayout();
         return showingLayout.getMaxHeight();
@@ -899,8 +893,7 @@
     @Override
     public int getMinExpandHeight() {
         if (mIsSummaryWithChildren && !mOnKeyguard) {
-            return mChildrenContainer.getMinHeight()
-                    + mNotificationHeader.getHeight();
+            return mChildrenContainer.getMinHeight();
         }
         return getMinHeight();
     }
@@ -923,6 +916,25 @@
     public void notifyContentUpdated() {
         mPublicLayout.notifyContentUpdated();
         mPrivateLayout.notifyContentUpdated();
+        if (mIsSummaryWithChildren) {
+            recreateNotificationHeader();
+        }
+    }
+
+    private void recreateNotificationHeader() {
+        final Notification.Builder builder = Notification.Builder.recoverBuilder(getContext(),
+                getStatusBarNotification().getNotification());
+        final RemoteViews header = builder.makeNotificationHeader();
+        if (mNotificationHeader == null) {
+            mNotificationHeader = (NotificationHeaderView) header.apply(getContext(), this);
+            final View expandButton = mNotificationHeader.findViewById(
+                    com.android.internal.R.id.expand_button);
+            expandButton.setVisibility(VISIBLE);
+            mNotificationHeader.setOnClickListener(mExpandClickListener);
+            addView(mNotificationHeader);
+        } else {
+            header.reapply(getContext(), mNotificationHeader);
+        }
     }
 
     public boolean isMaxExpandHeightInitialized() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 528a4af..5c41065 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -24,6 +24,7 @@
 import android.graphics.Rect;
 import android.service.notification.StatusBarNotification;
 import android.util.AttributeSet;
+import android.view.NotificationHeaderView;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewOutlineProvider;
@@ -77,7 +78,6 @@
     private boolean mShowingLegacyBackground;
     private boolean mIsChildInGroup;
     private int mSmallHeight;
-    private ExpandableNotificationRow mContainingNotification;
     private StatusBarNotification mStatusBarNotification;
     private NotificationGroupManager mGroupManager;
 
@@ -98,17 +98,7 @@
                     mRoundRectRadius);
         }
     };
-    private OnClickListener mExpandClickListener = new OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            if (mGroupManager.isSummaryOfGroup(mStatusBarNotification)) {
-                mGroupManager.toggleGroupExpansion(mStatusBarNotification);
-            } else {
-                mContainingNotification.setUserExpanded(!mContainingNotification.isExpanded());
-                mContainingNotification.notifyHeightChanged(true);
-            }
-        }
-    };
+    private OnClickListener mExpandClickListener;
 
     public NotificationContentView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -503,10 +493,6 @@
         updateSingleLineView();
     }
 
-    public void setContainingNotification(ExpandableNotificationRow notification) {
-        mContainingNotification = notification;
-    }
-
     public void setStatusBarNotification(StatusBarNotification statusBarNotification) {
         mStatusBarNotification = statusBarNotification;
         updateSingleLineView();
@@ -535,18 +521,19 @@
         mGroupManager = groupManager;
     }
 
-    public void updateExpandButtons() {
+    public void setExpandClickListener(OnClickListener expandClickListener) {
+        mExpandClickListener = expandClickListener;
+    }
+
+    public void updateExpandButtons(boolean expandable) {
         if (mExpandedChild != null) {
-            mExpandedWrapper.updateExpandability(mContainingNotification.isExpandable(),
-                    mExpandClickListener);
+            mExpandedWrapper.updateExpandability(expandable, mExpandClickListener);
         }
         if (mContractedChild != null) {
-            mContractedWrapper.updateExpandability(mContainingNotification.isExpandable(),
-                    mExpandClickListener);
+            mContractedWrapper.updateExpandability(expandable, mExpandClickListener);
         }
         if (mHeadsUpChild != null) {
-            mHeadsUpWrapper.updateExpandability(mContainingNotification.isExpandable(),
-                    mExpandClickListener);
+            mHeadsUpWrapper.updateExpandability(expandable,  mExpandClickListener);
         }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderView.java
deleted file mode 100644
index ec26cc4..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderView.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * 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
- */
-
-package com.android.systemui.statusbar.notification;
-
-import android.annotation.Nullable;
-import android.app.Notification;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.service.notification.StatusBarNotification;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.internal.util.NotificationColorUtil;
-import com.android.systemui.R;
-import com.android.systemui.statusbar.BaseStatusBar;
-import com.android.systemui.statusbar.ExpandableNotificationRow;
-import com.android.systemui.statusbar.NotificationData;
-import com.android.systemui.statusbar.phone.NotificationGroupManager;
-
-import java.util.List;
-
-/**
- * A header for a notification view
- */
-public class NotificationHeaderView extends FrameLayout {
-
-    private static final int DEFAULT_ICON_TINT_COLOR = 0xff616161;
-    private final NotificationColorUtil mNotificationColorUtil;
-    private NotificationData.Entry mNotificationEntry;
-    private ImageView mIconView;
-    private TextView mAppName;
-    private TextView mPostTime;
-    private TextView mChildCount;
-    private TextView mSubTextDivider;
-    private TextView mSubText;
-    private NotificationGroupManager mGroupManager;
-    private ImageButton mExpandButton;
-
-    public NotificationHeaderView(Context context) {
-        this(context, null);
-    }
-
-    public NotificationHeaderView(Context context, @Nullable AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public NotificationHeaderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
-        this(context, attrs, defStyleAttr, 0);
-    }
-
-    public NotificationHeaderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
-            int defStyleRes) {
-        super(context, attrs, defStyleAttr, defStyleRes);
-        mNotificationColorUtil = NotificationColorUtil.getInstance(context);
-    }
-
-    @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-        mIconView = (ImageView) findViewById(R.id.header_notification_icon);
-        mAppName = (TextView) findViewById(R.id.app_name_text);
-        mSubTextDivider = (TextView) findViewById(R.id.app_title_sub_text_divider);
-        mSubText = (TextView) findViewById(R.id.title_sub_text);
-        mPostTime = (TextView) findViewById(R.id.post_time);
-        mChildCount = (TextView) findViewById(R.id.number_of_children);
-        mExpandButton = (ImageButton) findViewById(R.id.notification_expand_button);
-        mExpandButton.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                mGroupManager.toggleGroupExpansion(mNotificationEntry.notification);
-            }
-        });
-    }
-
-    public void bind(NotificationData.Entry notificationEntry) {
-        mNotificationEntry = notificationEntry;
-        StatusBarNotification sbn = notificationEntry.notification;
-        int notificationColor = getNotificationColor(sbn);
-        bindIcon(notificationColor);
-        bindNumber(notificationColor);
-        bindAppName(sbn);
-        bindSubText();
-        bindTime(sbn);
-        bindExpandButton(sbn);
-    }
-
-    private void bindExpandButton(StatusBarNotification sbn) {
-        boolean summaryOfGroup = mGroupManager.isSummaryOfGroup(sbn);
-        mExpandButton.setVisibility(summaryOfGroup ? VISIBLE : GONE);
-    }
-
-    private void bindSubText() {
-        List<ExpandableNotificationRow> notificationChildren =
-                mNotificationEntry.row.getNotificationChildren();
-        CharSequence subText = null;
-        if (notificationChildren != null) {
-            for (int i = 0; i < notificationChildren.size(); i++) {
-                ExpandableNotificationRow row = notificationChildren.get(i);
-                CharSequence rowSubText = row.getSubText();
-                if (TextUtils.isEmpty(rowSubText)
-                        || (subText != null && !subText.equals(rowSubText))) {
-                    // The children don't have a common subText
-                    subText = null;
-                    break;
-                } else if (subText == null) {
-                    subText = rowSubText;
-                }
-            }
-        };
-        setSubText(subText);
-    }
-
-    private void setSubText(CharSequence subText) {
-        boolean goneInHeader = TextUtils.isEmpty(subText);
-        if (goneInHeader) {
-            mSubText.setVisibility(GONE);
-            mSubTextDivider.setVisibility(GONE);
-        } else {
-            mSubText.setVisibility(VISIBLE);
-            mSubText.setText(subText);
-            mSubTextDivider.setVisibility(VISIBLE);
-        }
-        List<ExpandableNotificationRow> notificationChildren =
-                mNotificationEntry.row.getNotificationChildren();
-        if (notificationChildren != null) {
-            for (int i = 0; i < notificationChildren.size(); i++) {
-                ExpandableNotificationRow row = notificationChildren.get(i);
-                row.setContentSubTextVisible(goneInHeader);
-            }
-        }
-    }
-
-    private int getNotificationColor(StatusBarNotification sbn) {
-        int color = sbn.getNotification().color;
-        if (color == Notification.COLOR_DEFAULT) {
-            return DEFAULT_ICON_TINT_COLOR;
-        }
-        return color;
-    }
-
-    private void bindNumber(int notificationColor) {
-        int numberOfNotificationChildren = mNotificationEntry.row.getNumberOfNotificationChildren();
-        boolean visible = numberOfNotificationChildren > 0;
-        if (visible) {
-            mChildCount.setText("(" + numberOfNotificationChildren + ")");
-            mChildCount.setTextColor(notificationColor);
-            mChildCount.setVisibility(VISIBLE);
-        } else {
-            mChildCount.setVisibility(GONE);
-        }
-    }
-
-    private void bindTime(StatusBarNotification sbn) {
-
-    }
-
-    private void bindIcon(int notificationColor) {
-        Drawable icon = mNotificationEntry.icon.getDrawable().getConstantState()
-                .newDrawable(getResources()).mutate();
-        mIconView.setImageDrawable(icon);
-        if (NotificationUtils.isGrayscale(mIconView, mNotificationColorUtil)) {
-            icon.setTint(notificationColor);
-        }
-    }
-
-    private void bindAppName(StatusBarNotification sbn) {
-        PackageManager pmUser = BaseStatusBar.getPackageManagerForUser(getContext(),
-                sbn.getUser().getIdentifier());
-        final String pkg = sbn.getPackageName();
-        String appname = pkg;
-        try {
-            final ApplicationInfo info = pmUser.getApplicationInfo(pkg,
-                    PackageManager.GET_UNINSTALLED_PACKAGES
-                            | PackageManager.GET_DISABLED_COMPONENTS);
-            if (info != null) {
-                appname = String.valueOf(pmUser.getApplicationLabel(info));
-
-            }
-        } catch (PackageManager.NameNotFoundException e) {
-            // app is gone, just show package name
-        }
-        mAppName.setText(appname);
-    }
-
-    public void setGroupManager(NotificationGroupManager groupManager) {
-        mGroupManager = groupManager;
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index fbe9730..08da0d3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -92,8 +92,6 @@
         if (group.children.isEmpty()) {
             if (group.summary == null) {
                 mGroupMap.remove(groupKey);
-            } else if (!group.expanded) {
-                group.summary.row.updateNotificationHeader();
             }
         }
     }
@@ -109,9 +107,6 @@
         }
         if (notif.isGroupChild()) {
             group.children.add(added);
-            if (group.summary != null && group.children.size() == 1 && !group.expanded) {
-                group.summary.row.updateNotificationHeader();
-            }
         } else {
             group.summary = added;
             group.expanded = added.row.areChildrenExpanded();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index c9ebc84..77a9871 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -78,7 +78,7 @@
         mNotificationAppearDistance = getResources().getDimensionPixelSize(
                 R.dimen.notification_appear_distance);
         mNotificationHeaderHeight = getResources().getDimensionPixelSize(
-                R.dimen.notification_header_height);
+                com.android.internal.R.dimen.notification_header_height);
         mHeaderTopPaddingSubstraction = 2 * getResources().getDisplayMetrics().density;
         mCollapsedBottompadding = 10 * getResources().getDisplayMetrics().density;
         mHybridViewManager = new HybridNotificationViewManager(getContext(), this);
@@ -246,7 +246,7 @@
      *         in @param maxAllowedVisibleChildren
      */
     private int getIntrinsicHeight(float maxAllowedVisibleChildren) {
-        int intrinsicHeight = 0;
+        int intrinsicHeight = mNotificationHeaderHeight;;
         int visibleChildren = 0;
         int childCount = mChildren.size();
         for (int i = 0; i < childCount; i++) {