Loading packages/SystemUI/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,10 @@ <!-- The number of rows in the QuickSettings --> <integer name="quick_settings_max_rows">4</integer> <!-- If the dp width of the available space is <= this value, potentially adjust the number of media recommendation items--> <integer name="default_qs_media_rec_width_dp">380</integer> <!-- The number of columns that the top level tiles span in the QuickSettings --> <!-- The default tiles to display in QuickSettings --> Loading packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1094,6 +1094,7 @@ <dimen name="qs_media_session_collapsed_guideline">144dp</dimen> <!-- Size of Smartspace media recommendations cards in the QSPanel carousel --> <dimen name="qs_media_rec_default_width">380dp</dimen> <dimen name="qs_media_rec_icon_top_margin">16dp</dimen> <dimen name="qs_media_rec_album_icon_size">16dp</dimen> <dimen name="qs_media_rec_album_size">88dp</dimen> Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt +3 −2 Original line number Diff line number Diff line Loading @@ -109,10 +109,11 @@ constructor( private val keyguardTransitionInteractor: KeyguardTransitionInteractor, ) : Dumpable { /** The current width of the carousel */ private var currentCarouselWidth: Int = 0 var currentCarouselWidth: Int = 0 private set /** The current height of the carousel */ @VisibleForTesting var currentCarouselHeight: Int = 0 private var currentCarouselHeight: Int = 0 /** Are we currently showing only active players */ private var currentlyShowingOnlyActive: Boolean = false Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaControlPanel.java +62 −4 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BlendMode; import android.graphics.Color; Loading @@ -54,6 +56,7 @@ import android.os.Process; import android.os.Trace; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -468,6 +471,7 @@ public class MediaControlPanel { TransitionLayout recommendations = vh.getRecommendations(); mMediaViewController.attach(recommendations, MediaViewController.TYPE.RECOMMENDATION); mMediaViewController.configurationChangeListener = this::updateRecommendationsVisibility; mRecommendationViewHolder.getRecommendations().setOnLongClickListener(v -> { if (mFalsingManager.isFalseLongTap(FalsingManager.LOW_PENALTY)) return true; Loading Loading @@ -1364,6 +1368,7 @@ public class MediaControlPanel { boolean hasTitle = false; boolean hasSubtitle = false; int fittedRecsNum = getNumberOfFittedRecommendations(); for (int itemIndex = 0; itemIndex < NUM_REQUIRED_RECOMMENDATIONS; itemIndex++) { SmartspaceAction recommendation = recommendations.get(itemIndex); Loading Loading @@ -1444,12 +1449,20 @@ public class MediaControlPanel { // If there's no subtitles and/or titles for any of the albums, hide those views. ConstraintSet expandedSet = mMediaViewController.getExpandedLayout(); ConstraintSet collapsedSet = mMediaViewController.getCollapsedLayout(); final boolean titlesVisible = hasTitle; final boolean subtitlesVisible = hasSubtitle; mRecommendationViewHolder.getMediaTitles().forEach((titleView) -> setVisibleAndAlpha(expandedSet, titleView.getId(), titlesVisible)); mRecommendationViewHolder.getMediaSubtitles().forEach((subtitleView) -> setVisibleAndAlpha(expandedSet, subtitleView.getId(), subtitlesVisible)); mRecommendationViewHolder.getMediaTitles().forEach((titleView) -> { setVisibleAndAlpha(expandedSet, titleView.getId(), titlesVisible); setVisibleAndAlpha(collapsedSet, titleView.getId(), titlesVisible); }); mRecommendationViewHolder.getMediaSubtitles().forEach((subtitleView) -> { setVisibleAndAlpha(expandedSet, subtitleView.getId(), subtitlesVisible); setVisibleAndAlpha(collapsedSet, subtitleView.getId(), subtitlesVisible); }); // Media covers visibility. setMediaCoversVisibility(fittedRecsNum); // Guts Runnable onDismissClickedRunnable = () -> { Loading Loading @@ -1486,6 +1499,51 @@ public class MediaControlPanel { Trace.endSection(); } private Unit updateRecommendationsVisibility() { int fittedRecsNum = getNumberOfFittedRecommendations(); setMediaCoversVisibility(fittedRecsNum); return Unit.INSTANCE; } private void setMediaCoversVisibility(int fittedRecsNum) { ConstraintSet expandedSet = mMediaViewController.getExpandedLayout(); ConstraintSet collapsedSet = mMediaViewController.getCollapsedLayout(); List<ViewGroup> mediaCoverContainers = mRecommendationViewHolder.getMediaCoverContainers(); // Hide media cover that cannot fit in the recommendation card. for (int itemIndex = 0; itemIndex < NUM_REQUIRED_RECOMMENDATIONS; itemIndex++) { setVisibleAndAlpha(expandedSet, mediaCoverContainers.get(itemIndex).getId(), itemIndex < fittedRecsNum); setVisibleAndAlpha(collapsedSet, mediaCoverContainers.get(itemIndex).getId(), itemIndex < fittedRecsNum); } } @VisibleForTesting protected int getNumberOfFittedRecommendations() { Resources res = mContext.getResources(); Configuration config = res.getConfiguration(); int defaultDpWidth = res.getInteger(R.integer.default_qs_media_rec_width_dp); int recCoverWidth = res.getDimensionPixelSize(R.dimen.qs_media_rec_album_width) + res.getDimensionPixelSize(R.dimen.qs_media_info_spacing) * 2; // On landscape, media controls should take half of the screen width. int displayAvailableDpWidth = config.screenWidthDp; if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { displayAvailableDpWidth = displayAvailableDpWidth / 2; } int fittedNum; if (displayAvailableDpWidth > defaultDpWidth) { int recCoverDefaultWidth = res.getDimensionPixelSize( R.dimen.qs_media_rec_default_width); fittedNum = recCoverDefaultWidth / recCoverWidth; } else { int displayAvailableWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, displayAvailableDpWidth, res.getDisplayMetrics()); fittedNum = displayAvailableWidth / recCoverWidth; } return Math.min(fittedNum, NUM_REQUIRED_RECOMMENDATIONS); } private void fetchAndUpdateRecommendationColors(Drawable appIcon) { mBackgroundExecutor.execute(() -> { ColorScheme colorScheme = new ColorScheme( Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ constructor( /** A listener when the current dimensions of the player change */ lateinit var sizeChangedListener: () -> Unit lateinit var configurationChangeListener: () -> Unit private var firstRefresh: Boolean = true @VisibleForTesting private var transitionLayout: TransitionLayout? = null private val layoutController = TransitionLayoutController() Loading Loading @@ -195,6 +196,10 @@ constructor( ) } } if (this@MediaViewController::configurationChangeListener.isInitialized) { configurationChangeListener.invoke() refreshState() } } } } Loading Loading
packages/SystemUI/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,10 @@ <!-- The number of rows in the QuickSettings --> <integer name="quick_settings_max_rows">4</integer> <!-- If the dp width of the available space is <= this value, potentially adjust the number of media recommendation items--> <integer name="default_qs_media_rec_width_dp">380</integer> <!-- The number of columns that the top level tiles span in the QuickSettings --> <!-- The default tiles to display in QuickSettings --> Loading
packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1094,6 +1094,7 @@ <dimen name="qs_media_session_collapsed_guideline">144dp</dimen> <!-- Size of Smartspace media recommendations cards in the QSPanel carousel --> <dimen name="qs_media_rec_default_width">380dp</dimen> <dimen name="qs_media_rec_icon_top_margin">16dp</dimen> <dimen name="qs_media_rec_album_icon_size">16dp</dimen> <dimen name="qs_media_rec_album_size">88dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt +3 −2 Original line number Diff line number Diff line Loading @@ -109,10 +109,11 @@ constructor( private val keyguardTransitionInteractor: KeyguardTransitionInteractor, ) : Dumpable { /** The current width of the carousel */ private var currentCarouselWidth: Int = 0 var currentCarouselWidth: Int = 0 private set /** The current height of the carousel */ @VisibleForTesting var currentCarouselHeight: Int = 0 private var currentCarouselHeight: Int = 0 /** Are we currently showing only active players */ private var currentlyShowingOnlyActive: Boolean = false Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaControlPanel.java +62 −4 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BlendMode; import android.graphics.Color; Loading @@ -54,6 +56,7 @@ import android.os.Process; import android.os.Trace; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -468,6 +471,7 @@ public class MediaControlPanel { TransitionLayout recommendations = vh.getRecommendations(); mMediaViewController.attach(recommendations, MediaViewController.TYPE.RECOMMENDATION); mMediaViewController.configurationChangeListener = this::updateRecommendationsVisibility; mRecommendationViewHolder.getRecommendations().setOnLongClickListener(v -> { if (mFalsingManager.isFalseLongTap(FalsingManager.LOW_PENALTY)) return true; Loading Loading @@ -1364,6 +1368,7 @@ public class MediaControlPanel { boolean hasTitle = false; boolean hasSubtitle = false; int fittedRecsNum = getNumberOfFittedRecommendations(); for (int itemIndex = 0; itemIndex < NUM_REQUIRED_RECOMMENDATIONS; itemIndex++) { SmartspaceAction recommendation = recommendations.get(itemIndex); Loading Loading @@ -1444,12 +1449,20 @@ public class MediaControlPanel { // If there's no subtitles and/or titles for any of the albums, hide those views. ConstraintSet expandedSet = mMediaViewController.getExpandedLayout(); ConstraintSet collapsedSet = mMediaViewController.getCollapsedLayout(); final boolean titlesVisible = hasTitle; final boolean subtitlesVisible = hasSubtitle; mRecommendationViewHolder.getMediaTitles().forEach((titleView) -> setVisibleAndAlpha(expandedSet, titleView.getId(), titlesVisible)); mRecommendationViewHolder.getMediaSubtitles().forEach((subtitleView) -> setVisibleAndAlpha(expandedSet, subtitleView.getId(), subtitlesVisible)); mRecommendationViewHolder.getMediaTitles().forEach((titleView) -> { setVisibleAndAlpha(expandedSet, titleView.getId(), titlesVisible); setVisibleAndAlpha(collapsedSet, titleView.getId(), titlesVisible); }); mRecommendationViewHolder.getMediaSubtitles().forEach((subtitleView) -> { setVisibleAndAlpha(expandedSet, subtitleView.getId(), subtitlesVisible); setVisibleAndAlpha(collapsedSet, subtitleView.getId(), subtitlesVisible); }); // Media covers visibility. setMediaCoversVisibility(fittedRecsNum); // Guts Runnable onDismissClickedRunnable = () -> { Loading Loading @@ -1486,6 +1499,51 @@ public class MediaControlPanel { Trace.endSection(); } private Unit updateRecommendationsVisibility() { int fittedRecsNum = getNumberOfFittedRecommendations(); setMediaCoversVisibility(fittedRecsNum); return Unit.INSTANCE; } private void setMediaCoversVisibility(int fittedRecsNum) { ConstraintSet expandedSet = mMediaViewController.getExpandedLayout(); ConstraintSet collapsedSet = mMediaViewController.getCollapsedLayout(); List<ViewGroup> mediaCoverContainers = mRecommendationViewHolder.getMediaCoverContainers(); // Hide media cover that cannot fit in the recommendation card. for (int itemIndex = 0; itemIndex < NUM_REQUIRED_RECOMMENDATIONS; itemIndex++) { setVisibleAndAlpha(expandedSet, mediaCoverContainers.get(itemIndex).getId(), itemIndex < fittedRecsNum); setVisibleAndAlpha(collapsedSet, mediaCoverContainers.get(itemIndex).getId(), itemIndex < fittedRecsNum); } } @VisibleForTesting protected int getNumberOfFittedRecommendations() { Resources res = mContext.getResources(); Configuration config = res.getConfiguration(); int defaultDpWidth = res.getInteger(R.integer.default_qs_media_rec_width_dp); int recCoverWidth = res.getDimensionPixelSize(R.dimen.qs_media_rec_album_width) + res.getDimensionPixelSize(R.dimen.qs_media_info_spacing) * 2; // On landscape, media controls should take half of the screen width. int displayAvailableDpWidth = config.screenWidthDp; if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { displayAvailableDpWidth = displayAvailableDpWidth / 2; } int fittedNum; if (displayAvailableDpWidth > defaultDpWidth) { int recCoverDefaultWidth = res.getDimensionPixelSize( R.dimen.qs_media_rec_default_width); fittedNum = recCoverDefaultWidth / recCoverWidth; } else { int displayAvailableWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, displayAvailableDpWidth, res.getDisplayMetrics()); fittedNum = displayAvailableWidth / recCoverWidth; } return Math.min(fittedNum, NUM_REQUIRED_RECOMMENDATIONS); } private void fetchAndUpdateRecommendationColors(Drawable appIcon) { mBackgroundExecutor.execute(() -> { ColorScheme colorScheme = new ColorScheme( Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ constructor( /** A listener when the current dimensions of the player change */ lateinit var sizeChangedListener: () -> Unit lateinit var configurationChangeListener: () -> Unit private var firstRefresh: Boolean = true @VisibleForTesting private var transitionLayout: TransitionLayout? = null private val layoutController = TransitionLayoutController() Loading Loading @@ -195,6 +196,10 @@ constructor( ) } } if (this@MediaViewController::configurationChangeListener.isInitialized) { configurationChangeListener.invoke() refreshState() } } } } Loading