Fixed the paddings in inbox style to match the rest of the templates
Change-Id: Ib7701ac29d5f8a123441fbf6d95a5b0b9cadfb4e
Fixes: 27998488
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 39f8e19..7230a91 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -4822,33 +4822,37 @@
contentView.setViewVisibility(rowId, View.GONE);
}
- final boolean largeText =
- mBuilder.mContext.getResources().getConfiguration().fontScale > 1f;
- final float subTextSize = mBuilder.mContext.getResources().getDimensionPixelSize(
- R.dimen.notification_subtext_size);
int i=0;
- final float density = mBuilder.mContext.getResources().getDisplayMetrics().density;
- int topPadding = (int) (5 * density);
- int bottomPadding = mBuilder.mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.notification_content_margin_bottom);
+ int topPadding = mBuilder.mContext.getResources().getDimensionPixelSize(
+ R.dimen.notification_inbox_item_top_padding);
boolean first = true;
- while (i < mTexts.size() && i < rowIds.length) {
+ int onlyViewId = 0;
+ int maxRows = rowIds.length;
+ if (mBuilder.mActions.size() > 0) {
+ maxRows--;
+ }
+ while (i < mTexts.size() && i < maxRows) {
CharSequence str = mTexts.get(i);
- if (str != null && !str.equals("")) {
+ if (!TextUtils.isEmpty(str)) {
contentView.setViewVisibility(rowIds[i], View.VISIBLE);
contentView.setTextViewText(rowIds[i], mBuilder.processLegacyText(str));
- if (largeText) {
- contentView.setTextViewTextSize(rowIds[i], TypedValue.COMPLEX_UNIT_PX,
- subTextSize);
- }
- contentView.setViewPadding(rowIds[i], 0, topPadding, 0,
- i == rowIds.length - 1 || i == mTexts.size() - 1 ? bottomPadding : 0);
+ contentView.setViewPadding(rowIds[i], 0, topPadding, 0, 0);
handleInboxImageMargin(contentView, rowIds[i], first);
+ if (first) {
+ onlyViewId = rowIds[i];
+ } else {
+ onlyViewId = 0;
+ }
first = false;
}
i++;
}
-
+ if (onlyViewId != 0) {
+ // We only have 1 entry, lets make it look like the normal Text of a Bigtext
+ topPadding = mBuilder.mContext.getResources().getDimensionPixelSize(
+ R.dimen.notification_text_margin_top);
+ contentView.setViewPadding(onlyViewId, 0, topPadding, 0, 0);
+ }
return contentView;
}
diff --git a/core/res/res/layout/notification_template_material_big_text.xml b/core/res/res/layout/notification_template_material_big_text.xml
index 3638b20..71600ef 100644
--- a/core/res/res/layout/notification_template_material_big_text.xml
+++ b/core/res/res/layout/notification_template_material_big_text.xml
@@ -47,7 +47,7 @@
<com.android.internal.widget.ImageFloatingTextView android:id="@+id/big_text"
android:layout_width="match_parent"
android:layout_height="0dp"
- android:layout_marginTop="0.5dp"
+ android:layout_marginTop="@dimen/notification_text_margin_top"
android:paddingBottom="@dimen/notification_content_margin_bottom"
android:textAppearance="@style/TextAppearance.Material.Notification"
android:singleLine="false"
diff --git a/core/res/res/layout/notification_template_material_inbox.xml b/core/res/res/layout/notification_template_material_inbox.xml
index ce9acda..0e93d0b 100644
--- a/core/res/res/layout/notification_template_material_inbox.xml
+++ b/core/res/res/layout/notification_template_material_inbox.xml
@@ -37,6 +37,7 @@
android:layout_gravity="top"
android:paddingStart="@dimen/notification_content_margin_start"
android:paddingEnd="@dimen/notification_content_margin_end"
+ android:paddingBottom="@dimen/notification_content_margin_bottom"
android:minHeight="@dimen/notification_min_content_height"
android:clipToPadding="false"
android:orientation="vertical"
diff --git a/core/res/res/layout/notification_template_text.xml b/core/res/res/layout/notification_template_text.xml
index a318bda..20c2896 100644
--- a/core/res/res/layout/notification_template_text.xml
+++ b/core/res/res/layout/notification_template_text.xml
@@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
- android:layout_marginTop="0.5dp"
+ android:layout_marginTop="@dimen/notification_text_margin_top"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:gravity="top"
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index ad7b7cc..5446d4c 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -290,6 +290,12 @@
<!-- Padding for notification icon when drawn with circle around it -->
<dimen name="notification_large_icon_circle_padding">11dp</dimen>
+ <!-- The margin on top of the text of the notification -->
+ <dimen name="notification_text_margin_top">0.5dp</dimen>
+
+ <!-- The padding on top of inbox style elements -->
+ <dimen name="notification_inbox_item_top_padding">5dp</dimen>
+
<!-- Size of the profile badge for notifications -->
<dimen name="notification_badge_size">12dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index adeaa63..df298c9 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2546,6 +2546,9 @@
<java-symbol type="dimen" name="notification_messaging_spacing" />
+ <java-symbol type="dimen" name="notification_text_margin_top" />
+ <java-symbol type="dimen" name="notification_inbox_item_top_padding" />
+
<!-- WallpaperManager config -->
<java-symbol type="string" name="config_wallpaperCropperPackage" />