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

Commit e2c024f9 authored by Arian's avatar Arian
Browse files

SystemUI: VolumeDialogImpl: Show output button if there is an active stream

The media output dialog can be used to connect different devices.
This patch makes it show up if at least one of the following
conditions is met:
1: There is an active local media controller
2: There is a bluetooth a2dp device connected

Change-Id: Ie2a2a0f3125e1ffbf78bfc1f66868696f6389294
parent 3a190757
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -1240,20 +1240,23 @@ public class VolumeDialogImpl implements VolumeDialog,
                == BluetoothProfile.STATE_CONNECTED;
    }

    private boolean isMediaControllerAvailable(MediaController mediaController) {
        return mediaController != null && !TextUtils.isEmpty(mediaController.getPackageName());
    }

    public void initSettingsH() {
        if (mSettingsView != null) {
            mSettingsView.setVisibility(mDeviceProvisionedController.isCurrentUserSetup()
                    && mActivityManager.getLockTaskModeState() == LOCK_TASK_MODE_NONE
                    && isBluetoothA2dpConnected()
                    && (isMediaControllerAvailable(getActiveLocalMediaController())
                            || isBluetoothA2dpConnected())
                    ? VISIBLE : GONE);
        }
        if (mSettingsIcon != null) {
            mSettingsIcon.setOnClickListener(v -> {
                Events.writeEvent(Events.EVENT_SETTINGS_CLICK);
                final MediaController mediaController = getActiveLocalMediaController();
                String packageName =
                        mediaController != null
                                && !TextUtils.isEmpty(mediaController.getPackageName())
                String packageName = isMediaControllerAvailable(mediaController)
                        ? mediaController.getPackageName()
                        : "";
                mMediaOutputDialogFactory.create(packageName, false, mDialogView);