diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 061e5ff35f553..864af3d4ae4da 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -7526,9 +7526,11 @@ public class Notification implements Parcelable p, bindResult); addExtras(mBuilder.mN.extras); - // also update the end margin if there is an image - contentView.setViewLayoutMarginEnd(R.id.notification_messaging, - bindResult.getIconMarginEnd()); + if (!CONVERSATION_LAYOUT_ENABLED) { + // also update the end margin if there is an image + contentView.setViewLayoutMarginEnd(R.id.notification_messaging, + bindResult.getIconMarginEnd()); + } contentView.setInt(R.id.status_bar_latest_event_content, "setLayoutColor", mBuilder.isColorized(p) ? mBuilder.getPrimaryTextColor(p) : mBuilder.resolveContrastColor(p)); diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java index 714639d49406d..73da6007156a6 100644 --- a/core/java/com/android/internal/widget/ConversationLayout.java +++ b/core/java/com/android/internal/widget/ConversationLayout.java @@ -122,6 +122,11 @@ public class ConversationLayout extends FrameLayout private CharSequence mFallbackChatName; private CharSequence mFallbackGroupChatName; private CharSequence mConversationTitle; + private int mNotificationHeaderExpandedPadding; + private View mConversationHeader; + private View mContentContainer; + private boolean mExpandable = true; + private int mContentMarginEnd; public ConversationLayout(@NonNull Context context) { super(context); @@ -166,12 +171,18 @@ public class ConversationLayout extends FrameLayout }); mConversationText = findViewById(R.id.conversation_text); mExpandButtonContainer = findViewById(R.id.expand_button_container); + mConversationHeader = findViewById(R.id.conversation_header); + mContentContainer = findViewById(R.id.notification_action_list_margin_target); mExpandButtonAndContentContainer = findViewById(R.id.expand_button_and_content_container); mExpandButton = findViewById(R.id.expand_button); mExpandButtonExpandedTopMargin = getResources().getDimensionPixelSize( R.dimen.conversation_expand_button_top_margin_expanded); mExpandButtonExpandedSize = getResources().getDimensionPixelSize( R.dimen.conversation_expand_button_expanded_size); + mNotificationHeaderExpandedPadding = getResources().getDimensionPixelSize( + R.dimen.conversation_header_expanded_padding_end); + mContentMarginEnd = getResources().getDimensionPixelSize( + R.dimen.notification_content_margin_end); mBadgedSideMargins = getResources().getDimensionPixelSize( R.dimen.conversation_badge_side_margin); mIconSizeBadged = getResources().getDimensionPixelSize( @@ -207,6 +218,7 @@ public class ConversationLayout extends FrameLayout mIsCollapsed = isCollapsed; mMessagingLinearLayout.setMaxDisplayedLines(isCollapsed ? 1 : Integer.MAX_VALUE); updateExpandButton(); + updateContentPaddings(); } @RemotableViewMethod @@ -852,10 +864,39 @@ public class ConversationLayout extends FrameLayout mExpandButton.setLayoutParams(layoutParams); mExpandButtonContainer.setContentDescription(mContext.getText(contentDescriptionId)); + } + private void updateContentPaddings() { + + // Let's make sure the conversation header can't run into the expand button when we're + // collapsed and update the paddings of the content + int headerPaddingEnd; + int contentPaddingEnd; + if (!mExpandable) { + headerPaddingEnd = 0; + contentPaddingEnd = mContentMarginEnd; + } else if (mIsCollapsed) { + headerPaddingEnd = 0; + contentPaddingEnd = 0; + } else { + headerPaddingEnd = mNotificationHeaderExpandedPadding; + contentPaddingEnd = mContentMarginEnd; + } + mConversationHeader.setPaddingRelative( + mConversationHeader.getPaddingStart(), + mConversationHeader.getPaddingTop(), + headerPaddingEnd, + mConversationHeader.getPaddingBottom()); + + mContentContainer.setPaddingRelative( + mContentContainer.getPaddingStart(), + mContentContainer.getPaddingTop(), + contentPaddingEnd, + mContentContainer.getPaddingBottom()); } public void updateExpandability(boolean expandable, @Nullable OnClickListener onClickListener) { + mExpandable = expandable; if (expandable) { mExpandButtonContainer.setVisibility(VISIBLE); mExpandButtonContainer.setOnClickListener(onClickListener); @@ -863,5 +904,6 @@ public class ConversationLayout extends FrameLayout // TODO: handle content paddings to end of layout mExpandButtonContainer.setVisibility(GONE); } + updateContentPaddings(); } } diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index dc52e979a3102..2348deeed7fb3 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -93,9 +93,10 @@ android:clipChildren="false" android:clipToPadding="false"> - @@ -163,12 +164,12 @@ android:id="@+id/notification_messaging" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="40dp" + android:layout_marginTop="2dp" android:spacing="@dimen/notification_messaging_spacing" android:clipToPadding="false" android:clipChildren="false" /> - + diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index bddd5d8853463..15ef09c4277a0 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -699,6 +699,9 @@ 5dp + + 38dp + 12dp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 2f9d38c4fe2bd..4c0dd8dd3e4ee 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3901,6 +3901,7 @@ +