Merge "Add SMARTSPACE_CARD_RENDERED for media card" into sc-dev
This commit is contained in:
@@ -184,7 +184,14 @@ class MediaCarouselController @Inject constructor(
|
||||
true /* persistent */)
|
||||
mediaManager.addListener(object : MediaDataManager.Listener {
|
||||
override fun onMediaDataLoaded(key: String, oldKey: String?, data: MediaData) {
|
||||
addOrUpdatePlayer(key, oldKey, data)
|
||||
if (addOrUpdatePlayer(key, oldKey, data)) {
|
||||
MediaPlayerData.getMediaPlayer(key, null)?.let {
|
||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||
it.mInstanceId,
|
||||
/* isRecommendationCard */ false,
|
||||
it.surfaceForSmartspaceLogging)
|
||||
}
|
||||
}
|
||||
val canRemove = data.isPlaying?.let { !it } ?: data.isClearable && !data.active
|
||||
if (canRemove && !Utils.useMediaResumption(context)) {
|
||||
// This view isn't playing, let's remove this! This happens e.g when
|
||||
@@ -203,6 +210,12 @@ class MediaCarouselController @Inject constructor(
|
||||
override fun onSmartspaceMediaDataLoaded(key: String, data: SmartspaceTarget) {
|
||||
Log.d(TAG, "My Smartspace media update is here")
|
||||
addSmartspaceMediaRecommendations(key, data)
|
||||
MediaPlayerData.getMediaPlayer(key, null)?.let {
|
||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||
it.mInstanceId,
|
||||
/* isRecommendationCard */ true,
|
||||
it.surfaceForSmartspaceLogging)
|
||||
}
|
||||
if (mediaCarouselScrollHandler.visibleToUser) {
|
||||
logSmartspaceImpression()
|
||||
}
|
||||
@@ -276,7 +289,8 @@ class MediaCarouselController @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun addOrUpdatePlayer(key: String, oldKey: String?, data: MediaData) {
|
||||
// Returns true if new player is added
|
||||
private fun addOrUpdatePlayer(key: String, oldKey: String?, data: MediaData): Boolean {
|
||||
val dataCopy = data.copy(backgroundColor = bgColor)
|
||||
val existingPlayer = MediaPlayerData.getMediaPlayer(key, oldKey)
|
||||
if (existingPlayer == null) {
|
||||
@@ -309,6 +323,7 @@ class MediaCarouselController @Inject constructor(
|
||||
if (MediaPlayerData.players().size != mediaContent.childCount) {
|
||||
Log.wtf(TAG, "Size of players list and number of views in carousel are out of sync")
|
||||
}
|
||||
return existingPlayer == null
|
||||
}
|
||||
|
||||
private fun addSmartspaceMediaRecommendations(key: String, data: SmartspaceTarget) {
|
||||
|
||||
@@ -276,7 +276,7 @@ public class MediaControlPanel {
|
||||
if (mMediaViewController.isGutsVisible()) return;
|
||||
|
||||
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
|
||||
false);
|
||||
/* isRecommendationCard */ false);
|
||||
mActivityStarter.postStartActivityDismissingKeyguard(clickIntent,
|
||||
buildLaunchAnimatorController(mPlayerViewHolder.getPlayer()));
|
||||
});
|
||||
@@ -384,7 +384,7 @@ public class MediaControlPanel {
|
||||
button.setEnabled(true);
|
||||
button.setOnClickListener(v -> {
|
||||
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
|
||||
false);
|
||||
/* isRecommendationCard */ false);
|
||||
action.run();
|
||||
});
|
||||
}
|
||||
@@ -418,7 +418,7 @@ public class MediaControlPanel {
|
||||
mPlayerViewHolder.getDismiss().setEnabled(isDismissible);
|
||||
mPlayerViewHolder.getDismiss().setOnClickListener(v -> {
|
||||
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
|
||||
false);
|
||||
/* isRecommendationCard */ false);
|
||||
|
||||
if (mKey != null) {
|
||||
closeGuts();
|
||||
@@ -563,7 +563,7 @@ public class MediaControlPanel {
|
||||
// Set up long press to show guts setting panel.
|
||||
mRecommendationViewHolder.getDismiss().setOnClickListener(v -> {
|
||||
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
|
||||
true);
|
||||
/* isRecommendationCard */ true);
|
||||
closeGuts();
|
||||
mKeyguardDismissUtil.executeWhenUnlocked(() -> {
|
||||
mMediaDataManagerLazy.get().dismissSmartspaceRecommendation(
|
||||
@@ -668,7 +668,7 @@ public class MediaControlPanel {
|
||||
view.setOnClickListener(v -> {
|
||||
// When media recommendation card is shown, it will always be the top card.
|
||||
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
|
||||
true);
|
||||
/* isRecommendationCard */ true);
|
||||
|
||||
if (shouldSmartspaceRecItemOpenInForeground(action)) {
|
||||
// Request to unlock the device if the activity needs to be opened in foreground.
|
||||
|
||||
Reference in New Issue
Block a user