From 7da4bccd8a1e182a8bce103b2dc89ea24341ffc8 Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Thu, 11 Jun 2020 16:02:45 -0400 Subject: [PATCH 1/2] Truncate sender name in collapsed group message. Fixes: 158769554 Test: manual, visual Change-Id: I861d6ef755eac2c41e3ae2e2ca01d4a2dfeeecc8 --- .../internal/widget/MessagingGroup.java | 4 ++- .../MessagingLayoutTransformState.java | 29 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/core/java/com/android/internal/widget/MessagingGroup.java b/core/java/com/android/internal/widget/MessagingGroup.java index 53272f7eebf95..6d940b8ec33ee 100644 --- a/core/java/com/android/internal/widget/MessagingGroup.java +++ b/core/java/com/android/internal/widget/MessagingGroup.java @@ -42,6 +42,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RemoteViews; +import android.widget.TextView; import com.android.internal.R; @@ -612,7 +613,7 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou return 0; } - public View getSenderView() { + public TextView getSenderView() { return mSenderView; } @@ -668,6 +669,7 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou singleLine ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); MarginLayoutParams layoutParams = (MarginLayoutParams) mSenderView.getLayoutParams(); layoutParams.setMarginEnd(singleLine ? mSenderTextPaddingSingleLine : 0); + mSenderView.setSingleLine(singleLine); updateMaxDisplayedLines(); updateClipRect(); updateSenderVisibility(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MessagingLayoutTransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MessagingLayoutTransformState.java index 5ee4693a32bf0..e0532c3e2b28d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MessagingLayoutTransformState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MessagingLayoutTransformState.java @@ -17,9 +17,11 @@ package com.android.systemui.statusbar.notification; import android.content.res.Resources; +import android.text.Layout; import android.util.Pools; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import com.android.internal.widget.IMessagingLayout; import com.android.internal.widget.MessagingGroup; @@ -229,6 +231,15 @@ public class MessagingLayoutTransformState extends TransformState { return result; } + private boolean hasEllipses(TextView textView) { + Layout layout = textView.getLayout(); + return layout != null && layout.getEllipsisCount(layout.getLineCount() - 1) > 0; + } + + private boolean needsReflow(TextView own, TextView other) { + return hasEllipses(own) != hasEllipses(other); + } + /** * Transform two groups towards each other. * @@ -238,13 +249,20 @@ public class MessagingLayoutTransformState extends TransformState { float transformationAmount, boolean to) { boolean useLinearTransformation = otherGroup.getIsolatedMessage() == null && !mTransformInfo.isAnimating(); - transformView(transformationAmount, to, ownGroup.getSenderView(), otherGroup.getSenderView(), - true /* sameAsAny */, useLinearTransformation); + TextView ownSenderView = ownGroup.getSenderView(); + TextView otherSenderView = otherGroup.getSenderView(); + transformView(transformationAmount, to, ownSenderView, otherSenderView, + // Normally this would be handled by the TextViewMessageState#sameAs check, but in + // this case it doesn't work because our text won't match, due to the appended colon + // in the collapsed view. + !needsReflow(ownSenderView, otherSenderView), + useLinearTransformation); int totalAvatarTranslation = transformView(transformationAmount, to, ownGroup.getAvatar(), otherGroup.getAvatar(), true /* sameAsAny */, useLinearTransformation); List ownMessages = ownGroup.getMessages(); List otherMessages = otherGroup.getMessages(); float previousTranslation = 0; + boolean isLastView = true; for (int i = 0; i < ownMessages.size(); i++) { View child = ownMessages.get(ownMessages.size() - 1 - i).getView(); if (isGone(child)) { @@ -278,6 +296,9 @@ public class MessagingLayoutTransformState extends TransformState { mMessagingLayout.setMessagingClippingDisabled(true); } if (otherChild == null) { + if (isLastView) { + previousTranslation = ownSenderView.getTranslationY(); + } child.setTranslationY(previousTranslation); setClippingDeactivated(child, true); } else if (ownGroup.getIsolatedMessage() == child || otherIsIsolated) { @@ -287,6 +308,7 @@ public class MessagingLayoutTransformState extends TransformState { } else { previousTranslation = child.getTranslationY(); } + isLastView = false; } ownGroup.updateClipRect(); return totalAvatarTranslation; @@ -382,6 +404,9 @@ public class MessagingLayoutTransformState extends TransformState { if (view.getParent() == null) { return true; } + if (view.getWidth() == 0) { + return true; + } final ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp instanceof MessagingLinearLayout.LayoutParams && ((MessagingLinearLayout.LayoutParams) lp).hide) { From 4594603f1e4bc88f5b44f0a98c0ca5d5bb3eeacf Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Mon, 15 Jun 2020 15:40:31 -0400 Subject: [PATCH 2/2] Fix alignment of expanded bundled group convo avatar Fixes: 159043203 Test: manual Change-Id: If8d5b906d79c9dfcc5e99d8162f73d0f7d09e6e1 --- .../android/internal/widget/ConversationLayout.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java index b64923fb5bf81..5d4407bf8370c 100644 --- a/core/java/com/android/internal/widget/ConversationLayout.java +++ b/core/java/com/android/internal/widget/ConversationLayout.java @@ -233,13 +233,20 @@ public class ConversationLayout extends FrameLayout oldVisibility = mImportanceRingView.getVisibility(); wasGone = oldVisibility == GONE; visibility = !mImportantConversation ? GONE : visibility; - isGone = visibility == GONE; - if (wasGone != isGone) { + boolean isRingGone = visibility == GONE; + if (wasGone != isRingGone) { // Keep the badge visibility in sync with the icon. This is necessary in cases // Where the icon is being hidden externally like in group children. mImportanceRingView.animate().cancel(); mImportanceRingView.setVisibility(visibility); } + + oldVisibility = mConversationIconBadge.getVisibility(); + wasGone = oldVisibility == GONE; + if (wasGone != isGone) { + mConversationIconBadge.animate().cancel(); + mConversationIconBadge.setVisibility(visibility); + } }); // When the small icon is gone, hide the rest of the badge mIcon.setOnForceHiddenChangedListener((forceHidden) -> {