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

Commit e87b1374 authored by Priaynk Singh's avatar Priaynk Singh Committed by Priyank Singh
Browse files

Fixing the volume dialog to show only the volume control stream every time.

Test: Manual
Bug: 112006006
Change-Id: I99b4240f704d3dd6649f5c1eb4d97685b46a6803
parent 183bdcf1
Loading
Loading
Loading
Loading
+101 −69
Original line number Diff line number Diff line
@@ -112,20 +112,26 @@ public class CarVolumeDialogImpl implements VolumeDialog {
                    // TODO: Include zoneId into consideration.
                    // For instance
                    // - single display + single-zone, ignore zoneId
            // - multi-display + single-zone, zoneId is fixed, may show volume bar on all displays
                    // - multi-display + single-zone, zoneId is fixed, may show volume bar on all
                    // displays
                    // - single-display + multi-zone, may show volume bar on primary display only
            // - multi-display + multi-zone, may show volume bar on display specified by zoneId
                    // - multi-display + multi-zone, may show volume bar on display specified by
                    // zoneId
                    VolumeItem volumeItem = mAvailableVolumeItems.get(groupId);
                    int value = getSeekbarValue(mCarAudioManager, groupId);
            // Do not update the progress if it is the same as before. When car audio manager sets
            // its group volume caused by the seekbar progress changed, it also triggers this
            // callback. Updating the seekbar at the same time could block the continuous seeking.
                    // Do not update the progress if it is the same as before. When car audio
                    // manager sets
                    // its group volume caused by the seekbar progress changed, it also triggers
                    // this
                    // callback. Updating the seekbar at the same time could block the continuous
                    // seeking.
                    if (value != volumeItem.progress) {
                        volumeItem.listItem.setProgress(value);
                        volumeItem.progress = value;
                    }
                    if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
                mHandler.obtainMessage(H.SHOW, Events.SHOW_REASON_VOLUME_CHANGED).sendToTarget();
                        mHandler.obtainMessage(H.SHOW,
                                Events.SHOW_REASON_VOLUME_CHANGED).sendToTarget();
                    }
                }

@@ -137,6 +143,8 @@ public class CarVolumeDialogImpl implements VolumeDialog {
    private boolean mHovering;
    private boolean mShowing;
    private boolean mExpanded;
    private View mExpandIcon;
    private VolumeItem mDefaultVolumeItem;
    private final ServiceConnection mServiceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
@@ -151,10 +159,8 @@ public class CarVolumeDialogImpl implements VolumeDialog {
                    mAvailableVolumeItems.add(volumeItem);
                    // The first one is the default item.
                    if (groupId == 0) {
                        volumeItem.defaultItem = true;
                        addSeekbarListItem(volumeItem, groupId,
                                R.drawable.car_ic_keyboard_arrow_down,
                                new ExpandIconListener());
                        mDefaultVolumeItem = volumeItem;
                        setupDefaultListItem();
                    }
                }

@@ -178,6 +184,13 @@ public class CarVolumeDialogImpl implements VolumeDialog {
        }
    };

    private void setupDefaultListItem() {
        mDefaultVolumeItem.defaultItem = true;
        addSeekbarListItem(mDefaultVolumeItem, /* volumeGroupId = */0,
                R.drawable.car_ic_keyboard_arrow_down, new ExpandIconListener()
        );
    }

    public CarVolumeDialogImpl(Context context) {
        mContext = new ContextThemeWrapper(context, com.android.systemui.R.style.qs_theme);
        mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
@@ -294,7 +307,9 @@ public class CarVolumeDialogImpl implements VolumeDialog {
            return;
        }
        mShowing = true;

        if (mVolumeLineItems.isEmpty()) {
            setupDefaultListItem();
        }
        mDialog.show();
        Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked());
    }
@@ -340,6 +355,13 @@ public class CarVolumeDialogImpl implements VolumeDialog {
                    }
                    mDialog.dismiss();
                    mShowing = false;
                    mShowing = false;
                    // if mExpandIcon is null that means user never clicked on the expanded arrow
                    // which implies that the dialog is still not expanded. In that case we do
                    // not want to reset the state
                    if (mExpandIcon != null && mExpanded) {
                        toggleDialogExpansion(/* isClicked = */ false);
                    }
                }, DISMISS_DELAY_IN_MILLIS))
                .start();

@@ -517,9 +539,14 @@ public class CarVolumeDialogImpl implements VolumeDialog {
    }

    private final class ExpandIconListener implements View.OnClickListener {

        @Override
        public void onClick(final View v) {
            mExpandIcon = v;
            toggleDialogExpansion(true);
        }
    }

    private void toggleDialogExpansion(boolean isClicked) {
        mExpanded = !mExpanded;
        Animator inAnimator;
        if (mExpanded) {
@@ -535,6 +562,7 @@ public class CarVolumeDialogImpl implements VolumeDialog {
            }
            inAnimator = AnimatorInflater.loadAnimator(
                    mContext, R.anim.car_arrow_fade_in_rotate_up);

        } else {
            // Only keeping the default stream if it is not expended.
            Iterator itr = mVolumeLineItems.iterator();
@@ -557,11 +585,15 @@ public class CarVolumeDialogImpl implements VolumeDialog {
        inAnimator.setStartDelay(ARROW_FADE_IN_START_DELAY_IN_MILLIS);
        AnimatorSet animators = new AnimatorSet();
        animators.playTogether(outAnimator, inAnimator);
            animators.setTarget(v);
        if (!isClicked) {
            // Do not animate when the state is called to reset the dialogs view and not clicked
            // by user.
            animators.setDuration(0);
        }
        animators.setTarget(mExpandIcon);
        animators.start();
        mPagedListAdapter.notifyDataSetChanged();
    }
    }

    private final class VolumeSeekBarChangeListener implements OnSeekBarChangeListener {