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

Commit f03e48d7 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Allow shade to fallback when blur is disabled

Fixes: 388891313
Flag: com.android.systemui.notification_shade_blur
Test: manual
Change-Id: Ib6c7608ff4309b0f548f2b5e15d84416837f8bc0
parent 371e3721
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -110,12 +110,12 @@

    <!-- 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>
    <color name="shade_panel_base">@android:color/system_accent1_800</color>
    <color name="notification_scrim_base">@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>
    <!-- Dark theme fallback colors for notification shade/scrim -->
    <color name="shade_panel_fallback">@android:color/system_accent2_800</color>
    <color name="notification_scrim_fallback">@android:color/system_surface_dim_dark</color>

    <!-- Keyboard shortcut helper dialog -->
    <color name="ksh_key_item_color">@*android:color/system_on_surface_variant_dark</color>
+5 −5
Original line number Diff line number Diff line
@@ -34,12 +34,12 @@

    <!-- 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>
    <color name="shade_panel_base">@android:color/system_accent1_900</color>
    <color name="notification_scrim_base">@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>
    <!-- Fallback colors for notification shade/scrim -->
    <color name="shade_panel_fallback">@android:color/system_accent2_200</color>
    <color name="notification_scrim_fallback">@android:color/system_surface_dim_light</color>

    <!-- The color of the background in the separated list of the Global Actions menu -->
    <color name="global_actions_separated_background">#F5F5F5</color>
+0 −32
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.common.shared.colors

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.shadeBasePanel(): Int {
        val layerAbove =
            ColorUtils.setAlphaComponent(getColor(R.color.shade_panel), (0.4f * 255).toInt())
        val layerBelow = ColorUtils.setAlphaComponent(Color.WHITE, (0.1f * 255).toInt())
        return ColorUtils.compositeColors(layerAbove, layerBelow)
    }
}
+0 −3
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@
package com.android.systemui.common.shared.colors

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

object SurfaceEffectColors {
    @JvmStatic
+35 −5
Original line number Diff line number Diff line
@@ -23,18 +23,48 @@ 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())
    fun Resources.shadePanel(blurSupported: Boolean): Int {
        return if (blurSupported) {
            shadePanelStandard()
        } else {
            shadePanelFallback()
        }
    }

    @JvmStatic
    fun Resources.notificationScrim(blurSupported: Boolean): Int {
        return if (blurSupported) {
            notificationScrimStandard()
        } else {
            notificationScrimFallback()
        }
    }

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

    @JvmStatic
    fun Resources.notificationScrim(): Int {
    private fun Resources.shadePanelFallback(): Int {
        return getColor(R.color.shade_panel_fallback, null)
    }

    @JvmStatic
    private fun Resources.notificationScrimStandard(): Int {
        return ColorUtils.setAlphaComponent(
            getColor(R.color.notification_scrim_base),
            getColor(R.color.notification_scrim_base, null),
            (0.5f * 255).toInt(),
        )
    }

    @JvmStatic
    private fun Resources.notificationScrimFallback(): Int {
        return getColor(R.color.notification_scrim_fallback, null)
    }
}
Loading