Merge "[Media] Simplify how we get the background color for the media player." into tm-dev am: 0943028db7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17756692 Change-Id: I88f19ec0544bb72ee42d043b454a9b2d5d6a4f31 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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()) {
|
||||||
|
|||||||
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import org.mockito.junit.MockitoJUnit
|
|||||||
|
|
||||||
private const val DEFAULT_COLOR = Color.RED
|
private const val DEFAULT_COLOR = Color.RED
|
||||||
private const val TARGET_COLOR = Color.BLUE
|
private const val TARGET_COLOR = Color.BLUE
|
||||||
private const val BG_COLOR = Color.GREEN
|
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner::class)
|
@RunWith(AndroidTestingRunner::class)
|
||||||
@@ -66,8 +65,7 @@ class ColorSchemeTransitionTest : SysuiTestCase() {
|
|||||||
transitionFactory = { default, extractColor, applyColor -> mockTransition }
|
transitionFactory = { default, extractColor, applyColor -> mockTransition }
|
||||||
whenever(extractColor.invoke(colorScheme)).thenReturn(TARGET_COLOR)
|
whenever(extractColor.invoke(colorScheme)).thenReturn(TARGET_COLOR)
|
||||||
|
|
||||||
colorSchemeTransition = ColorSchemeTransition(context,
|
colorSchemeTransition = ColorSchemeTransition(context, mediaViewHolder, transitionFactory)
|
||||||
BG_COLOR, mediaViewHolder, transitionFactory)
|
|
||||||
|
|
||||||
colorTransition = object : ColorTransition(DEFAULT_COLOR, extractColor, applyColor) {
|
colorTransition = object : ColorTransition(DEFAULT_COLOR, extractColor, applyColor) {
|
||||||
override fun buildAnimator(): ValueAnimator {
|
override fun buildAnimator(): ValueAnimator {
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ import org.mockito.Mockito.verify
|
|||||||
import org.mockito.junit.MockitoJUnit
|
import org.mockito.junit.MockitoJUnit
|
||||||
|
|
||||||
private const val KEY = "TEST_KEY"
|
private const val KEY = "TEST_KEY"
|
||||||
private const val BG_COLOR = Color.RED
|
|
||||||
private const val PACKAGE = "PKG"
|
private const val PACKAGE = "PKG"
|
||||||
private const val ARTIST = "ARTIST"
|
private const val ARTIST = "ARTIST"
|
||||||
private const val TITLE = "TITLE"
|
private const val TITLE = "TITLE"
|
||||||
@@ -247,7 +246,6 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
session.setActive(true)
|
session.setActive(true)
|
||||||
|
|
||||||
mediaData = MediaTestUtils.emptyMediaData.copy(
|
mediaData = MediaTestUtils.emptyMediaData.copy(
|
||||||
backgroundColor = BG_COLOR,
|
|
||||||
artist = ARTIST,
|
artist = ARTIST,
|
||||||
song = TITLE,
|
song = TITLE,
|
||||||
packageName = PACKAGE,
|
packageName = PACKAGE,
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
private static final String OLD_KEY = "TEST_KEY_OLD";
|
private static final String OLD_KEY = "TEST_KEY_OLD";
|
||||||
private static final String APP = "APP";
|
private static final String APP = "APP";
|
||||||
private static final String PACKAGE = "PKG";
|
private static final String PACKAGE = "PKG";
|
||||||
private static final int BG_COLOR = Color.RED;
|
|
||||||
private static final String ARTIST = "ARTIST";
|
private static final String ARTIST = "ARTIST";
|
||||||
private static final String TITLE = "TITLE";
|
private static final String TITLE = "TITLE";
|
||||||
private static final String DEVICE_NAME = "DEVICE_NAME";
|
private static final String DEVICE_NAME = "DEVICE_NAME";
|
||||||
@@ -76,7 +75,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
mManager.addListener(mListener);
|
mManager.addListener(mListener);
|
||||||
|
|
||||||
mMediaData = new MediaData(
|
mMediaData = new MediaData(
|
||||||
USER_ID, true, BG_COLOR, APP, null, ARTIST, TITLE, null,
|
USER_ID, true, APP, null, ARTIST, TITLE, null,
|
||||||
new ArrayList<>(), new ArrayList<>(), null, PACKAGE, null, null, null, true, null,
|
new ArrayList<>(), new ArrayList<>(), null, PACKAGE, null, null, null, true, null,
|
||||||
MediaData.PLAYBACK_LOCAL, false, KEY, false, false, false, 0L,
|
MediaData.PLAYBACK_LOCAL, false, KEY, false, false, false, 0L,
|
||||||
InstanceId.fakeInstanceId(-1), -1);
|
InstanceId.fakeInstanceId(-1), -1);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ class MediaTestUtils {
|
|||||||
val emptyMediaData = MediaData(
|
val emptyMediaData = MediaData(
|
||||||
userId = 0,
|
userId = 0,
|
||||||
initialized = true,
|
initialized = true,
|
||||||
backgroundColor = 0,
|
|
||||||
app = null,
|
app = null,
|
||||||
appIcon = null,
|
appIcon = null,
|
||||||
artist = null,
|
artist = null,
|
||||||
|
|||||||
Reference in New Issue
Block a user