Create separate dimensions for the notificaitons and notification rows.
Use notification heights on layouts internal to the notificaitons.
Use row heights where padding needs to be protected, on row layout decisions.
Clean up values-xhdpi/dimens.xml since there is no longer a values-hdpi/dimens.xml.

Bug: 6475098
Bug: 6489095
Change-Id: I44750574c6e23336585a432a38c5f1ba183b6cbc
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index bc144bb..4cff67b 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -48,7 +48,7 @@
             android:id="@+id/latestItems"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            systemui:rowHeight="@dimen/notification_height"
+            systemui:rowHeight="@dimen/notification_row_min_height"
             />
     </ScrollView>
 
@@ -68,4 +68,4 @@
 
     </com.android.systemui.statusbar.phone.CloseDragHandle>
 
-</FrameLayout><!-- end of sliding panel -->
\ No newline at end of file
+</FrameLayout><!-- end of sliding panel -->
diff --git a/packages/SystemUI/res/layout/system_bar_notification_panel.xml b/packages/SystemUI/res/layout/system_bar_notification_panel.xml
index 42af147..5579505 100644
--- a/packages/SystemUI/res/layout/system_bar_notification_panel.xml
+++ b/packages/SystemUI/res/layout/system_bar_notification_panel.xml
@@ -77,7 +77,7 @@
                     android:clickable="true"
                     android:focusable="true"
                     android:descendantFocusability="afterDescendants"
-                    systemui:rowHeight="@dimen/notification_height"
+                    systemui:rowHeight="@dimen/notification_row_min_height"
                     />
             </ScrollView>
         </LinearLayout>
diff --git a/packages/SystemUI/res/values-xhdpi/dimens.xml b/packages/SystemUI/res/values-xhdpi/dimens.xml
deleted file mode 100644
index 303841a..0000000
--- a/packages/SystemUI/res/values-xhdpi/dimens.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2011, 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.
-*/
--->
-<resources>
-    <!-- thickness (height) of each notification row, including any separators or padding -->
-    <!-- note: this is the same value as in values/dimens.xml; the value is overridden in
-         values-hdpi/dimens.xml and so we need to re-assert the general value here -->
-    <dimen name="notification_height">68dp</dimen>
-
-    <!-- thickness (height) of dividers between each notification row -->
-    <!-- same as in values/dimens.xml; see note at notification_height -->
-    <dimen name="notification_divider_height">2dp</dimen>
-</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index f548166..9042045 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -49,18 +49,21 @@
          reducing false presses on navbar buttons; approx 2mm -->
     <dimen name="navigation_bar_deadzone_size">12dp</dimen>
 
-    <!-- thickness (height) of each 1U notification row plus glow, padding, etc -->
-    <dimen name="notification_height">72dp</dimen>
-
     <!-- Height of notification icons in the status bar -->
     <dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>
 
-    <!-- Height of a small notification in the status bar plus glow, padding, etc -->
-    <dimen name="notification_min_height">72dp</dimen>
+    <!-- Height of a small notification in the status bar -->
+    <dimen name="notification_min_height">64dp</dimen>
 
     <!-- Height of a large notification in the status bar -->
     <dimen name="notification_max_height">256dp</dimen>
 
+    <!-- Height of a small notification in the status bar plus glow, padding, etc -->
+    <dimen name="notification_row_min_height">72dp</dimen>
+
+    <!-- Height of a large notification in the status bar plus glow, padding, etc -->
+    <dimen name="notification_row_max_height">260dp</dimen>
+
     <!-- size at which Notification icons will be drawn in the status bar -->
     <dimen name="status_bar_icon_drawing_size">18dip</dimen>
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index db4079a..4b223dd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -478,7 +478,7 @@
 
     protected  boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) {
         int rowHeight =
-                mContext.getResources().getDimensionPixelSize(R.dimen.notification_height);
+                mContext.getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
         int minHeight =
                 mContext.getResources().getDimensionPixelSize(R.dimen.notification_min_height);
         int maxHeight =
@@ -498,7 +498,6 @@
         // for blaming (see SwipeHelper.setLongPressListener)
         row.setTag(sbn.pkg);
 
-        ViewGroup.LayoutParams lp = row.getLayoutParams();
         workAroundBadLayerDrawableOpacity(row);
         View vetoButton = updateNotificationVetoButton(row, sbn);
         vetoButton.setContentDescription(mContext.getString(
@@ -510,13 +509,6 @@
         ViewGroup content = (ViewGroup)row.findViewById(R.id.content);
         ViewGroup adaptive = (ViewGroup)row.findViewById(R.id.adaptive);
 
-        // Ensure that R.id.content is properly set to 64dp high if 1U
-        lp = content.getLayoutParams();
-        if (large == null) {
-            lp.height = minHeight;
-        }
-        content.setLayoutParams(lp);
-
         content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
 
         PendingIntent contentIntent = sbn.notification.contentIntent;
@@ -557,7 +549,7 @@
                 SizeAdaptiveLayout.LayoutParams params =
                         new SizeAdaptiveLayout.LayoutParams(expandedLarge.getLayoutParams());
                 params.minHeight = minHeight+1;
-                params.maxHeight = SizeAdaptiveLayout.LayoutParams.UNBOUNDED;
+                params.maxHeight = maxHeight;
                 adaptive.addView(expandedLarge, params);
             }
             row.setDrawingCacheEnabled(true);
@@ -724,20 +716,18 @@
     }
 
     protected boolean expandView(NotificationData.Entry entry, boolean expand) {
-        if (entry.expandable()) {
-            int rowHeight =
-                    mContext.getResources().getDimensionPixelSize(R.dimen.notification_height);
-            ViewGroup.LayoutParams lp = entry.row.getLayoutParams();
-            if (expand) {
-                lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
-            } else {
-                lp.height = rowHeight;
-            }
-            entry.row.setLayoutParams(lp);
-            return expand;
+        int rowHeight =
+                mContext.getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
+        ViewGroup.LayoutParams lp = entry.row.getLayoutParams();
+        if (entry.expandable() && expand) {
+            if (DEBUG) Slog.d(TAG, "setting expanded row height to WRAP_CONTENT");
+            lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
         } else {
-            return false;
+            if (DEBUG) Slog.d(TAG, "setting collapsed row height to " + rowHeight);
+            lp.height = rowHeight;
         }
+        entry.row.setLayoutParams(lp);
+        return expand;
     }
 
     protected void updateExpansionStates() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
index 0fe7a0a..f41d99c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -101,8 +101,8 @@
         float densityScale = getResources().getDisplayMetrics().density;
         float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
         mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
-        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
-        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
+        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
+        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
         mExpandHelper = new ExpandHelper(mContext, this, minHeight, maxHeight);
     }