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

Commit 56c3534e authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Pipe isBlurSupported signal into notification row rendering" into main

parents 4854d8f9 834174b5
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.accessibility.data.repository.FakeAccessibilityRepository
import com.android.systemui.accessibility.domain.interactor.AccessibilityInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.testKosmos
import com.android.systemui.window.domain.interactor.windowRootViewBlurInteractor
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
@@ -32,12 +34,16 @@ import org.junit.runner.RunWith
@SmallTest
class ActivatableNotificationViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos()

    // fakes
    private val a11yRepo = FakeAccessibilityRepository()

    // real impls
    private val a11yInteractor = AccessibilityInteractor(a11yRepo)
    private val underTest = ActivatableNotificationViewModel(a11yInteractor)
    private val windowRootViewBlurInteractor = kosmos.windowRootViewBlurInteractor
    private val underTest = ActivatableNotificationViewModel(a11yInteractor,
        windowRootViewBlurInteractor)

    @Test
    fun isTouchable_whenA11yTouchExplorationDisabled() = runTest {
+25 −1
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    protected Point mTargetPoint;
    private boolean mDismissed;
    private boolean mRefocusOnDismiss;
    protected boolean mIsBlurSupported;

    public ActivatableNotificationView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -128,12 +129,13 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }

    private void updateColors() {
        if (notificationRowTransparency()) {
        if (usesTransparentBackground()) {
            mNormalColor = SurfaceEffectColors.surfaceEffect1(getContext());
        } else {
            mNormalColor = mContext.getColor(
                    com.android.internal.R.color.materialColorSurfaceContainerHigh);
        }
        setBackgroundToNormalColor();
        mTintedRippleColor = mContext.getColor(
                R.color.notification_ripple_tinted_color);
        mNormalRippleColor = mContext.getColor(
@@ -144,6 +146,12 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mOverrideAmount = 0.0f;
    }

    private void setBackgroundToNormalColor() {
        if (mBackgroundNormal != null) {
            mBackgroundNormal.setNormalColor(mNormalColor);
        }
    }

    /**
     * Reload background colors from resources and invalidate views.
     */
@@ -173,6 +181,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBackgroundNormal = findViewById(R.id.backgroundNormal);
        mFakeShadow = findViewById(R.id.fake_shadow);
        mShadowHidden = mFakeShadow.getVisibility() != VISIBLE;
        setBackgroundToNormalColor();
        initBackground();
        updateBackgroundTint();
        updateOutlineAlpha();
@@ -326,6 +335,21 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBackgroundNormal.setBottomAmountClips(!isChildInGroup());
    }

    public void setIsBlurSupported(boolean isBlurSupported) {
        if (!notificationRowTransparency()) {
            return;
        }
        boolean usedTransparentBackground = usesTransparentBackground();
        mIsBlurSupported = isBlurSupported;
        if (usedTransparentBackground != usesTransparentBackground()) {
            updateBackgroundColors();
        }
    }

    protected boolean usesTransparentBackground() {
        return mIsBlurSupported && notificationRowTransparency();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
+6 −5
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@ import static android.app.Flags.notificationsRedesignTemplates;
import static android.app.Notification.Action.SEMANTIC_ACTION_MARK_CONVERSATION_AS_PRIORITY;
import static android.service.notification.NotificationListenerService.REASON_CANCEL;

import static com.android.systemui.Flags.notificationsPinnedHunInShade;
import static com.android.systemui.Flags.notificationRowTransparency;
import static com.android.systemui.Flags.notificationsPinnedHunInShade;
import static com.android.systemui.flags.Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE;
import static com.android.systemui.statusbar.notification.NotificationUtils.logKey;
import static com.android.systemui.statusbar.notification.collection.NotificationEntry.DismissState.PARENT_DISMISSED;
@@ -1678,14 +1678,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (view != null) {
            view.setBackgroundTintColor(color);
        }
        if (notificationRowTransparency()
                && (mBackgroundNormal != null)) {
        if (notificationRowTransparency() && mBackgroundNormal != null) {
            if (NotificationBundleUi.isEnabled()) {
                mBackgroundNormal.setBgIsColorized(mEntryAdapter.isColorized());
                mBackgroundNormal.setBgIsColorized(
                        usesTransparentBackground() && mEntryAdapter.isColorized());
            } else {
                if (mEntry != null) {
                    mBackgroundNormal.setBgIsColorized(
                            mEntry.getSbn().getNotification().isColorized());
                            usesTransparentBackground()
                                    && mEntry.getSbn().getNotification().isColorized());
                }
            }
        }
+5 −7
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class NotificationBackgroundView extends View implements Dumpable,
    private int mDrawableAlpha = 255;
    private final ColorStateList mLightColoredStatefulColors;
    private final ColorStateList mDarkColoredStatefulColors;
    private final int mNormalColor;
    private int mNormalColor;
    private boolean mBgIsColorized = false;
    private boolean mForceOpaque = false;
    private final int convexR = 9;
@@ -89,15 +89,13 @@ public class NotificationBackgroundView extends View implements Dumpable,
                R.color.notification_state_color_light);
        mDarkColoredStatefulColors = getResources().getColorStateList(
                R.color.notification_state_color_dark);
        if (notificationRowTransparency()) {
            mNormalColor = SurfaceEffectColors.surfaceEffect1(getContext());
        } else  {
            mNormalColor = mContext.getColor(
                    com.android.internal.R.color.materialColorSurfaceContainerHigh);
        }
        mFocusOverlayStroke = getResources().getDimension(R.dimen.notification_focus_stroke_width);
    }

    public void setNormalColor(int color) {
        mNormalColor = color;
    }

    @Override
    public void onTargetVisibilityChanged(boolean targetVisible) {
        if (NotificationAddXOnHoverToDismiss.isUnexpectedlyInLegacyMode()) {
+9 −0
Original line number Diff line number Diff line
@@ -50,6 +50,15 @@ object ActivatableNotificationViewBinder {
                view.registerListenersWhileAttached(touchHandler)
            }
        }
        view.repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch {
                    viewModel.isBlurSupported.collect { supported ->
                        view.setIsBlurSupported(supported)
                    }
                }
            }
        }
    }

    private suspend fun ActivatableNotificationView.registerListenersWhileAttached(
Loading