When updating background colors in the shade, be sure to apply the reset to child rows.
Bug: 227880269 Fixes: 235868877 Test: atest ExpandableNotificationRowTest Change-Id: I10dae8dde98d94a629f4b8c1d99b4d4cd3a2d310
This commit is contained in:
@@ -141,7 +141,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
public static final float DEFAULT_HEADER_VISIBLE_AMOUNT = 1.0f;
|
||||
private static final long RECENTLY_ALERTED_THRESHOLD_MS = TimeUnit.SECONDS.toMillis(30);
|
||||
|
||||
private boolean mUpdateBackgroundOnUpdate;
|
||||
private boolean mUpdateSelfBackgroundOnUpdate;
|
||||
private boolean mNotificationTranslationFinished = false;
|
||||
private boolean mIsSnoozed;
|
||||
private boolean mIsFaded;
|
||||
@@ -553,9 +553,28 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
updateLimits();
|
||||
updateShelfIconColor();
|
||||
updateRippleAllowed();
|
||||
if (mUpdateBackgroundOnUpdate) {
|
||||
mUpdateBackgroundOnUpdate = false;
|
||||
updateBackgroundColors();
|
||||
if (mUpdateSelfBackgroundOnUpdate) {
|
||||
// Because this is triggered by UiMode change which we already propagated to children,
|
||||
// we know that child rows will receive the same event, and will update their own
|
||||
// backgrounds when they finish inflating, so propagating again would be redundant.
|
||||
mUpdateSelfBackgroundOnUpdate = false;
|
||||
updateBackgroundColorsOfSelf();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBackgroundColorsOfSelf() {
|
||||
super.updateBackgroundColors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBackgroundColors() {
|
||||
// Because this call is made by the NSSL only on attached rows at the moment of the
|
||||
// UiMode or Theme change, we have to propagate to our child views.
|
||||
updateBackgroundColorsOfSelf();
|
||||
if (mIsSummaryWithChildren) {
|
||||
for (ExpandableNotificationRow child : mChildrenContainer.getAttachedChildren()) {
|
||||
child.updateBackgroundColors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1242,7 +1261,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
}
|
||||
|
||||
public void onUiModeChanged() {
|
||||
mUpdateBackgroundOnUpdate = true;
|
||||
mUpdateSelfBackgroundOnUpdate = true;
|
||||
reInflateViews();
|
||||
if (mChildrenContainer != null) {
|
||||
for (ExpandableNotificationRow child : mChildrenContainer.getAttachedChildren()) {
|
||||
|
||||
@@ -43,6 +43,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.graphics.Color;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
@@ -109,6 +110,28 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBackgroundColors_isRecursive() {
|
||||
mGroupRow.setTintColor(Color.RED);
|
||||
mGroupRow.getChildNotificationAt(0).setTintColor(Color.GREEN);
|
||||
mGroupRow.getChildNotificationAt(1).setTintColor(Color.BLUE);
|
||||
|
||||
assertThat(mGroupRow.getCurrentBackgroundTint()).isEqualTo(Color.RED);
|
||||
assertThat(mGroupRow.getChildNotificationAt(0).getCurrentBackgroundTint())
|
||||
.isEqualTo(Color.GREEN);
|
||||
assertThat(mGroupRow.getChildNotificationAt(1).getCurrentBackgroundTint())
|
||||
.isEqualTo(Color.BLUE);
|
||||
|
||||
mGroupRow.updateBackgroundColors();
|
||||
|
||||
int resetTint = mGroupRow.getCurrentBackgroundTint();
|
||||
assertThat(resetTint).isNotEqualTo(Color.RED);
|
||||
assertThat(mGroupRow.getChildNotificationAt(0).getCurrentBackgroundTint())
|
||||
.isEqualTo(resetTint);
|
||||
assertThat(mGroupRow.getChildNotificationAt(1).getCurrentBackgroundTint())
|
||||
.isEqualTo(resetTint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetSensitiveOnNotifRowNotifiesOfHeightChange() throws InterruptedException {
|
||||
// GIVEN a sensitive notification row that's currently redacted
|
||||
|
||||
Reference in New Issue
Block a user