Fix the layout issue with the expand button of the CallStyle
Bug: 179178086 Test: Post CallStyle; notice no gap where the expander would be. Change-Id: I15ca699449fa2840dba39d1c82e994d1ce2c9575
This commit is contained in:
@@ -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 @@
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- TODO(b/179178086): remove padding from main column when this is visible -->
|
||||
<include layout="@layout/notification_expand_button"
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|end"
|
||||
/>
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="@dimen/notification_content_margin_end"
|
||||
>
|
||||
|
||||
<include layout="@layout/notification_expand_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user