• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.media.dialog
18 
19 import android.content.Context
20 import com.android.settingslib.Utils
21 import com.android.systemui.monet.ColorScheme
22 import com.android.systemui.res.R
23 
24 abstract class MediaOutputColorSchemeLegacy {
25     companion object Factory {
26         @JvmStatic
fromSystemColorsnull27         fun fromSystemColors(context: Context): MediaOutputColorSchemeLegacy {
28             return MediaOutputColorSchemeLegacySystem(context)
29         }
30 
31         @JvmStatic
fromDynamicColorsnull32         fun fromDynamicColors(
33             colorScheme: ColorScheme,
34             isDarkTheme: Boolean,
35         ): MediaOutputColorSchemeLegacy {
36             return MediaOutputColorSchemeLegacyDynamic(colorScheme, isDarkTheme)
37         }
38     }
39 
getColorConnectedItemBackgroundnull40     abstract fun getColorConnectedItemBackground(): Int
41 
42     abstract fun getColorPositiveButtonText(): Int
43 
44     abstract fun getColorDialogBackground(): Int
45 
46     abstract fun getColorItemContent(): Int
47 
48     abstract fun getColorSeekbarProgress(): Int
49 
50     abstract fun getColorButtonBackground(): Int
51 
52     abstract fun getColorItemBackground(): Int
53 }
54 
55 class MediaOutputColorSchemeLegacySystem(private val mContext: Context) :
56     MediaOutputColorSchemeLegacy() {
57 
58     override fun getColorConnectedItemBackground() =
59         Utils.getColorStateListDefaultColor(
60             mContext,
61             R.color.media_dialog_connected_item_background,
62         )
63 
64     override fun getColorPositiveButtonText() =
65         Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_solid_button_text)
66 
67     override fun getColorDialogBackground() =
68         Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_background)
69 
70     override fun getColorItemContent() =
71         Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_item_main_content)
72 
73     override fun getColorSeekbarProgress() =
74         Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_seekbar_progress)
75 
76     override fun getColorButtonBackground() =
77         Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_button_background)
78 
79     override fun getColorItemBackground() =
80         Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_item_background)
81 }
82 
83 class MediaOutputColorSchemeLegacyDynamic(colorScheme: ColorScheme, isDarkTheme: Boolean) :
84     MediaOutputColorSchemeLegacy() {
85     private var mColorItemContent: Int
86     private var mColorSeekbarProgress: Int
87     private var mColorButtonBackground: Int
88     private var mColorItemBackground: Int
89     private var mColorConnectedItemBackground: Int
90     private var mColorPositiveButtonText: Int
91     private var mColorDialogBackground: Int
92 
93     init {
94         if (isDarkTheme) {
95             mColorItemContent = colorScheme.accent1.s100 // A1-100
96             mColorSeekbarProgress = colorScheme.accent2.s600 // A2-600
97             mColorButtonBackground = colorScheme.accent1.s300 // A1-300
98             mColorItemBackground = colorScheme.neutral2.s800 // N2-800
99             mColorConnectedItemBackground = colorScheme.accent2.s800 // A2-800
100             mColorPositiveButtonText = colorScheme.accent2.s800 // A2-800
101             mColorDialogBackground = colorScheme.neutral1.s900 // N1-900
102         } else {
103             mColorItemContent = colorScheme.accent1.s800 // A1-800
104             mColorSeekbarProgress = colorScheme.accent1.s300 // A1-300
105             mColorButtonBackground = colorScheme.accent1.s600 // A1-600
106             mColorItemBackground = colorScheme.accent2.s50 // A2-50
107             mColorConnectedItemBackground = colorScheme.accent1.s100 // A1-100
108             mColorPositiveButtonText = colorScheme.neutral1.s50 // N1-50
109             mColorDialogBackground = colorScheme.backgroundColor
110         }
111     }
112 
getColorConnectedItemBackgroundnull113     override fun getColorConnectedItemBackground() = mColorConnectedItemBackground
114 
115     override fun getColorPositiveButtonText() = mColorPositiveButtonText
116 
117     override fun getColorDialogBackground() = mColorDialogBackground
118 
119     override fun getColorItemContent() = mColorItemContent
120 
121     override fun getColorSeekbarProgress() = mColorSeekbarProgress
122 
123     override fun getColorButtonBackground() = mColorButtonBackground
124 
125     override fun getColorItemBackground() = mColorItemBackground
126 }
127