summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java53
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeItem.java15
2 files changed, 33 insertions, 35 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
index 512210be0a46..267d9f54dd8d 100644
--- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
+++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
@@ -112,17 +112,22 @@ public class CarVolumeDialogImpl implements VolumeDialog {
// zoneId
VolumeItem volumeItem = mAvailableVolumeItems.get(groupId);
int value = getSeekbarValue(mCarAudioManager, groupId);
+ // find if the group id for which the volume changed is currently being
+ // displayed.
+ boolean isShowing = mCarVolumeLineItems.stream().anyMatch(
+ item -> item.getGroupId() == 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.
- if (value != volumeItem.progress) {
+ if (value != volumeItem.progress && isShowing) {
volumeItem.carVolumeItem.setProgress(value);
volumeItem.progress = value;
}
if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
+ mCurrentlyDisplayingGroupId = groupId;
mHandler.obtainMessage(H.SHOW,
Events.SHOW_REASON_VOLUME_CHANGED).sendToTarget();
}
@@ -134,10 +139,10 @@ public class CarVolumeDialogImpl implements VolumeDialog {
}
};
private boolean mHovering;
+ private int mCurrentlyDisplayingGroupId;
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) {
@@ -152,8 +157,7 @@ public class CarVolumeDialogImpl implements VolumeDialog {
mAvailableVolumeItems.add(volumeItem);
// The first one is the default item.
if (groupId == 0) {
- mDefaultVolumeItem = volumeItem;
- setupDefaultCarVolumeItem();
+ setuptListItem(0);
}
}
@@ -177,9 +181,11 @@ public class CarVolumeDialogImpl implements VolumeDialog {
}
};
- private void setupDefaultCarVolumeItem() {
- mDefaultVolumeItem.defaultItem = true;
- addCarVolumeListItem(mDefaultVolumeItem, /* volumeGroupId = */0,
+ private void setuptListItem(int groupId) {
+ mCarVolumeLineItems.clear();
+ VolumeItem volumeItem = mAvailableVolumeItems.get(groupId);
+ volumeItem.defaultItem = true;
+ addCarVolumeListItem(volumeItem, /* volumeGroupId = */ groupId,
R.drawable.car_ic_keyboard_arrow_down, new ExpandIconListener()
);
}
@@ -299,9 +305,7 @@ public class CarVolumeDialogImpl implements VolumeDialog {
return;
}
mShowing = true;
- if (mCarVolumeLineItems.isEmpty()) {
- setupDefaultCarVolumeItem();
- }
+ setuptListItem(mCurrentlyDisplayingGroupId);
mDialog.show();
Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked());
}
@@ -437,7 +441,7 @@ public class CarVolumeDialogImpl implements VolumeDialog {
carVolumeItem.setSupplementalIcon(/* drawable= */ null,
/* showSupplementalIconDivider= */ false);
}
-
+ carVolumeItem.setGroupId(volumeGroupId);
mCarVolumeLineItems.add(carVolumeItem);
volumeItem.carVolumeItem = carVolumeItem;
volumeItem.progress = progress;
@@ -545,11 +549,8 @@ public class CarVolumeDialogImpl implements VolumeDialog {
Animator inAnimator;
if (mExpanded) {
for (int groupId = 0; groupId < mAvailableVolumeItems.size(); ++groupId) {
- // Adding the items which are not coming from the default item.
- VolumeItem volumeItem = mAvailableVolumeItems.get(groupId);
- if (volumeItem.defaultItem) {
- updateDefaultVolumeItem(volumeItem.carVolumeItem);
- } else {
+ if (groupId != mCurrentlyDisplayingGroupId) {
+ VolumeItem volumeItem = mAvailableVolumeItems.get(groupId);
addCarVolumeListItem(volumeItem, groupId, 0, null);
}
}
@@ -561,11 +562,8 @@ public class CarVolumeDialogImpl implements VolumeDialog {
Iterator itr = mCarVolumeLineItems.iterator();
while (itr.hasNext()) {
CarVolumeItem carVolumeItem = (CarVolumeItem) itr.next();
- VolumeItem volumeItem = findVolumeItem(carVolumeItem);
- if (!volumeItem.defaultItem) {
+ if (carVolumeItem.getGroupId() != mCurrentlyDisplayingGroupId) {
itr.remove();
- } else {
- updateDefaultVolumeItem(carVolumeItem);
}
}
inAnimator = AnimatorInflater.loadAnimator(
@@ -587,21 +585,6 @@ public class CarVolumeDialogImpl implements VolumeDialog {
mVolumeItemsAdapter.notifyDataSetChanged();
}
- private void updateDefaultVolumeItem(CarVolumeItem carVolumeItem) {
- VolumeItem volumeItem = findVolumeItem(carVolumeItem);
-
- // When volume dialog is expanded or collapsed the default list item is never
- // reset. Whereas all other list items are removed when the dialog is collapsed and then
- // added when the dialog is expanded using {@link CarVolumeDialogImpl#addCarVolumeListItem}.
- // This sets the progressbar and the tint color of icons for all items other than default
- // if they were changed. For default list item it should be done manually here.
- int color = mContext.getResources().getColor(R.color.car_volume_dialog_tint);
- Drawable primaryIcon = mContext.getResources().getDrawable(volumeItem.icon);
- primaryIcon.mutate().setTint(color);
- volumeItem.carVolumeItem.setPrimaryIcon(primaryIcon);
- volumeItem.carVolumeItem.setProgress(volumeItem.progress);
- }
-
private final class VolumeSeekBarChangeListener implements OnSeekBarChangeListener {
private final int mVolumeGroupId;
diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeItem.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeItem.java
index 9613de1bfaaa..e1ea6f6f0a41 100644
--- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeItem.java
+++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeItem.java
@@ -35,6 +35,7 @@ public class CarVolumeItem {
private Drawable mSupplementalIcon;
private View.OnClickListener mSupplementalIconOnClickListener;
private boolean mShowSupplementalIconDivider;
+ private int mGroupId;
private int mMax;
private int mProgress;
@@ -85,6 +86,20 @@ public class CarVolumeItem {
mIsDirty = true;
}
+ /**
+ * Gets the group id associated.
+ */
+ public int getGroupId() {
+ return mGroupId;
+ }
+
+ /**
+ * Sets the group id associated.
+ */
+ public void setGroupId(int groupId) {
+ this.mGroupId = groupId;
+ }
+
/** Sets {@code OnClickListener} for the supplemental icon. */
public void setSupplementalIconListener(View.OnClickListener listener) {
mSupplementalIconOnClickListener = listener;