Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0943028d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Media] Simplify how we get the background color for the media player." into tm-dev

parents 22dc6e9e f9c2af71
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -85,12 +85,13 @@ typealias ColorTransitionFactory = (Int, (ColorScheme) -> Int, (Int) -> Unit) ->
 */
 */
class ColorSchemeTransition internal constructor(
class ColorSchemeTransition internal constructor(
    private val context: Context,
    private val context: Context,
    bgColor: Int,
    mediaViewHolder: MediaViewHolder,
    mediaViewHolder: MediaViewHolder,
    colorTransitionFactory: ColorTransitionFactory
    colorTransitionFactory: ColorTransitionFactory
) {
) {
    constructor(context: Context, bgColor: Int, mediaViewHolder: MediaViewHolder) :
    constructor(context: Context, mediaViewHolder: MediaViewHolder) :
        this(context, bgColor, mediaViewHolder, ::ColorTransition)
        this(context, mediaViewHolder, ::ColorTransition)

    val bgColor = context.getColor(com.android.systemui.R.color.material_dynamic_secondary95)


    val surfaceColor = colorTransitionFactory(
    val surfaceColor = colorTransitionFactory(
        bgColor,
        bgColor,
+0 −1
Original line number Original line Diff line number Diff line
@@ -904,7 +904,6 @@ internal object MediaPlayerData {
    private val EMPTY = MediaData(
    private val EMPTY = MediaData(
            userId = -1,
            userId = -1,
            initialized = false,
            initialized = false,
            backgroundColor = 0,
            app = null,
            app = null,
            appIcon = null,
            appIcon = null,
            artist = null,
            artist = null,
+4 −7
Original line number Original line Diff line number Diff line
@@ -150,7 +150,6 @@ public class MediaControlPanel {
    private MediaSession.Token mToken;
    private MediaSession.Token mToken;
    private MediaController mController;
    private MediaController mController;
    private Lazy<MediaDataManager> mMediaDataManagerLazy;
    private Lazy<MediaDataManager> mMediaDataManagerLazy;
    private int mBackgroundColor;
    // Uid for the media app.
    // Uid for the media app.
    protected int mUid = Process.INVALID_UID;
    protected int mUid = Process.INVALID_UID;
    private int mSmartspaceMediaItemsCount;
    private int mSmartspaceMediaItemsCount;
@@ -343,8 +342,7 @@ public class MediaControlPanel {
        AnimatorSet exit = loadAnimator(R.anim.media_metadata_exit,
        AnimatorSet exit = loadAnimator(R.anim.media_metadata_exit,
                Interpolators.EMPHASIZED_ACCELERATE, titleText, artistText);
                Interpolators.EMPHASIZED_ACCELERATE, titleText, artistText);


        mColorSchemeTransition = new ColorSchemeTransition(
        mColorSchemeTransition = new ColorSchemeTransition(mContext, mMediaViewHolder);
            mContext, mBackgroundColor, mMediaViewHolder);
        mMetadataAnimationHandler = new MetadataAnimationHandler(exit, enter);
        mMetadataAnimationHandler = new MetadataAnimationHandler(exit, enter);
    }
    }


@@ -409,7 +407,6 @@ public class MediaControlPanel {
        }
        }
        mInstanceId = data.getInstanceId();
        mInstanceId = data.getInstanceId();


        mBackgroundColor = data.getBackgroundColor();
        if (mToken == null || !mToken.equals(token)) {
        if (mToken == null || !mToken.equals(token)) {
            mToken = token;
            mToken = token;
        }
        }
@@ -485,7 +482,7 @@ public class MediaControlPanel {
            Drawable icon = device.getIcon();
            Drawable icon = device.getIcon();
            if (icon instanceof AdaptiveIcon) {
            if (icon instanceof AdaptiveIcon) {
                AdaptiveIcon aIcon = (AdaptiveIcon) icon;
                AdaptiveIcon aIcon = (AdaptiveIcon) icon;
                aIcon.setBackgroundColor(mBackgroundColor);
                aIcon.setBackgroundColor(mColorSchemeTransition.getBgColor());
                iconView.setImageDrawable(aIcon);
                iconView.setImageDrawable(aIcon);
            } else {
            } else {
                iconView.setImageDrawable(icon);
                iconView.setImageDrawable(icon);
@@ -956,11 +953,11 @@ public class MediaControlPanel {
        }
        }


        mSmartspaceId = SmallHash.hash(data.getTargetId());
        mSmartspaceId = SmallHash.hash(data.getTargetId());
        mBackgroundColor = data.getBackgroundColor();
        int backgroundColor = data.getBackgroundColor();
        mPackageName = data.getPackageName();
        mPackageName = data.getPackageName();
        mInstanceId = data.getInstanceId();
        mInstanceId = data.getInstanceId();
        TransitionLayout recommendationCard = mRecommendationViewHolder.getRecommendations();
        TransitionLayout recommendationCard = mRecommendationViewHolder.getRecommendations();
        recommendationCard.setBackgroundTintList(ColorStateList.valueOf(mBackgroundColor));
        recommendationCard.setBackgroundTintList(ColorStateList.valueOf(backgroundColor));


        List<SmartspaceAction> mediaRecommendationList = data.getRecommendations();
        List<SmartspaceAction> mediaRecommendationList = data.getRecommendations();
        if (mediaRecommendationList == null || mediaRecommendationList.isEmpty()) {
        if (mediaRecommendationList == null || mediaRecommendationList.isEmpty()) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import com.android.systemui.R
data class MediaData(
data class MediaData(
    val userId: Int,
    val userId: Int,
    val initialized: Boolean = false,
    val initialized: Boolean = false,
    val backgroundColor: Int,
    /**
    /**
     * App name that will be displayed on the player.
     * App name that will be displayed on the player.
     */
     */
+2 −4
Original line number Original line Diff line number Diff line
@@ -85,7 +85,6 @@ private const val EXTRAS_SMARTSPACE_DISMISS_INTENT_KEY = "dismiss_intent"
private val LOADING = MediaData(
private val LOADING = MediaData(
        userId = -1,
        userId = -1,
        initialized = false,
        initialized = false,
        backgroundColor = 0,
        app = null,
        app = null,
        appIcon = null,
        appIcon = null,
        artist = null,
        artist = null,
@@ -177,7 +176,6 @@ class MediaDataManager(


    private val themeText = com.android.settingslib.Utils.getColorAttr(context,
    private val themeText = com.android.settingslib.Utils.getColorAttr(context,
            com.android.internal.R.attr.textColorPrimary).defaultColor
            com.android.internal.R.attr.textColorPrimary).defaultColor
    private val bgColor = context.getColor(R.color.material_dynamic_secondary95)


    // Internal listeners are part of the internal pipeline. External listeners (those registered
    // Internal listeners are part of the internal pipeline. External listeners (those registered
    // with [MediaDeviceManager.addListener]) receive events after they have propagated through
    // with [MediaDeviceManager.addListener]) receive events after they have propagated through
@@ -591,7 +589,7 @@ class MediaDataManager(
        val mediaAction = getResumeMediaAction(resumeAction)
        val mediaAction = getResumeMediaAction(resumeAction)
        val lastActive = systemClock.elapsedRealtime()
        val lastActive = systemClock.elapsedRealtime()
        foregroundExecutor.execute {
        foregroundExecutor.execute {
            onMediaDataLoaded(packageName, null, MediaData(userId, true, bgColor, appName,
            onMediaDataLoaded(packageName, null, MediaData(userId, true, appName,
                    null, desc.subtitle, desc.title, artworkIcon, listOf(mediaAction), listOf(0),
                    null, desc.subtitle, desc.title, artworkIcon, listOf(mediaAction), listOf(0),
                    MediaButton(playOrPause = mediaAction), packageName, token, appIntent,
                    MediaButton(playOrPause = mediaAction), packageName, token, appIntent,
                    device = null, active = false,
                    device = null, active = false,
@@ -713,7 +711,7 @@ class MediaDataManager(
            val resumeAction: Runnable? = mediaEntries[key]?.resumeAction
            val resumeAction: Runnable? = mediaEntries[key]?.resumeAction
            val hasCheckedForResume = mediaEntries[key]?.hasCheckedForResume == true
            val hasCheckedForResume = mediaEntries[key]?.hasCheckedForResume == true
            val active = mediaEntries[key]?.active ?: true
            val active = mediaEntries[key]?.active ?: true
            onMediaDataLoaded(key, oldKey, MediaData(sbn.normalizedUserId, true, bgColor, app,
            onMediaDataLoaded(key, oldKey, MediaData(sbn.normalizedUserId, true, app,
                    smallIcon, artist, song, artWorkIcon, actionIcons, actionsToShowCollapsed,
                    smallIcon, artist, song, artWorkIcon, actionIcons, actionsToShowCollapsed,
                    semanticActions, sbn.packageName, token, notif.contentIntent, device,
                    semanticActions, sbn.packageName, token, notif.contentIntent, device,
                    active, resumeAction = resumeAction, playbackLocation = playbackLocation,
                    active, resumeAction = resumeAction, playbackLocation = playbackLocation,
Loading