From fb33675a10461931aa52a15fa1855c3a7f3bbd08 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 26 Apr 2021 09:51:56 -0400 Subject: [PATCH] Fix layout oscillation at the root of a few bugs. Note: The CL which introduced this bug was Ic9cd89e899a03010a523bee4f1ef72fbfbd8b43f Test: visual, manual Test: Use TalkBack to validate that the size of the touch target is still >48dp tall. Test: Use an app (e.g. LINE) which only posts the most recent message in an update to send 2+ messages to the device (to make the unread number visible), and validate that 1) the text is visible, and 2) there are not thousands of View errors spamming adb. Fixes: 182474419 Change-Id: Ia23113f5903fe2c508fc2dbad99160471dcec5fd --- .../android/internal/widget/ConversationLayout.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java index bab4e93bdd9ac..ea0f704829c8f 100644 --- a/core/java/com/android/internal/widget/ConversationLayout.java +++ b/core/java/com/android/internal/widget/ConversationLayout.java @@ -1082,15 +1082,18 @@ public class ConversationLayout extends FrameLayout private void updateExpandButton() { int buttonGravity; - int containerHeight; ViewGroup newContainer; if (mIsCollapsed) { buttonGravity = Gravity.CENTER; - containerHeight = ViewGroup.LayoutParams.WRAP_CONTENT; + // NOTE(b/182474419): In order for the touch target of the expand button to be the full + // height of the notification, we would want the mExpandButtonContainer's height to be + // set to WRAP_CONTENT (or 88dp) when in the collapsed state. Unfortunately, that + // causes an unstable remeasuring infinite loop when the unread count is visible, + // causing the layout to occasionally hide the messages. As an aside, that naive + // solution also causes an undesirably large gap between content and smart replies. newContainer = mExpandButtonAndContentContainer; } else { buttonGravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; - containerHeight = ViewGroup.LayoutParams.MATCH_PARENT; newContainer = this; } mExpandButton.setExpanded(!mIsCollapsed); @@ -1099,7 +1102,6 @@ public class ConversationLayout extends FrameLayout // content when collapsed, but allows the content to flow under it when expanded. if (newContainer != mExpandButtonContainer.getParent()) { ((ViewGroup) mExpandButtonContainer.getParent()).removeView(mExpandButtonContainer); - mExpandButtonContainer.getLayoutParams().height = containerHeight; newContainer.addView(mExpandButtonContainer); }