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

Commit d38b82c1 authored by Alex Shabalin's avatar Alex Shabalin
Browse files

Fix the UI for the `UserManager.DISALLOW_ADJUST_VOLUME` option.

- Fix the presence of SeekBar from the group state UI when the volume
adjustment is forbidden.
- Fix rendering of state-specific UI and click listeners when the
`DISALLOW_ADJUST_VOLUME` is enabled.

Flag: EXEMPT bugfix
Bug: 394419155
Fix: 394419155
Test: atest SystemUIGoogleRoboRNGTests:MediaOutputAdapterScreenshotTest,
    atest SystemUiRoboTests:MediaOutputAdapterTest
Change-Id: Ibd327d945633bd4f6c23b293242aecb414d2bc7b
parent 9caa2ad8
Loading
Loading
Loading
Loading
+11 −16
Original line number Diff line number Diff line
@@ -820,25 +820,20 @@ public class MediaOutputAdapterTest extends SysuiTestCase {

    @DisableFlags(Flags.FLAG_ENABLE_OUTPUT_SWITCHER_SESSION_GROUPING)
    @Test
    public void onItemClick_onGroupActionTriggered_verifySeekbarDisabled() {
        when(mMediaSwitchingController.getSelectedMediaDevice())
                .thenReturn(
                        mMediaItems.stream()
                                .map((item) -> item.getMediaDevice().get())
                                .collect(Collectors.toList()));
        mMediaOutputAdapter = new MediaOutputAdapter(mMediaSwitchingController);
        mMediaOutputAdapter.updateItems();
        mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter
                .onCreateViewHolder(new LinearLayout(mContext), 0);
        List<MediaDevice> selectableDevices = new ArrayList<>();
        selectableDevices.add(mMediaDevice1);
        when(mMediaSwitchingController.getSelectableMediaDevice()).thenReturn(selectableDevices);
    public void onBindViewHolder_hasVolumeAdjustmentRestriction_verifySeekbarDisabled() {
        when(mMediaSwitchingController.getSelectedMediaDevice()).thenReturn(
                List.of(mMediaDevice1, mMediaDevice2));
        when(mMediaSwitchingController.isCurrentConnectedDeviceRemote()).thenReturn(true);
        when(mMediaSwitchingController.hasAdjustVolumeUserRestriction()).thenReturn(true);
        mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0);
        mMediaOutputAdapter.updateItems();

        mViewHolder.mContainerLayout.performClick();
        // Connected and selected device
        mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0);
        assertThat(mViewHolder.mSeekBar.getVisibility()).isEqualTo(View.GONE);

        assertThat(mViewHolder.mSeekBar.isEnabled()).isFalse();
        // Selected device
        mMediaOutputAdapter.onBindViewHolder(mViewHolder, 1);
        assertThat(mViewHolder.mSeekBar.getVisibility()).isEqualTo(View.GONE);
    }

    @Test
+3 −5
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
            GroupStatus groupStatus = null;
            OngoingSessionStatus ongoingSessionStatus = null;
            ConnectionState connectionState = ConnectionState.DISCONNECTED;
            boolean restrictVolumeAdjustment = false;
            boolean restrictVolumeAdjustment = mController.hasAdjustVolumeUserRestriction();
            String subtitle = null;
            Drawable deviceStatusIcon = null;
            boolean deviceDisabled = false;
@@ -200,8 +200,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
            mItemLayout.setVisibility(View.VISIBLE);

            if (mController.isAnyDeviceTransferring()) {
                if (device.getState() == MediaDeviceState.STATE_CONNECTING
                        && !mController.hasAdjustVolumeUserRestriction()) {
                if (device.getState() == MediaDeviceState.STATE_CONNECTING) {
                    connectionState = ConnectionState.CONNECTING;
                }
            } else {
@@ -251,8 +250,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                            true /* selected */,
                            isDeselectable /* deselectable */);
                    connectionState = ConnectionState.CONNECTED;
                } else if (!mController.hasAdjustVolumeUserRestriction()
                        && currentlyConnected) {
                } else if (currentlyConnected) {
                    // single selected device
                    if (isMutingExpectedDeviceExist
                            && !mController.isCurrentConnectedDeviceRemote()) {