Loading packages/SystemUI/res/drawable/qs_media_outline_album_bg.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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 --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFFFF" /> <corners android:radius="@dimen/notification_corner_radius"/> </shape> packages/SystemUI/res/drawable/qs_media_outline_layout_bg.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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 --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00000000" /> <corners android:radius="@dimen/notification_corner_radius"/> </shape> packages/SystemUI/res/drawable/qs_media_scrim.xml +0 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="@dimen/notification_corner_radius"/> <!-- gradient from 25% in the center to 100% at edges --> <gradient android:type="radial" Loading packages/SystemUI/res/layout/media_session_view.xml +3 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,8 @@ android:clipToPadding="true" android:gravity="center_horizontal|fill_vertical" android:forceHasOverlappingRendering="false" android:background="@drawable/qs_media_background" android:background="@drawable/qs_media_outline_layout_bg" android:clipToOutline="true" android:theme="@style/MediaPlayer"> <ImageView Loading @@ -40,8 +41,8 @@ android:scaleType="centerCrop" android:adjustViewBounds="true" android:clipToOutline="true" android:background="@drawable/qs_media_outline_album_bg" android:foreground="@drawable/qs_media_scrim" android:background="@drawable/qs_media_scrim" /> <!-- Guideline for output switcher --> Loading packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt +39 −45 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.animation.ValueAnimator.AnimatorUpdateListener import android.animation.ValueAnimator import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.graphics.drawable.RippleDrawable import com.android.internal.R Loading @@ -37,13 +38,6 @@ interface ColorTransition { fun updateColorScheme(scheme: ColorScheme?) } /** A generic implementation of [ColorTransition] so that we can define a factory method. */ open class GenericColorTransition( private val applyTheme: (ColorScheme?) -> Unit ) : ColorTransition { override fun updateColorScheme(scheme: ColorScheme?) = applyTheme(scheme) } /** * A [ColorTransition] that animates between two specific colors. * It uses a ValueAnimator to execute the animation and interpolate between the source color and Loading Loading @@ -96,7 +90,6 @@ open class AnimatingColorTransition( typealias AnimatingColorTransitionFactory = (Int, (ColorScheme) -> Int, (Int) -> Unit) -> AnimatingColorTransition typealias GenericColorTransitionFactory = ((ColorScheme?) -> Unit) -> GenericColorTransition /** * ColorSchemeTransition constructs a ColorTransition for each color in the scheme Loading @@ -105,23 +98,22 @@ typealias GenericColorTransitionFactory = ((ColorScheme?) -> Unit) -> GenericCol */ class ColorSchemeTransition internal constructor( private val context: Context, mediaViewHolder: MediaViewHolder, animatingColorTransitionFactory: AnimatingColorTransitionFactory, genericColorTransitionFactory: GenericColorTransitionFactory private val mediaViewHolder: MediaViewHolder, animatingColorTransitionFactory: AnimatingColorTransitionFactory ) { constructor(context: Context, mediaViewHolder: MediaViewHolder) : this(context, mediaViewHolder, ::AnimatingColorTransition, ::GenericColorTransition) this(context, mediaViewHolder, ::AnimatingColorTransition) private var isGradientEnabled = true val bgColor = context.getColor(com.android.systemui.R.color.material_dynamic_secondary95) val surfaceColor = animatingColorTransitionFactory( bgColor, ::surfaceFromScheme ) { surfaceColor -> val colorList = ColorStateList.valueOf(surfaceColor) mediaViewHolder.player.backgroundTintList = colorList mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(surfaceColor) mediaViewHolder.albumView.backgroundTintList = colorList mediaViewHolder.gutsViewHolder.setSurfaceColor(surfaceColor) } Loading Loading @@ -181,36 +173,15 @@ class ColorSchemeTransition internal constructor( mediaViewHolder.seekBar.progressBackgroundTintList = ColorStateList.valueOf(textTertiary) } // Note: This background gradient currently doesn't animate between colors. val backgroundGradient = genericColorTransitionFactory { scheme -> val defaultTintColor = ColorStateList.valueOf(bgColor) if (scheme == null) { mediaViewHolder.albumView.foregroundTintList = defaultTintColor mediaViewHolder.albumView.backgroundTintList = defaultTintColor return@genericColorTransitionFactory } // If there's no album art, just hide the gradient so we show the solid background. val showGradient = mediaViewHolder.albumView.drawable != null val startColor = getColorWithAlpha( backgroundStartFromScheme(scheme), alpha = if (showGradient) .25f else 0f ) val endColor = getColorWithAlpha( backgroundEndFromScheme(scheme), alpha = if (showGradient) .90f else 0f ) val gradientColors = intArrayOf(startColor, endColor) val bgGradientStart = animatingColorTransitionFactory( bgColor, albumGradientPicker(::backgroundStartFromScheme, 0.25f) ) { _ -> updateAlbumGradient() } val foregroundGradient = mediaViewHolder.albumView.foreground?.mutate() if (foregroundGradient is GradientDrawable) { foregroundGradient.colors = gradientColors } val backgroundGradient = mediaViewHolder.albumView.background?.mutate() if (backgroundGradient is GradientDrawable) { backgroundGradient.colors = gradientColors } } val bgGradientEnd = animatingColorTransitionFactory( bgColor, albumGradientPicker(::backgroundEndFromScheme, 0.9f) ) { _ -> updateAlbumGradient() } val colorTransitions = arrayOf( surfaceColor, Loading @@ -220,14 +191,37 @@ class ColorSchemeTransition internal constructor( textPrimaryInverse, textSecondary, textTertiary, backgroundGradient bgGradientStart, bgGradientEnd ) private fun updateAlbumGradient() { val gradient = mediaViewHolder.albumView.foreground?.mutate() if (gradient is GradientDrawable) { gradient.colors = intArrayOf( bgGradientStart?.currentColor ?: 0, bgGradientEnd?.currentColor ?: 0) } } private fun albumGradientPicker( inner: (ColorScheme) -> Int, targetAlpha: Float ): (ColorScheme) -> Int { return { scheme -> if (isGradientEnabled) getColorWithAlpha(inner(scheme), targetAlpha) else Color.TRANSPARENT } } private fun loadDefaultColor(id: Int): Int { return Utils.getColorAttr(context, id).defaultColor } fun updateColorScheme(colorScheme: ColorScheme?) { fun updateColorScheme(colorScheme: ColorScheme?, enableGradient: Boolean) { isGradientEnabled = enableGradient colorTransitions.forEach { it.updateColorScheme(colorScheme) } } } Loading
packages/SystemUI/res/drawable/qs_media_outline_album_bg.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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 --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFFFF" /> <corners android:radius="@dimen/notification_corner_radius"/> </shape>
packages/SystemUI/res/drawable/qs_media_outline_layout_bg.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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 --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00000000" /> <corners android:radius="@dimen/notification_corner_radius"/> </shape>
packages/SystemUI/res/drawable/qs_media_scrim.xml +0 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="@dimen/notification_corner_radius"/> <!-- gradient from 25% in the center to 100% at edges --> <gradient android:type="radial" Loading
packages/SystemUI/res/layout/media_session_view.xml +3 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,8 @@ android:clipToPadding="true" android:gravity="center_horizontal|fill_vertical" android:forceHasOverlappingRendering="false" android:background="@drawable/qs_media_background" android:background="@drawable/qs_media_outline_layout_bg" android:clipToOutline="true" android:theme="@style/MediaPlayer"> <ImageView Loading @@ -40,8 +41,8 @@ android:scaleType="centerCrop" android:adjustViewBounds="true" android:clipToOutline="true" android:background="@drawable/qs_media_outline_album_bg" android:foreground="@drawable/qs_media_scrim" android:background="@drawable/qs_media_scrim" /> <!-- Guideline for output switcher --> Loading
packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt +39 −45 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.animation.ValueAnimator.AnimatorUpdateListener import android.animation.ValueAnimator import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.graphics.drawable.RippleDrawable import com.android.internal.R Loading @@ -37,13 +38,6 @@ interface ColorTransition { fun updateColorScheme(scheme: ColorScheme?) } /** A generic implementation of [ColorTransition] so that we can define a factory method. */ open class GenericColorTransition( private val applyTheme: (ColorScheme?) -> Unit ) : ColorTransition { override fun updateColorScheme(scheme: ColorScheme?) = applyTheme(scheme) } /** * A [ColorTransition] that animates between two specific colors. * It uses a ValueAnimator to execute the animation and interpolate between the source color and Loading Loading @@ -96,7 +90,6 @@ open class AnimatingColorTransition( typealias AnimatingColorTransitionFactory = (Int, (ColorScheme) -> Int, (Int) -> Unit) -> AnimatingColorTransition typealias GenericColorTransitionFactory = ((ColorScheme?) -> Unit) -> GenericColorTransition /** * ColorSchemeTransition constructs a ColorTransition for each color in the scheme Loading @@ -105,23 +98,22 @@ typealias GenericColorTransitionFactory = ((ColorScheme?) -> Unit) -> GenericCol */ class ColorSchemeTransition internal constructor( private val context: Context, mediaViewHolder: MediaViewHolder, animatingColorTransitionFactory: AnimatingColorTransitionFactory, genericColorTransitionFactory: GenericColorTransitionFactory private val mediaViewHolder: MediaViewHolder, animatingColorTransitionFactory: AnimatingColorTransitionFactory ) { constructor(context: Context, mediaViewHolder: MediaViewHolder) : this(context, mediaViewHolder, ::AnimatingColorTransition, ::GenericColorTransition) this(context, mediaViewHolder, ::AnimatingColorTransition) private var isGradientEnabled = true val bgColor = context.getColor(com.android.systemui.R.color.material_dynamic_secondary95) val surfaceColor = animatingColorTransitionFactory( bgColor, ::surfaceFromScheme ) { surfaceColor -> val colorList = ColorStateList.valueOf(surfaceColor) mediaViewHolder.player.backgroundTintList = colorList mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(surfaceColor) mediaViewHolder.albumView.backgroundTintList = colorList mediaViewHolder.gutsViewHolder.setSurfaceColor(surfaceColor) } Loading Loading @@ -181,36 +173,15 @@ class ColorSchemeTransition internal constructor( mediaViewHolder.seekBar.progressBackgroundTintList = ColorStateList.valueOf(textTertiary) } // Note: This background gradient currently doesn't animate between colors. val backgroundGradient = genericColorTransitionFactory { scheme -> val defaultTintColor = ColorStateList.valueOf(bgColor) if (scheme == null) { mediaViewHolder.albumView.foregroundTintList = defaultTintColor mediaViewHolder.albumView.backgroundTintList = defaultTintColor return@genericColorTransitionFactory } // If there's no album art, just hide the gradient so we show the solid background. val showGradient = mediaViewHolder.albumView.drawable != null val startColor = getColorWithAlpha( backgroundStartFromScheme(scheme), alpha = if (showGradient) .25f else 0f ) val endColor = getColorWithAlpha( backgroundEndFromScheme(scheme), alpha = if (showGradient) .90f else 0f ) val gradientColors = intArrayOf(startColor, endColor) val bgGradientStart = animatingColorTransitionFactory( bgColor, albumGradientPicker(::backgroundStartFromScheme, 0.25f) ) { _ -> updateAlbumGradient() } val foregroundGradient = mediaViewHolder.albumView.foreground?.mutate() if (foregroundGradient is GradientDrawable) { foregroundGradient.colors = gradientColors } val backgroundGradient = mediaViewHolder.albumView.background?.mutate() if (backgroundGradient is GradientDrawable) { backgroundGradient.colors = gradientColors } } val bgGradientEnd = animatingColorTransitionFactory( bgColor, albumGradientPicker(::backgroundEndFromScheme, 0.9f) ) { _ -> updateAlbumGradient() } val colorTransitions = arrayOf( surfaceColor, Loading @@ -220,14 +191,37 @@ class ColorSchemeTransition internal constructor( textPrimaryInverse, textSecondary, textTertiary, backgroundGradient bgGradientStart, bgGradientEnd ) private fun updateAlbumGradient() { val gradient = mediaViewHolder.albumView.foreground?.mutate() if (gradient is GradientDrawable) { gradient.colors = intArrayOf( bgGradientStart?.currentColor ?: 0, bgGradientEnd?.currentColor ?: 0) } } private fun albumGradientPicker( inner: (ColorScheme) -> Int, targetAlpha: Float ): (ColorScheme) -> Int { return { scheme -> if (isGradientEnabled) getColorWithAlpha(inner(scheme), targetAlpha) else Color.TRANSPARENT } } private fun loadDefaultColor(id: Int): Int { return Utils.getColorAttr(context, id).defaultColor } fun updateColorScheme(colorScheme: ColorScheme?) { fun updateColorScheme(colorScheme: ColorScheme?, enableGradient: Boolean) { isGradientEnabled = enableGradient colorTransitions.forEach { it.updateColorScheme(colorScheme) } } }