Merge "Fixed various paddings of the messaging layout" into rvc-dev

This commit is contained in:
Selim Cinek
2020-03-16 19:46:09 +00:00
committed by Android (Google) Code Review
5 changed files with 55 additions and 6 deletions

View File

@@ -7526,9 +7526,11 @@ public class Notification implements Parcelable
p, p,
bindResult); bindResult);
addExtras(mBuilder.mN.extras); addExtras(mBuilder.mN.extras);
// also update the end margin if there is an image if (!CONVERSATION_LAYOUT_ENABLED) {
contentView.setViewLayoutMarginEnd(R.id.notification_messaging, // also update the end margin if there is an image
bindResult.getIconMarginEnd()); contentView.setViewLayoutMarginEnd(R.id.notification_messaging,
bindResult.getIconMarginEnd());
}
contentView.setInt(R.id.status_bar_latest_event_content, "setLayoutColor", contentView.setInt(R.id.status_bar_latest_event_content, "setLayoutColor",
mBuilder.isColorized(p) ? mBuilder.getPrimaryTextColor(p) mBuilder.isColorized(p) ? mBuilder.getPrimaryTextColor(p)
: mBuilder.resolveContrastColor(p)); : mBuilder.resolveContrastColor(p));

View File

@@ -122,6 +122,11 @@ public class ConversationLayout extends FrameLayout
private CharSequence mFallbackChatName; private CharSequence mFallbackChatName;
private CharSequence mFallbackGroupChatName; private CharSequence mFallbackGroupChatName;
private CharSequence mConversationTitle; private CharSequence mConversationTitle;
private int mNotificationHeaderExpandedPadding;
private View mConversationHeader;
private View mContentContainer;
private boolean mExpandable = true;
private int mContentMarginEnd;
public ConversationLayout(@NonNull Context context) { public ConversationLayout(@NonNull Context context) {
super(context); super(context);
@@ -166,12 +171,18 @@ public class ConversationLayout extends FrameLayout
}); });
mConversationText = findViewById(R.id.conversation_text); mConversationText = findViewById(R.id.conversation_text);
mExpandButtonContainer = findViewById(R.id.expand_button_container); 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); mExpandButtonAndContentContainer = findViewById(R.id.expand_button_and_content_container);
mExpandButton = findViewById(R.id.expand_button); mExpandButton = findViewById(R.id.expand_button);
mExpandButtonExpandedTopMargin = getResources().getDimensionPixelSize( mExpandButtonExpandedTopMargin = getResources().getDimensionPixelSize(
R.dimen.conversation_expand_button_top_margin_expanded); R.dimen.conversation_expand_button_top_margin_expanded);
mExpandButtonExpandedSize = getResources().getDimensionPixelSize( mExpandButtonExpandedSize = getResources().getDimensionPixelSize(
R.dimen.conversation_expand_button_expanded_size); 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( mBadgedSideMargins = getResources().getDimensionPixelSize(
R.dimen.conversation_badge_side_margin); R.dimen.conversation_badge_side_margin);
mIconSizeBadged = getResources().getDimensionPixelSize( mIconSizeBadged = getResources().getDimensionPixelSize(
@@ -207,6 +218,7 @@ public class ConversationLayout extends FrameLayout
mIsCollapsed = isCollapsed; mIsCollapsed = isCollapsed;
mMessagingLinearLayout.setMaxDisplayedLines(isCollapsed ? 1 : Integer.MAX_VALUE); mMessagingLinearLayout.setMaxDisplayedLines(isCollapsed ? 1 : Integer.MAX_VALUE);
updateExpandButton(); updateExpandButton();
updateContentPaddings();
} }
@RemotableViewMethod @RemotableViewMethod
@@ -852,10 +864,39 @@ public class ConversationLayout extends FrameLayout
mExpandButton.setLayoutParams(layoutParams); mExpandButton.setLayoutParams(layoutParams);
mExpandButtonContainer.setContentDescription(mContext.getText(contentDescriptionId)); 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) { public void updateExpandability(boolean expandable, @Nullable OnClickListener onClickListener) {
mExpandable = expandable;
if (expandable) { if (expandable) {
mExpandButtonContainer.setVisibility(VISIBLE); mExpandButtonContainer.setVisibility(VISIBLE);
mExpandButtonContainer.setOnClickListener(onClickListener); mExpandButtonContainer.setOnClickListener(onClickListener);
@@ -863,5 +904,6 @@ public class ConversationLayout extends FrameLayout
// TODO: handle content paddings to end of layout // TODO: handle content paddings to end of layout
mExpandButtonContainer.setVisibility(GONE); mExpandButtonContainer.setVisibility(GONE);
} }
updateContentPaddings();
} }
} }

View File

@@ -93,9 +93,10 @@
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false"> android:clipToPadding="false">
<!--TODO: move this into a separate layout and share logic with the header to bring back app opps etc--> <!--TODO: move this into a separate layout and share logic with the header to bring back app opps etc-->
<FrameLayout <com.android.internal.widget.RemeasuringLinearLayout
android:id="@+id/notification_action_list_margin_target" android:id="@+id/notification_action_list_margin_target"
android:layout_width="0dp" android:layout_width="0dp"
android:orientation="vertical"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"> android:layout_weight="1">
@@ -163,12 +164,12 @@
android:id="@+id/notification_messaging" android:id="@+id/notification_messaging"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="40dp" android:layout_marginTop="2dp"
android:spacing="@dimen/notification_messaging_spacing" android:spacing="@dimen/notification_messaging_spacing"
android:clipToPadding="false" android:clipToPadding="false"
android:clipChildren="false" android:clipChildren="false"
/> />
</FrameLayout> </com.android.internal.widget.RemeasuringLinearLayout>
<!-- Unread Count --> <!-- Unread Count -->
<!-- <TextView /> --> <!-- <TextView /> -->

View File

@@ -699,6 +699,9 @@
<!-- margin on the top when the icon is centered for group conversations --> <!-- margin on the top when the icon is centered for group conversations -->
<dimen name="conversation_icon_margin_top_centered">5dp</dimen> <dimen name="conversation_icon_margin_top_centered">5dp</dimen>
<!-- The padding of the conversation header when expanded. This is calculated from the expand button size + notification_content_margin_end -->
<dimen name="conversation_header_expanded_padding_end">38dp</dimen>
<!-- margin at the end of messaging group icons when not conversations --> <!-- margin at the end of messaging group icons when not conversations -->
<dimen name="messaging_layout_margin_end">12dp</dimen> <dimen name="messaging_layout_margin_end">12dp</dimen>

View File

@@ -3901,6 +3901,7 @@
<java-symbol type="dimen" name="conversation_icon_margin_top_centered" /> <java-symbol type="dimen" name="conversation_icon_margin_top_centered" />
<java-symbol type="dimen" name="conversation_content_start" /> <java-symbol type="dimen" name="conversation_content_start" />
<java-symbol type="dimen" name="messaging_layout_margin_end" /> <java-symbol type="dimen" name="messaging_layout_margin_end" />
<java-symbol type="dimen" name="conversation_header_expanded_padding_end" />
<java-symbol type="layout" name="notification_template_material_conversation" /> <java-symbol type="layout" name="notification_template_material_conversation" />
<java-symbol type="layout" name="conversation_face_pile_layout" /> <java-symbol type="layout" name="conversation_face_pile_layout" />