From a49c4c7b6d415ed491c3db4561b10e01d12d177a Mon Sep 17 00:00:00 2001 From: Yining Liu Date: Wed, 14 Sep 2022 15:34:21 +0000 Subject: [PATCH] Fix the height of NotificationContentView when there's no actions but bubble button Added margin dynamic update for the condition when a NotificationContentView has bubble button but no actions Bug: 244522899 Test: Visual: 1. Mock a message notification that has bubble button but no actions, there shouldn't be a 20dp margin between notification_action_list_margin_target and actions_container. 2. Mock a message notification that has bubble button and actions, there shouldn't be a 20dp margin between notification_action_list_margin_target and actions_container. 3. Mock a message notification that has no bubble button or actions, notification_action_list_margin_target should have a 20dp bottom margin. Change-Id: Ie834309872c786dcf120023e7449099ee415e38e --- .../notification/row/NotificationContentView.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 ba26cfaa30b43..df81c0ed3a61e 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 @@ -1369,6 +1369,8 @@ public class NotificationContentView extends FrameLayout implements Notification } ImageView bubbleButton = layout.findViewById(com.android.internal.R.id.bubble_button); View actionContainer = layout.findViewById(com.android.internal.R.id.actions_container); + LinearLayout actionListMarginTarget = layout.findViewById( + com.android.internal.R.id.notification_action_list_margin_target); if (bubbleButton == null || actionContainer == null) { return; } @@ -1393,6 +1395,16 @@ public class NotificationContentView extends FrameLayout implements Notification bubbleButton.setOnClickListener(mContainingNotification.getBubbleClickListener()); bubbleButton.setVisibility(VISIBLE); actionContainer.setVisibility(VISIBLE); + // Set notification_action_list_margin_target's bottom margin to 0 when showing bubble + if (actionListMarginTarget != null) { + ViewGroup.LayoutParams lp = actionListMarginTarget.getLayoutParams(); + if (lp instanceof ViewGroup.MarginLayoutParams) { + final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp; + if (mlp.bottomMargin > 0) { + mlp.setMargins(mlp.leftMargin, mlp.topMargin, mlp.rightMargin, 0); + } + } + } } else { bubbleButton.setVisibility(GONE); }