From 407b180628d9d90487b6583e6d62b74ba0794dc5 Mon Sep 17 00:00:00 2001 From: mattsziklay Date: Thu, 1 Jun 2023 10:36:29 -0700 Subject: [PATCH] Use status bar appearance to determine header element brightness. Currently we use status bar color to determine header element brightness, which has the side effect of defaulting to bright elements on a clear caption. This CL will instead use the WindowInsets.APPEARANCE_LIGHT_STATUS_BAR flag to determine brightness in this particular case. Bug: 280833361 Test: Manual; open apps with and without clear status bar. Change-Id: Ie429825a76c20a5e1767bb80ba99cae8b7ce6068 --- .../viewholder/DesktopModeWindowDecorationViewHolder.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt index 514ea52cb8ae5..76c80f7bbe85e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt @@ -4,7 +4,7 @@ import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.graphics.Color import android.view.View - +import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS /** * Encapsulates the root [View] of a window decoration and its children to facilitate looking up * children (via findViewById) and updating to the latest data from [RunningTaskInfo]. @@ -23,6 +23,10 @@ internal abstract class DesktopModeWindowDecorationViewHolder(rootView: View) { * with the caption background color. */ protected fun shouldUseLightCaptionColors(taskInfo: RunningTaskInfo): Boolean { - return Color.valueOf(taskInfo.taskDescription.statusBarColor).luminance() < 0.5 + return if (Color.alpha(taskInfo.taskDescription.statusBarColor) != 0) { + Color.valueOf(taskInfo.taskDescription.statusBarColor).luminance() < 0.5 + } else { + taskInfo.taskDescription.statusBarAppearance and APPEARANCE_LIGHT_STATUS_BARS == 0 + } } }