summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt90
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt37
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java33
3 files changed, 107 insertions, 53 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt b/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt
index 2ae1806f3b3d..5023cf685457 100644
--- a/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt
@@ -95,66 +95,64 @@ class ColorSchemeTransition internal constructor(
val surfaceColor = colorTransitionFactory(
bgColor,
- { colorScheme -> colorScheme.accent2[9] }, // A2-800
- { surfaceColor ->
- val colorList = ColorStateList.valueOf(surfaceColor)
- mediaViewHolder.player.backgroundTintList = colorList
- mediaViewHolder.albumView.foregroundTintList = colorList
- mediaViewHolder.albumView.backgroundTintList = colorList
- mediaViewHolder.seamlessIcon.imageTintList = colorList
- mediaViewHolder.seamlessText.setTextColor(surfaceColor)
- mediaViewHolder.dismissText.setTextColor(surfaceColor)
- })
+ ::surfaceFromScheme
+ ) { surfaceColor ->
+ val colorList = ColorStateList.valueOf(surfaceColor)
+ mediaViewHolder.player.backgroundTintList = colorList
+ mediaViewHolder.albumView.foregroundTintList = colorList
+ mediaViewHolder.albumView.backgroundTintList = colorList
+ mediaViewHolder.seamlessIcon.imageTintList = colorList
+ mediaViewHolder.seamlessText.setTextColor(surfaceColor)
+ mediaViewHolder.dismissText.setTextColor(surfaceColor)
+ }
val accentPrimary = colorTransitionFactory(
loadDefaultColor(R.attr.textColorPrimary),
- { colorScheme -> colorScheme.accent1[2] }, // A1-100
- { accentPrimary ->
- val accentColorList = ColorStateList.valueOf(accentPrimary)
- mediaViewHolder.actionPlayPause.backgroundTintList = accentColorList
- mediaViewHolder.seamlessButton.backgroundTintList = accentColorList
- mediaViewHolder.settings.imageTintList = accentColorList
- mediaViewHolder.cancelText.backgroundTintList = accentColorList
- mediaViewHolder.dismissText.backgroundTintList = accentColorList
- })
+ ::accentPrimaryFromScheme
+ ) { accentPrimary ->
+ val accentColorList = ColorStateList.valueOf(accentPrimary)
+ mediaViewHolder.actionPlayPause.backgroundTintList = accentColorList
+ mediaViewHolder.seamlessButton.backgroundTintList = accentColorList
+ mediaViewHolder.settings.imageTintList = accentColorList
+ mediaViewHolder.cancelText.backgroundTintList = accentColorList
+ mediaViewHolder.dismissText.backgroundTintList = accentColorList
+ }
val textPrimary = colorTransitionFactory(
loadDefaultColor(R.attr.textColorPrimary),
- { colorScheme -> colorScheme.neutral1[1] }, // N1-50
- { textPrimary ->
- mediaViewHolder.titleText.setTextColor(textPrimary)
- val textColorList = ColorStateList.valueOf(textPrimary)
- mediaViewHolder.seekBar.thumb.setTintList(textColorList)
- mediaViewHolder.seekBar.progressTintList = textColorList
- mediaViewHolder.longPressText.setTextColor(textColorList)
- mediaViewHolder.cancelText.setTextColor(textColorList)
- mediaViewHolder.scrubbingElapsedTimeView.setTextColor(textColorList)
- mediaViewHolder.scrubbingTotalTimeView.setTextColor(textColorList)
- for (button in mediaViewHolder.getTransparentActionButtons()) {
- button.imageTintList = textColorList
- }
- })
+ ::textPrimaryFromScheme
+ ) { textPrimary ->
+ mediaViewHolder.titleText.setTextColor(textPrimary)
+ val textColorList = ColorStateList.valueOf(textPrimary)
+ mediaViewHolder.seekBar.thumb.setTintList(textColorList)
+ mediaViewHolder.seekBar.progressTintList = textColorList
+ mediaViewHolder.longPressText.setTextColor(textColorList)
+ mediaViewHolder.cancelText.setTextColor(textColorList)
+ mediaViewHolder.scrubbingElapsedTimeView.setTextColor(textColorList)
+ mediaViewHolder.scrubbingTotalTimeView.setTextColor(textColorList)
+ for (button in mediaViewHolder.getTransparentActionButtons()) {
+ button.imageTintList = textColorList
+ }
+ }
val textPrimaryInverse = colorTransitionFactory(
loadDefaultColor(R.attr.textColorPrimaryInverse),
- { colorScheme -> colorScheme.neutral1[10] }, // N1-900
- { textPrimaryInverse ->
- mediaViewHolder.actionPlayPause.imageTintList =
- ColorStateList.valueOf(textPrimaryInverse)
- })
+ ::textPrimaryInverseFromScheme
+ ) { textPrimaryInverse ->
+ mediaViewHolder.actionPlayPause.imageTintList = ColorStateList.valueOf(textPrimaryInverse)
+ }
val textSecondary = colorTransitionFactory(
loadDefaultColor(R.attr.textColorSecondary),
- { colorScheme -> colorScheme.neutral2[3] }, // N2-200
- { textSecondary -> mediaViewHolder.artistText.setTextColor(textSecondary) })
+ ::textSecondaryFromScheme
+ ) { textSecondary -> mediaViewHolder.artistText.setTextColor(textSecondary) }
val textTertiary = colorTransitionFactory(
loadDefaultColor(R.attr.textColorTertiary),
- { colorScheme -> colorScheme.neutral2[5] }, // N2-400
- { textTertiary ->
- mediaViewHolder.seekBar.progressBackgroundTintList =
- ColorStateList.valueOf(textTertiary)
- })
+ ::textTertiaryFromScheme
+ ) { textTertiary ->
+ mediaViewHolder.seekBar.progressBackgroundTintList = ColorStateList.valueOf(textTertiary)
+ }
val colorTransitions = arrayOf(
surfaceColor, accentPrimary, textPrimary,
@@ -167,4 +165,4 @@ class ColorSchemeTransition internal constructor(
fun updateColorScheme(colorScheme: ColorScheme?) {
colorTransitions.forEach { it.updateColorScheme(colorScheme) }
}
-} \ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt b/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt
new file mode 100644
index 000000000000..97c6014c91bd
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2022 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.media
+
+import com.android.systemui.monet.ColorScheme
+
+/** Returns the surface color for media controls based on the scheme. */
+internal fun surfaceFromScheme(scheme: ColorScheme) = scheme.accent2[9] // A2-800
+
+/** Returns the primary accent color for media controls based on the scheme. */
+internal fun accentPrimaryFromScheme(scheme: ColorScheme) = scheme.accent1[2] // A1-100
+
+/** Returns the primary text color for media controls based on the scheme. */
+internal fun textPrimaryFromScheme(scheme: ColorScheme) = scheme.neutral1[1] // N1-50
+
+/** Returns the inverse of the primary text color for media controls based on the scheme. */
+internal fun textPrimaryInverseFromScheme(scheme: ColorScheme) = scheme.neutral1[10] // N1-900
+
+/** Returns the secondary text color for media controls based on the scheme. */
+internal fun textSecondaryFromScheme(scheme: ColorScheme) = scheme.neutral2[3] // N2-200
+
+/** Returns the tertiary text color for media controls based on the scheme. */
+internal fun textTertiaryFromScheme(scheme: ColorScheme) = scheme.neutral2[5] // N2-400
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index 12369e514de5..3faccdb6ffda 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -60,7 +60,6 @@ import androidx.constraintlayout.widget.ConstraintSet;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.InstanceId;
-import com.android.settingslib.Utils;
import com.android.settingslib.widget.AdaptiveIcon;
import com.android.systemui.ActivityIntentHelper;
import com.android.systemui.R;
@@ -973,8 +972,6 @@ public class MediaControlPanel {
mPackageName = data.getPackageName();
mInstanceId = data.getInstanceId();
TransitionLayout recommendationCard = mRecommendationViewHolder.getRecommendations();
- recommendationCard.setBackgroundTintList(
- Utils.getColorAttr(mContext, com.android.internal.R.attr.colorSurface));
List<SmartspaceAction> mediaRecommendationList = data.getRecommendations();
if (mediaRecommendationList == null || mediaRecommendationList.isEmpty()) {
@@ -998,6 +995,7 @@ public class MediaControlPanel {
Drawable icon = packageManager.getApplicationIcon(applicationInfo);
ImageView headerLogoImageView = mRecommendationViewHolder.getCardIcon();
headerLogoImageView.setImageDrawable(icon);
+ fetchAndUpdateRecommendationColors(icon);
// Set up media source app's label text.
CharSequence appName = getAppName(data.getCardAction());
@@ -1073,8 +1071,6 @@ public class MediaControlPanel {
TextView titleView =
mRecommendationViewHolder.getMediaTitles().get(uiComponentIndex);
titleView.setText(title);
- titleView.setTextColor(Utils.getColorAttrDefaultColor(
- mContext, com.android.internal.R.attr.textColorPrimary));
// TODO(b/223603970): If none of them have titles, should we then hide the views?
// Set up subtitle
@@ -1085,8 +1081,6 @@ public class MediaControlPanel {
boolean shouldShowSubtitleText = !TextUtils.isEmpty(title);
CharSequence subtitleText = shouldShowSubtitleText ? subtitle : "";
subtitleView.setText(subtitleText);
- subtitleView.setTextColor(Utils.getColorAttrDefaultColor(
- mContext, com.android.internal.R.attr.textColorSecondary));
// TODO(b/223603970): If none of them have subtitles, should we then hide the views?
uiComponentIndex++;
@@ -1128,6 +1122,31 @@ public class MediaControlPanel {
}
}
+ private void fetchAndUpdateRecommendationColors(Drawable appIcon) {
+ mBackgroundExecutor.execute(() -> {
+ ColorScheme colorScheme = new ColorScheme(
+ WallpaperColors.fromDrawable(appIcon), /* darkTheme= */ true);
+ mMainExecutor.execute(() -> setRecommendationColors(colorScheme));
+ });
+ }
+
+ private void setRecommendationColors(ColorScheme colorScheme) {
+ if (mRecommendationViewHolder == null) {
+ return;
+ }
+
+ int backgroundColor = MediaColorSchemesKt.surfaceFromScheme(colorScheme);
+ int textPrimaryColor = MediaColorSchemesKt.textPrimaryFromScheme(colorScheme);
+ int textSecondaryColor = MediaColorSchemesKt.textSecondaryFromScheme(colorScheme);
+
+ mRecommendationViewHolder.getRecommendations()
+ .setBackgroundTintList(ColorStateList.valueOf(backgroundColor));
+ mRecommendationViewHolder.getMediaTitles().forEach(
+ (title) -> title.setTextColor(textPrimaryColor));
+ mRecommendationViewHolder.getMediaSubtitles().forEach(
+ (subtitle) -> subtitle.setTextColor(textSecondaryColor));
+ }
+
/**
* Close the guts for this player.
*