• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download

<lambda>null1 package com.android.wm.shell.windowdecor.viewholder
2 
3 import android.app.ActivityManager.RunningTaskInfo
4 import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
5 import android.content.Context
6 import android.graphics.Color
7 import android.view.View
8 import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
9 
10 /**
11  * Encapsulates the root [View] of a window decoration and its children to facilitate looking up
12  * children (via findViewById) and updating to the latest data from [RunningTaskInfo].
13  */
14 internal abstract class DesktopModeWindowDecorationViewHolder(rootView: View) {
15   val context: Context = rootView.context
16 
17   /**
18    * A signal to the view holder that new data is available and that the views should be updated to
19    * reflect it.
20    */
21   abstract fun bindData(taskInfo: RunningTaskInfo)
22 
23   /**
24    * Whether the caption items should use the 'light' color variant so that there's good contrast
25    * with the caption background color.
26    */
27   protected fun shouldUseLightCaptionColors(taskInfo: RunningTaskInfo): Boolean {
28     return taskInfo.taskDescription
29         ?.let { taskDescription ->
30           if (Color.alpha(taskDescription.statusBarColor) != 0 &&
31               taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) {
32             Color.valueOf(taskDescription.statusBarColor).luminance() < 0.5
33           } else {
34             taskDescription.statusBarAppearance and APPEARANCE_LIGHT_STATUS_BARS == 0
35           }
36         } ?: false
37   }
38 }
39