From 2063ebd990fdbea3f273a5c4fef3b739852c51c5 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 5 Sep 2017 15:09:43 -0700 Subject: [PATCH] Adjust notification paddings - Reduce main notification height - Increase header height and center "Notifications" - Footer has short height when empty to serve as padding Bug: 65215656 Change-Id: I691d176628b0b51e8d9af030084b8c29837778dc --- res/layout/notification.xml | 4 ++-- res/layout/notification_main.xml | 4 ++-- res/values/dimens.xml | 6 ++++-- .../notification/NotificationFooterLayout.java | 6 ++++-- .../notification/NotificationItemView.java | 14 ++++++++++++-- .../launcher3/popup/PopupContainerWithArrow.java | 5 +++-- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/res/layout/notification.xml b/res/layout/notification.xml index 4a02aa169c..1eebb434ba 100644 --- a/res/layout/notification.xml +++ b/res/layout/notification.xml @@ -49,7 +49,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" - android:gravity="bottom" + android:gravity="center_vertical" android:text="@string/notifications_header" android:textSize="@dimen/notification_header_text_size" android:textColor="?android:attr/textColorPrimary" /> @@ -58,7 +58,7 @@ android:layout_width="@dimen/notification_icon_size" android:layout_height="match_parent" android:layout_gravity="end" - android:gravity="bottom|center_horizontal" + android:gravity="center" android:textSize="@dimen/notification_header_count_text_size" android:fontFamily="sans-serif-medium" android:textColor="?android:attr/textColorPrimary" /> diff --git a/res/layout/notification_main.xml b/res/layout/notification_main.xml index f681e8b06d..f94face1b1 100644 --- a/res/layout/notification_main.xml +++ b/res/layout/notification_main.xml @@ -31,7 +31,7 @@ android:background="?attr/popupColorPrimary" android:paddingStart="@dimen/notification_padding_start" android:paddingEnd="@dimen/notification_main_text_padding_end" - android:paddingBottom="16dp"> + android:paddingBottom="14dp"> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 3f6efd794d..b1f9d63797 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -214,9 +214,11 @@ 12dp 15dp - 32dp - 96dp + 36dp + 84dp 32dp + + 6dp 13sp 12sp 16sp diff --git a/src/com/android/launcher3/notification/NotificationFooterLayout.java b/src/com/android/launcher3/notification/NotificationFooterLayout.java index 2455eabead..ad07d37bd5 100644 --- a/src/com/android/launcher3/notification/NotificationFooterLayout.java +++ b/src/com/android/launcher3/notification/NotificationFooterLayout.java @@ -200,7 +200,9 @@ public class NotificationFooterLayout extends FrameLayout { PopupContainerWithArrow popup = PopupContainerWithArrow.getOpen( Launcher.getLauncher(getContext())); if (popup != null) { - Animator collapseFooter = popup.reduceNotificationViewHeight(getHeight(), + final int newHeight = getResources().getDimensionPixelSize( + R.dimen.notification_empty_footer_height); + Animator collapseFooter = popup.reduceNotificationViewHeight(getHeight() - newHeight, getResources().getInteger(R.integer.config_removeNotificationViewDuration)); collapseFooter.addListener(new AnimatorListenerAdapter() { @Override @@ -208,7 +210,7 @@ public class NotificationFooterLayout extends FrameLayout { ((ViewGroup) getParent()).findViewById(R.id.divider).setVisibility(GONE); // Keep view around because gutter is aligned to it, but remove height to // both hide the view and keep calculations correct for last dismissal. - getLayoutParams().height = 0; + getLayoutParams().height = newHeight; requestLayout(); } }); diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java index 78c64d7dad..ab94c32d01 100644 --- a/src/com/android/launcher3/notification/NotificationItemView.java +++ b/src/com/android/launcher3/notification/NotificationItemView.java @@ -90,9 +90,19 @@ public class NotificationItemView extends PopupItemView implements LogContainerP return mMainView; } + /** + * This method is used to calculate the height to remove when dismissing the last notification. + * We subtract the height of the footer in this case since the footer should be gone or in the + * process of being removed. + * @return The height of the entire notification item, minus the footer if it still exists. + */ public int getHeightMinusFooter() { - int footerHeight = mFooter.getParent() == null ? 0 : mFooter.getHeight(); - return getHeight() - footerHeight; + if (mFooter.getParent() == null) { + return getHeight(); + } + int excessFooterHeight = mFooter.getHeight() - getResources().getDimensionPixelSize( + R.dimen.notification_empty_footer_height); + return getHeight() - excessFooterHeight; } public Animator animateHeightRemoval(int heightToRemove, boolean shouldRemoveFromTop) { diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index c3e2d8b89a..8441598cf7 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -275,8 +275,9 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra if (itemTypeToPopulate == PopupPopulator.Item.NOTIFICATION) { mNotificationItemView = (NotificationItemView) item; boolean notificationFooterHasIcons = numNotifications > 1; - int footerHeight = notificationFooterHasIcons ? - res.getDimensionPixelSize(R.dimen.notification_footer_height) : 0; + int footerHeight = res.getDimensionPixelSize( + notificationFooterHasIcons ? R.dimen.notification_footer_height + : R.dimen.notification_empty_footer_height); item.findViewById(R.id.footer).getLayoutParams().height = footerHeight; if (notificationFooterHasIcons) { mNotificationItemView.findViewById(R.id.divider).setVisibility(VISIBLE);