diff --git a/packages/SystemUI/res/layout/media_smartspace_recommendations.xml b/packages/SystemUI/res/layout/media_smartspace_recommendations.xml
index 8c54e2c1cec4f..5fb4819cb8b55 100644
--- a/packages/SystemUI/res/layout/media_smartspace_recommendations.xml
+++ b/packages/SystemUI/res/layout/media_smartspace_recommendations.xml
@@ -46,117 +46,83 @@
+ style="@style/MediaPlayer.AppIcon"/>
+ android:textSize="@dimen/qq_aa_media_rec_header_text_size"
+ android:breakStrategy="balanced"
+ android:hyphenationFrequency="none"/>
-
-
-
-
-
-
-
-
-
-
-
-
36dp
- 10dp
- 18dp
- 72dp
- 8dp
+ 66dp
+ 80dp
+ 8dp
16sp
diff --git a/packages/SystemUI/res/xml/media_recommendation_collapsed.xml b/packages/SystemUI/res/xml/media_recommendation_collapsed.xml
index 31a924cf48927..795c9087cec0f 100644
--- a/packages/SystemUI/res/xml/media_recommendation_collapsed.xml
+++ b/packages/SystemUI/res/xml/media_recommendation_collapsed.xml
@@ -20,10 +20,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/SystemUI/res/xml/media_recommendation_expanded.xml b/packages/SystemUI/res/xml/media_recommendation_expanded.xml
index 1411030a74313..3d03a9a3c52ef 100644
--- a/packages/SystemUI/res/xml/media_recommendation_expanded.xml
+++ b/packages/SystemUI/res/xml/media_recommendation_expanded.xml
@@ -20,10 +20,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index c26a39615812b..a873abf3dc307 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -23,6 +23,7 @@ import android.app.smartspace.SmartspaceAction;
import android.app.smartspace.SmartspaceTarget;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.ColorMatrix;
@@ -511,10 +512,31 @@ public class MediaControlPanel {
return;
}
+ // Set up recommendation card's header.
+ ApplicationInfo applicationInfo = getApplicationInfo(target);
+ if (applicationInfo == null) {
+ Log.w(TAG, "No valid application info is found for media recommendations");
+ return;
+ }
+
+ PackageManager packageManager = mContext.getPackageManager();
+ // Set up media source app's logo.
+ Drawable icon = packageManager.getApplicationIcon(applicationInfo);
+ icon.setColorFilter(getGrayscaleFilter());
+ ImageView headerLogoImageView = mRecommendationViewHolder.getCardIcon();
+ headerLogoImageView.setImageDrawable(icon);
+ // Set up media source app's label text. Fallback to "Play" if the found label is empty.
+ CharSequence appLabel = packageManager.getApplicationLabel(applicationInfo);
+ if (appLabel.length() != 0) {
+ TextView headerTitleText = mRecommendationViewHolder.getCardText();
+ headerTitleText.setText(appLabel);
+ }
+ // Set up media card's tap action if applicable.
+ setSmartspaceRecItemOnClickListener(
+ mRecommendationViewHolder.getRecommendations(), target.getBaseAction());
+
List mediaCoverItems = mRecommendationViewHolder.getMediaCoverItems();
- List mediaLogoItems = mRecommendationViewHolder.getMediaLogoItems();
List mediaCoverItemsResIds = mRecommendationViewHolder.getMediaCoverItemsResIds();
- List mediaLogoItemsResIds = mRecommendationViewHolder.getMediaLogoItemsResIds();
ConstraintSet expandedSet = mMediaViewController.getExpandedLayout();
ConstraintSet collapsedSet = mMediaViewController.getCollapsedLayout();
int mediaRecommendationNum = Math.min(mediaRecommendationList.size(),
@@ -528,50 +550,22 @@ public class MediaControlPanel {
continue;
}
- // Get media source app's logo.
- Bundle extras = recommendation.getExtras();
- Drawable icon = null;
- if (extras != null && extras.getString(EXTRAS_MEDIA_SOURCE_PACKAGE_NAME) != null) {
- // Get the logo from app's package name when applicable.
- String packageName = extras.getString(EXTRAS_MEDIA_SOURCE_PACKAGE_NAME);
- try {
- icon = mContext.getPackageManager().getApplicationIcon(
- packageName);
- icon.setColorFilter(getGrayscaleFilter());
- } catch (PackageManager.NameNotFoundException e) {
- Log.w(TAG, "No media source icon can be fetched via package name", e);
- }
- } else {
- Log.w(TAG, "No media source icon is provided. Skipping this item...");
- continue;
- }
-
- // Set up media source app's logo.
- ImageView mediaSourceLogoImageView = mediaLogoItems.get(uiComponentIndex);
- mediaSourceLogoImageView.setImageDrawable(icon);
-
// Set up media item cover.
ImageView mediaCoverImageView = mediaCoverItems.get(uiComponentIndex);
mediaCoverImageView.setImageIcon(recommendation.getIcon());
- // Set up the click listener if applicable.
+ // Set up the media item's click listener if applicable.
setSmartspaceRecItemOnClickListener(mediaCoverImageView, recommendation);
if (uiComponentIndex < MEDIA_RECOMMENDATION_ITEMS_PER_ROW) {
setVisibleAndAlpha(collapsedSet,
mediaCoverItemsResIds.get(uiComponentIndex), true);
- setVisibleAndAlpha(collapsedSet,
- mediaLogoItemsResIds.get(uiComponentIndex), true);
} else {
setVisibleAndAlpha(collapsedSet,
mediaCoverItemsResIds.get(uiComponentIndex), false);
- setVisibleAndAlpha(collapsedSet,
- mediaLogoItemsResIds.get(uiComponentIndex), false);
}
setVisibleAndAlpha(expandedSet,
mediaCoverItemsResIds.get(uiComponentIndex), true);
- setVisibleAndAlpha(expandedSet,
- mediaLogoItemsResIds.get(uiComponentIndex), true);
uiComponentIndex++;
}
@@ -681,7 +675,8 @@ public class MediaControlPanel {
private void setSmartspaceRecItemOnClickListener(
@NonNull View view,
@NonNull SmartspaceAction action) {
- if (view == null || action == null || action.getIntent() == null) {
+ if (view == null || action == null || action.getIntent() == null
+ || action.getIntent().getExtras() == null) {
Log.e(TAG, "No tap action can be set up");
return;
}
@@ -731,6 +726,38 @@ public class MediaControlPanel {
return false;
}
+ /**
+ * Returns the application info for the media recommendation's source app.
+ *
+ * @param target Smartspace target contains a list of media recommendations. Each item should
+ * contain the same source app's info.
+ *
+ * @return The source app's application info. This value can be null if no valid application
+ * info can be obtained.
+ */
+ private ApplicationInfo getApplicationInfo(@NonNull SmartspaceTarget target) {
+ List mediaRecommendationList = target.getIconGrid();
+ if (mediaRecommendationList == null || mediaRecommendationList.isEmpty()) {
+ return null;
+ }
+
+ for (SmartspaceAction recommendation: mediaRecommendationList) {
+ Bundle extras = recommendation.getExtras();
+ if (extras != null && extras.getString(EXTRAS_MEDIA_SOURCE_PACKAGE_NAME) != null) {
+ // Get the logo from app's package name when applicable.
+ String packageName = extras.getString(EXTRAS_MEDIA_SOURCE_PACKAGE_NAME);
+ try {
+ return mContext.getPackageManager()
+ .getApplicationInfo(packageName, 0 /* flags */);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(TAG, "Fail to get media recommendation's app info", e);
+ }
+ }
+ }
+
+ return null;
+ }
+
/**
* Get the surface given the current end location for MediaViewController
* @return surface used for Smartspace logging
diff --git a/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt b/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt
index 3d0e6533b33b9..a3f991080b1e5 100644
--- a/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/RecommendationViewHolder.kt
@@ -40,13 +40,6 @@ class RecommendationViewHolder private constructor(itemView: View) {
itemView.requireViewById(R.id.media_cover4),
itemView.requireViewById(R.id.media_cover5),
itemView.requireViewById(R.id.media_cover6))
- val mediaLogoItems = listOf(
- itemView.requireViewById(R.id.media_logo1),
- itemView.requireViewById(R.id.media_logo2),
- itemView.requireViewById(R.id.media_logo3),
- itemView.requireViewById(R.id.media_logo4),
- itemView.requireViewById(R.id.media_logo5),
- itemView.requireViewById(R.id.media_logo6))
val mediaCoverItemsResIds = listOf<@IntegerRes Int>(
R.id.media_cover1,
R.id.media_cover2,
@@ -54,13 +47,6 @@ class RecommendationViewHolder private constructor(itemView: View) {
R.id.media_cover4,
R.id.media_cover5,
R.id.media_cover6)
- val mediaLogoItemsResIds = listOf<@IntegerRes Int>(
- R.id.media_logo1,
- R.id.media_logo2,
- R.id.media_logo3,
- R.id.media_logo4,
- R.id.media_logo5,
- R.id.media_logo6)
// Settings/Guts screen
val cancel = itemView.requireViewById(R.id.cancel)
@@ -71,7 +57,6 @@ class RecommendationViewHolder private constructor(itemView: View) {
init {
(recommendations.background as IlluminationDrawable).let { background ->
mediaCoverItems.forEach { background.registerLightSource(it) }
- mediaLogoItems.forEach { background.registerLightSource(it) }
background.registerLightSource(cancel)
background.registerLightSource(dismiss)
background.registerLightSource(dismissLabel)
@@ -109,13 +94,7 @@ class RecommendationViewHolder private constructor(itemView: View) {
R.id.media_cover3,
R.id.media_cover4,
R.id.media_cover5,
- R.id.media_cover6,
- R.id.media_logo1,
- R.id.media_logo2,
- R.id.media_logo3,
- R.id.media_logo4,
- R.id.media_logo5,
- R.id.media_logo6
+ R.id.media_cover6
)
// Res Ids for the components on the guts panel.