diff --git a/core/res/res/layout/notification_template_material_call.xml b/core/res/res/layout/notification_template_material_call.xml index 7b52ec30abe64..c2ffd1f0d8b35 100644 --- a/core/res/res/layout/notification_template_material_call.xml +++ b/core/res/res/layout/notification_template_material_call.xml @@ -50,7 +50,6 @@ android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginStart="@dimen/conversation_content_start" - android:layout_marginEnd="@dimen/notification_content_margin_end" android:orientation="vertical" android:minHeight="68dp" > @@ -71,12 +70,18 @@ /> - - + android:layout_height="match_parent" + android:minWidth="@dimen/notification_content_margin_end" + > + + + + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index d3065aa36a5fa..dabea582798fa 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -349,7 +349,9 @@ public class NotificationContentView extends FrameLayout { invalidateOutline(); selectLayout(false /* animate */, mForceSelectNextLayout /* force */); mForceSelectNextLayout = false; - updateExpandButtons(mExpandable); + // TODO(b/182314698): move this to onMeasure. This requires switching to getMeasuredHeight, + // and also requires revisiting all of the logic called earlier in this method. + updateExpandButtonsDuringLayout(mExpandable, true /* duringLayout */); } @Override @@ -1589,6 +1591,10 @@ public class NotificationContentView extends FrameLayout { } public void updateExpandButtons(boolean expandable) { + updateExpandButtonsDuringLayout(expandable, false /* duringLayout */); + } + + private void updateExpandButtonsDuringLayout(boolean expandable, boolean duringLayout) { mExpandable = expandable; // if the expanded child has the same height as the collapsed one we hide it. if (mExpandedChild != null && mExpandedChild.getHeight() != 0) { @@ -1602,14 +1608,15 @@ public class NotificationContentView extends FrameLayout { expandable = false; } } + boolean requestLayout = duringLayout && mIsContentExpandable != expandable; if (mExpandedChild != null) { - mExpandedWrapper.updateExpandability(expandable, mExpandClickListener); + mExpandedWrapper.updateExpandability(expandable, mExpandClickListener, requestLayout); } if (mContractedChild != null) { - mContractedWrapper.updateExpandability(expandable, mExpandClickListener); + mContractedWrapper.updateExpandability(expandable, mExpandClickListener, requestLayout); } if (mHeadsUpChild != null) { - mHeadsUpWrapper.updateExpandability(expandable, mExpandClickListener); + mHeadsUpWrapper.updateExpandability(expandable, mExpandClickListener, requestLayout); } mIsContentExpandable = expandable; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt index fb0fdcccd4b13..383bb7e41a913 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt @@ -147,8 +147,11 @@ class NotificationConversationTemplateViewWrapper constructor( override fun setRemoteInputVisible(visible: Boolean) = conversationLayout.showHistoricMessages(visible) - override fun updateExpandability(expandable: Boolean, onClickListener: View.OnClickListener?) = - conversationLayout.updateExpandability(expandable, onClickListener) + override fun updateExpandability( + expandable: Boolean, + onClickListener: View.OnClickListener, + requestLayout: Boolean + ) = conversationLayout.updateExpandability(expandable, onClickListener) override fun disallowSingleClick(x: Float, y: Float): Boolean { val isOnExpandButton = expandBtnContainer.visibility == View.VISIBLE && diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index bdafd232167d1..5a55545351d0e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -261,7 +261,8 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { } @Override - public void updateExpandability(boolean expandable, View.OnClickListener onClickListener) { + public void updateExpandability(boolean expandable, View.OnClickListener onClickListener, + boolean requestLayout) { mExpandButton.setVisibility(expandable ? View.VISIBLE : View.GONE); mExpandButton.setOnClickListener(expandable ? onClickListener : null); if (mAltExpandTarget != null) { @@ -273,6 +274,13 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { if (mNotificationHeader != null) { mNotificationHeader.setOnClickListener(expandable ? onClickListener : null); } + // Unfortunately, the NotificationContentView has to layout its children in order to + // determine their heights, and that affects the button visibility. If that happens + // (thankfully it is rare) then we need to request layout of the expand button's parent + // in order to ensure it gets laid out correctly. + if (requestLayout) { + mExpandButton.getParent().requestLayout(); + } } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java index 9ced12d32d27a..3a7b4618ad221 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java @@ -291,8 +291,10 @@ public abstract class NotificationViewWrapper implements TransformableView { * * @param expandable should this view be expandable * @param onClickListener the listener to invoke when the expand affordance is clicked on + * @param requestLayout the expandability changed during onLayout, so a requestLayout required */ - public void updateExpandability(boolean expandable, View.OnClickListener onClickListener) {} + public void updateExpandability(boolean expandable, View.OnClickListener onClickListener, + boolean requestLayout) {} /** Set the expanded state on the view wrapper */ public void setExpanded(boolean expanded) {}