From 07c8017bc27f1cbf34e29f27e08ba4e7f8f10d16 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 21 Apr 2016 16:40:47 -0700 Subject: [PATCH] Fixed the paddings in inbox style to match the rest of the templates Change-Id: Ib7701ac29d5f8a123441fbf6d95a5b0b9cadfb4e Fixes: 27998488 --- core/java/android/app/Notification.java | 38 ++++++++++--------- ...otification_template_material_big_text.xml | 2 +- .../notification_template_material_inbox.xml | 1 + .../res/layout/notification_template_text.xml | 2 +- core/res/res/values/dimens.xml | 6 +++ core/res/res/values/symbols.xml | 3 ++ 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 39f8e190aeab0..7230a9195d286 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4822,33 +4822,37 @@ public class Notification implements Parcelable 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 3638b20d864a9..71600ef7b1345 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 @@ 11dp + + 0.5dp + + + 5dp + 12dp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index adeaa63900b6b..df298c9601aa5 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2546,6 +2546,9 @@ + + +