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

Commit fa9428d2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Scrim alpha changes for notification shade blur" into main

parents d5258154 d4802c79
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -108,8 +108,14 @@


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


    <!-- Dark Theme colors for notification shade/scrim -->
    <!-- Dark theme base colors for notification shade/scrim, the alpha component is adjusted
    <color name="shade_panel">@android:color/system_accent1_900</color>
     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 -->
    <!-- Keyboard shortcut helper dialog -->
    <color name="ksh_key_item_color">@*android:color/system_on_surface_variant_dark</color>
    <color name="ksh_key_item_color">@*android:color/system_on_surface_variant_dark</color>
+8 −2
Original line number Original line Diff line number Diff line
@@ -31,8 +31,14 @@
    <!-- The dark background color behind the shade -->
    <!-- The dark background color behind the shade -->
    <color name="shade_scrim_background_dark">@androidprv:color/system_under_surface_light</color>
    <color name="shade_scrim_background_dark">@androidprv:color/system_under_surface_light</color>


    <!-- Colors for notification shade/scrim -->
    <!-- Base colors for notification shade/scrim, the alpha component is adjusted programmatically
    <color name="shade_panel">@android:color/system_accent1_800</color>
    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 -->
    <!-- The color of the background in the separated list of the Global Actions menu -->
    <color name="global_actions_separated_background">#F5F5F5</color>
    <color name="global_actions_separated_background">#F5F5F5</color>
+40 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -868,6 +868,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
     * bounds instead.
     * bounds instead.
     */
     */
    public void setClipsQsScrim(boolean clipScrim) {
    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) {
        if (clipScrim == mClipsQsScrim) {
            return;
            return;
        }
        }
@@ -956,6 +962,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
                    behindFraction = (float) Math.pow(behindFraction, 0.8f);
                    behindFraction = (float) Math.pow(behindFraction, 0.8f);
                    mBehindAlpha = 1;
                    mBehindAlpha = 1;
                    mNotificationsAlpha = behindFraction * mDefaultScrimAlpha;
                    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 {
                    } else {
                        mBehindAlpha = mLargeScreenShadeInterpolator.getBehindScrimAlpha(
                        mBehindAlpha = mLargeScreenShadeInterpolator.getBehindScrimAlpha(
                                mPanelExpansionFraction * mDefaultScrimAlpha);
                                mPanelExpansionFraction * mDefaultScrimAlpha);
@@ -963,6 +977,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
                                mLargeScreenShadeInterpolator.getNotificationScrimAlpha(
                                mLargeScreenShadeInterpolator.getNotificationScrimAlpha(
                                        mPanelExpansionFraction);
                                        mPanelExpansionFraction);
                    }
                    }
                }
                mBehindTint = mState.getBehindTint();
                mBehindTint = mState.getBehindTint();
                mInFrontAlpha = 0;
                mInFrontAlpha = 0;
            }
            }
@@ -1015,7 +1030,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
                            .saturate(mTransitionToLockScreenFullShadeNotificationsProgress);
                            .saturate(mTransitionToLockScreenFullShadeNotificationsProgress);
                } else if (mState == ScrimState.SHADE_LOCKED) {
                } else if (mState == ScrimState.SHADE_LOCKED) {
                    // going from KEYGUARD to SHADE_LOCKED state
                    // going from KEYGUARD to SHADE_LOCKED state
                    if (Flags.notificationShadeBlur()) {
                        mNotificationsAlpha = mState.getNotifAlpha() * getInterpolatedFraction();
                    } else {
                        mNotificationsAlpha = getInterpolatedFraction();
                        mNotificationsAlpha = getInterpolatedFraction();
                    }
                } else if (mState == ScrimState.GLANCEABLE_HUB
                } else if (mState == ScrimState.GLANCEABLE_HUB
                        && mTransitionToFullShadeProgress == 0.0f) {
                        && mTransitionToFullShadeProgress == 0.0f) {
                    // Notification scrim should not be visible on the glanceable hub unless the
                    // Notification scrim should not be visible on the glanceable hub unless the
+39 −15
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.Flags;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManager;
import com.android.systemui.res.R;
import com.android.systemui.res.R;
import com.android.systemui.scrim.ScrimView;
import com.android.systemui.scrim.ScrimView;
import com.android.systemui.shade.ui.ShadeColors;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;


import kotlinx.coroutines.ExperimentalCoroutinesApi;
import kotlinx.coroutines.ExperimentalCoroutinesApi;
@@ -86,10 +87,16 @@ public enum ScrimState {
            } else {
            } else {
                mAnimationDuration = ScrimController.ANIMATION_DURATION;
                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;
                mFrontTint = mBackgroundColor;
                mBehindTint = mBackgroundColor;
                mBehindTint = mBackgroundColor;
                mNotifTint = mClipQsScrim ? mBackgroundColor : Color.TRANSPARENT;
                mNotifTint = mClipQsScrim ? mBackgroundColor : Color.TRANSPARENT;

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

        }
    },
    },


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


        @Override
        @Override
        public void prepare(ScrimState previousState) {
        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;
                mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha;
                mNotifAlpha = 1f;
                mNotifAlpha = 1f;
                mFrontAlpha = 0f;
                mFrontAlpha = 0f;
@@ -178,6 +194,7 @@ public enum ScrimState {
                    updateScrimColor(mScrimBehind, 1f /* alpha */, mBackgroundColor);
                    updateScrimColor(mScrimBehind, 1f /* alpha */, mBackgroundColor);
                }
                }
            }
            }
        }
    },
    },


    /**
    /**
@@ -282,6 +299,13 @@ public enum ScrimState {
                mFrontTint = mBackgroundColor;
                mFrontTint = mBackgroundColor;
                mBehindTint = mBackgroundColor;
                mBehindTint = mBackgroundColor;
                mBlankScreen = true;
                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) {
            if (mClipQsScrim) {