diff options
3 files changed, 12 insertions, 4 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 21799fc3d47e..fd47ec6223c3 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1187,6 +1187,7 @@ <!-- Output switcher panel related dimensions --> <dimen name="media_output_dialog_list_max_height">355dp</dimen> + <dimen name="media_output_dialog_list_item_height">76dp</dimen> <dimen name="media_output_dialog_header_album_icon_size">72dp</dimen> <dimen name="media_output_dialog_header_back_icon_size">32dp</dimen> <dimen name="media_output_dialog_header_icon_padding">16dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java index 2d09ddd7f630..b5166899dafa 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java @@ -99,6 +99,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements private Button mStopButton; private Button mAppButton; private int mListMaxHeight; + private int mItemHeight; private WallpaperColors mWallpaperColors; private Executor mExecutor; private boolean mShouldLaunchLeBroadcastDialog; @@ -106,10 +107,12 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements MediaOutputBaseAdapter mAdapter; private final ViewTreeObserver.OnGlobalLayoutListener mDeviceListLayoutListener = () -> { + ViewGroup.LayoutParams params = mDeviceListLayout.getLayoutParams(); + int totalItemsHeight = mAdapter.getItemCount() * mItemHeight; + int correctHeight = Math.min(totalItemsHeight, mListMaxHeight); // Set max height for list - if (mDeviceListLayout.getHeight() > mListMaxHeight) { - ViewGroup.LayoutParams params = mDeviceListLayout.getLayoutParams(); - params.height = mListMaxHeight; + if (correctHeight != params.height) { + params.height = correctHeight; mDeviceListLayout.setLayoutParams(params); } }; @@ -212,6 +215,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements mLayoutManager = new LayoutManagerWrapper(mContext); mListMaxHeight = context.getResources().getDimensionPixelSize( R.dimen.media_output_dialog_list_max_height); + mItemHeight = context.getResources().getDimensionPixelSize( + R.dimen.media_output_dialog_list_item_height); mExecutor = Executors.newSingleThreadExecutor(); } @@ -246,8 +251,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements mDeviceListLayout.getViewTreeObserver().addOnGlobalLayoutListener( mDeviceListLayoutListener); // Init device list + mLayoutManager.setAutoMeasureEnabled(true); mDevicesRecyclerView.setLayoutManager(mLayoutManager); mDevicesRecyclerView.setAdapter(mAdapter); + mDevicesRecyclerView.setHasFixedSize(false); // Init header icon mHeaderIcon.setOnClickListener(v -> onHeaderIconClick()); // Init bottom buttons diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java index f040e067bc6d..3f72b224d61e 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java @@ -995,7 +995,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, return; } - if (newState == PlaybackState.STATE_STOPPED || newState == PlaybackState.STATE_PAUSED) { + if (newState == PlaybackState.STATE_STOPPED) { mCallback.onMediaStoppedOrPaused(); } mCurrentState = newState; |