Adapted the measuring of notification content view

We are now measuring all notifications content views
with AT_MOST but with an upperboundary. This allows us
to put custom views inside our normal views and still not
blow up the small size. Also adapted the dimens not to
clamp the templates

Bug: 24866646
Change-Id: If9053d84a9d91e6bc9964f64b170e3c3260a807d
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 7422902..fb58ba1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -240,7 +240,6 @@
                 != com.android.internal.R.id.status_bar_latest_event_content;
         int headsUpheight = headsUpCustom && beforeN ? mMaxHeadsUpHeightLegacy
                 : mMaxHeadsUpHeight;
-        mMaxViewHeight = mNotificationMaxHeight;
         mPrivateLayout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight);
         mPublicLayout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight);
     }
@@ -542,16 +541,23 @@
     }
 
     private void initDimens() {
-        mNotificationMinHeightLegacy =  getResources().getDimensionPixelSize(
-                R.dimen.notification_min_height_legacy);
-        mNotificationMinHeight =  getResources().getDimensionPixelSize(
-                R.dimen.notification_min_height);
-        mNotificationMaxHeight =  getResources().getDimensionPixelSize(
-                R.dimen.notification_max_height);
-        mMaxHeadsUpHeightLegacy =  getResources().getDimensionPixelSize(
+        mNotificationMinHeightLegacy = getFontScaledHeight(R.dimen.notification_min_height_legacy);
+        mNotificationMinHeight = getFontScaledHeight(R.dimen.notification_min_height);
+        mNotificationMaxHeight = getFontScaledHeight(R.dimen.notification_max_height);
+        mMaxHeadsUpHeightLegacy = getFontScaledHeight(
                 R.dimen.notification_max_heads_up_height_legacy);
-        mMaxHeadsUpHeight =  getResources().getDimensionPixelSize(
-                R.dimen.notification_max_heads_up_height);
+        mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height);
+    }
+
+    /**
+     * @param dimenId the dimen to look up
+     * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp
+     */
+    private int getFontScaledHeight(int dimenId) {
+        int dimensionPixelSize = getResources().getDimensionPixelSize(dimenId);
+        float factor = Math.max(1.0f, getResources().getDisplayMetrics().scaledDensity /
+                getResources().getDisplayMetrics().density);
+        return (int) (dimensionPixelSize * factor);
     }
 
     /**
@@ -561,7 +567,6 @@
     public void reset() {
         super.reset();
         final boolean wasExpanded = isExpanded();
-        mMaxViewHeight = 0;
         mExpandable = false;
         mHasUserChangedExpansion = false;
         mUserLocked = false;