Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6444762e authored by shaoweishen's avatar shaoweishen
Browse files

[Output Switcher] Dismiss dialog when play state change to STOP

Dismiss Dialog only when Play state change to STOP.
Dynamically update deivces list height.

Bug: 246958375
Test: Verified on device
Change-Id: I1c5793f012e8a541994cdbb0bf33a3f3ff23309a
parent 4dc75678
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1174,6 +1174,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>
+10 −3
Original line number Diff line number Diff line
@@ -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 = () -> {
        // Set max height for list
        if (mDeviceListLayout.getHeight() > mListMaxHeight) {
        ViewGroup.LayoutParams params = mDeviceListLayout.getLayoutParams();
            params.height = mListMaxHeight;
        int totalItemsHeight = mAdapter.getItemCount() * mItemHeight;
        int correctHeight = Math.min(totalItemsHeight, mListMaxHeight);
        // Set max height for list
        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
+1 −1
Original line number Diff line number Diff line
@@ -1013,7 +1013,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;