Merge "Fix collapsed group message text alignment" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-17 19:16:49 +00:00
committed by Android (Google) Code Review
3 changed files with 28 additions and 0 deletions

View File

@@ -110,6 +110,7 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
private ViewGroup mMessagingIconContainer;
private int mConversationContentStart;
private int mNonConversationMarginEnd;
private int mNotificationTextMarginTop;
public MessagingGroup(@NonNull Context context) {
super(context);
@@ -149,6 +150,8 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
R.dimen.conversation_content_start);
mNonConversationMarginEnd = getResources().getDimensionPixelSize(
R.dimen.messaging_layout_margin_end);
mNotificationTextMarginTop = getResources().getDimensionPixelSize(
R.dimen.notification_text_margin_top);
}
public void updateClipRect() {
@@ -665,6 +668,9 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
public void setSingleLine(boolean singleLine) {
if (singleLine != mSingleLine) {
mSingleLine = singleLine;
MarginLayoutParams p = (MarginLayoutParams) mMessageContainer.getLayoutParams();
p.topMargin = singleLine ? 0 : mNotificationTextMarginTop;
mMessageContainer.setLayoutParams(p);
mContentContainer.setOrientation(
singleLine ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
MarginLayoutParams layoutParams = (MarginLayoutParams) mSenderView.getLayoutParams();

View File

@@ -300,6 +300,27 @@ public class MessagingLinearLayout extends ViewGroup {
return mMessagingLayout;
}
@Override
public int getBaseline() {
// When placed in a horizontal linear layout (as is the case in a single-line MessageGroup),
// align with the last visible child (which is the one that will be displayed in the single-
// line group.
int childCount = getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
final View child = getChildAt(i);
if (isGone(child)) {
continue;
}
final int childBaseline = child.getBaseline();
if (childBaseline == -1) {
return -1;
}
MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
return lp.topMargin + childBaseline;
}
return super.getBaseline();
}
public interface MessagingChild {
int MEASURED_NORMAL = 0;
int MEASURED_SHORTENED = 1;

View File

@@ -37,6 +37,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="true"
android:orientation="vertical">
<com.android.internal.widget.ImageFloatingTextView
android:id="@+id/message_name"