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

Commit d4802c79 authored by Chandru S's avatar Chandru S
Browse files

Scrim alpha changes for notification shade blur

Bug: 381263600
Test: NA
Flag: com.android.systemui.notification_shade_blur

Change-Id: Ib34a677dca881df150c5aa30558cf9215c0893b0
parent aac8e4ed
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -108,8 +108,14 @@

    <color name="people_tile_background">@color/material_dynamic_secondary20</color>

    <!-- Dark Theme colors for notification shade/scrim -->
    <color name="shade_panel">@android:color/system_accent1_900</color>
    <!-- Dark theme base colors for notification shade/scrim, the alpha component is adjusted
     programmatically to match the spec -->
    <color name="shade_panel">@android:color/system_accent1_800</color>
    <color name="surface_effect_0">@android:color/system_accent1_800</color>

    <!-- todo(b/388891904) Remove updated color references once they are available. -->
    <color name="shade_panel_base">@color/shade_panel</color>
    <color name="notification_scrim_base">@color/surface_effect_0</color>

    <!-- Keyboard shortcut helper dialog -->
    <color name="ksh_key_item_color">@*android:color/system_on_surface_variant_dark</color>
+8 −2
Original line number Diff line number Diff line
@@ -31,8 +31,14 @@
    <!-- The dark background color behind the shade -->
    <color name="shade_scrim_background_dark">@androidprv:color/system_under_surface_light</color>

    <!-- Colors for notification shade/scrim -->
    <color name="shade_panel">@android:color/system_accent1_800</color>
    <!-- Base colors for notification shade/scrim, the alpha component is adjusted programmatically
    to match the spec -->
    <color name="shade_panel">@android:color/system_accent1_900</color>
    <color name="surface_effect_0">@android:color/system_accent1_100</color>

    <!-- todo(b/388891904) Remove updated color references once they are available. -->
    <color name="shade_panel_base">@color/shade_panel</color>
    <color name="notification_scrim_base">@color/surface_effect_0</color>

    <!-- The color of the background in the separated list of the Global Actions menu -->
    <color name="global_actions_separated_background">#F5F5F5</color>
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.shade.ui

import android.content.res.Resources
import android.graphics.Color
import com.android.internal.graphics.ColorUtils
import com.android.systemui.res.R

object ShadeColors {
    @JvmStatic
    fun Resources.shadePanel(): Int {
        val layerAbove =
            ColorUtils.setAlphaComponent(getColor(R.color.shade_panel_base), (0.4f * 255).toInt())
        val layerBelow = ColorUtils.setAlphaComponent(Color.WHITE, (0.1f * 255).toInt())
        return ColorUtils.compositeColors(layerAbove, layerBelow)
    }

    @JvmStatic
    fun Resources.notificationScrim(): Int {
        return ColorUtils.setAlphaComponent(
            getColor(R.color.notification_scrim_base),
            (0.5f * 255).toInt(),
        )
    }
}
+25 −6
Original line number Diff line number Diff line
@@ -868,6 +868,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
     * bounds instead.
     */
    public void setClipsQsScrim(boolean clipScrim) {
        if (Flags.notificationShadeBlur()) {
            // Never clip scrims when blur is enabled, colors of UI elements are supposed to "add"
            // up across the scrims.
            mClipsQsScrim = false;
            return;
        }
        if (clipScrim == mClipsQsScrim) {
            return;
        }
@@ -956,6 +962,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
                    behindFraction = (float) Math.pow(behindFraction, 0.8f);
                    mBehindAlpha = 1;
                    mNotificationsAlpha = behindFraction * mDefaultScrimAlpha;
                } else {
                    if (Flags.notificationShadeBlur()) {
                        // TODO (b/390730594): match any spec for controlling alpha based on shade
                        //  expansion fraction.
                        mBehindAlpha = mState.getBehindAlpha() * mPanelExpansionFraction;
                        mBehindTint = mState.getBehindTint();
                        mNotificationsAlpha = mState.getNotifAlpha() * mPanelExpansionFraction;
                        mNotificationsTint = mState.getNotifTint();
                    } else {
                        mBehindAlpha = mLargeScreenShadeInterpolator.getBehindScrimAlpha(
                                mPanelExpansionFraction * mDefaultScrimAlpha);
@@ -963,6 +977,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
                                mLargeScreenShadeInterpolator.getNotificationScrimAlpha(
                                        mPanelExpansionFraction);
                    }
                }
                mBehindTint = mState.getBehindTint();
                mInFrontAlpha = 0;
            }
@@ -1015,7 +1030,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
                            .saturate(mTransitionToLockScreenFullShadeNotificationsProgress);
                } else if (mState == ScrimState.SHADE_LOCKED) {
                    // going from KEYGUARD to SHADE_LOCKED state
                    if (Flags.notificationShadeBlur()) {
                        mNotificationsAlpha = mState.getNotifAlpha() * getInterpolatedFraction();
                    } else {
                        mNotificationsAlpha = getInterpolatedFraction();
                    }
                } else if (mState == ScrimState.GLANCEABLE_HUB
                        && mTransitionToFullShadeProgress == 0.0f) {
                    // Notification scrim should not be visible on the glanceable hub unless the
+39 −15
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.Flags;
import com.android.systemui.dock.DockManager;
import com.android.systemui.res.R;
import com.android.systemui.scrim.ScrimView;
import com.android.systemui.shade.ui.ShadeColors;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;

import kotlinx.coroutines.ExperimentalCoroutinesApi;
@@ -86,10 +87,16 @@ public enum ScrimState {
            } else {
                mAnimationDuration = ScrimController.ANIMATION_DURATION;
            }
            if (Flags.notificationShadeBlur()) {
                mBehindTint = Color.TRANSPARENT;
                mNotifTint = ShadeColors.notificationScrim(mScrimBehind.getResources());
                mBehindAlpha = 0.0f;
                mNotifAlpha = 0.0f;
                mFrontAlpha = 0.0f;
            } else {
                mFrontTint = mBackgroundColor;
                mBehindTint = mBackgroundColor;
                mNotifTint = mClipQsScrim ? mBackgroundColor : Color.TRANSPARENT;

                mFrontAlpha = 0;
                mBehindAlpha = mClipQsScrim ? 1 : mScrimBehindAlphaKeyguard;
                mNotifAlpha = mClipQsScrim ? mScrimBehindAlphaKeyguard : 0;
@@ -97,6 +104,8 @@ public enum ScrimState {
                    updateScrimColor(mScrimBehind, 1f /* alpha */, mBackgroundColor);
                }
            }

        }
    },

    /**
@@ -169,6 +178,13 @@ public enum ScrimState {

        @Override
        public void prepare(ScrimState previousState) {
            if (Flags.notificationShadeBlur()) {
                mBehindTint = ShadeColors.shadePanel(mScrimBehind.getResources());
                mBehindAlpha = Color.alpha(mBehindTint) / 255.0f;
                mNotifTint = ShadeColors.notificationScrim(mScrimBehind.getResources());
                mNotifAlpha = Color.alpha(mNotifTint) / 255.0f;
                mFrontAlpha = 0.0f;
            } else {
                mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha;
                mNotifAlpha = 1f;
                mFrontAlpha = 0f;
@@ -178,6 +194,7 @@ public enum ScrimState {
                    updateScrimColor(mScrimBehind, 1f /* alpha */, mBackgroundColor);
                }
            }
        }
    },

    /**
@@ -282,6 +299,13 @@ public enum ScrimState {
                mFrontTint = mBackgroundColor;
                mBehindTint = mBackgroundColor;
                mBlankScreen = true;
            } else if (Flags.notificationShadeBlur()) {
                mBehindTint = ShadeColors.shadePanel(mScrimBehind.getResources());
                mBehindAlpha = Color.alpha(mBehindTint) / 255.0f;
                mNotifTint = ShadeColors.notificationScrim(mScrimBehind.getResources());
                mNotifAlpha = Color.alpha(mNotifTint) / 255.0f;
                mFrontAlpha = 0.0f;
                return;
            }

            if (mClipQsScrim) {