Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8928d21d authored by Jeff DeCew's avatar Jeff DeCew Committed by Automerger Merge Worker
Browse files

Merge "When updating background colors in the shade, be sure to apply the...

Merge "When updating background colors in the shade, be sure to apply the reset to child rows." into tm-qpr-dev am: ae85446b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18872707



Change-Id: I070b81a463d35cc37a4bcbccb239b106ca57f8ea
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 3952497c ae85446b
Loading
Loading
Loading
Loading
+24 −5
Original line number Diff line number Diff line
@@ -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()) {
+23 −0
Original line number Diff line number Diff line
@@ -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