From d3d76379f417351c28eb02bb9ded8f32101d28d2 Mon Sep 17 00:00:00 2001 From: Priyank Singh Date: Wed, 30 Jan 2019 18:50:07 -0800 Subject: [PATCH] Using the correct colors for tint from the theme. The color here comes from car_product overlay for night values. Also, when the volume dialog is expanded or collapsed the default list item is never reset where as all other list items are removed and then added using addSeekbarListItem which sets the progressbar and the tint color for icon if changed for example, due to config change. Because of this default volume item never gets the updated value after config change. Bug: 123541179 Test: Manual Change-Id: I44e1db691a985410f5c5ae358ab67d1a95e45ce4 (cherry picked from commit 35306bfec84b72aad3a221852b5eb0eb1b183a43) --- .../CarSystemUI/res/values/colors_car.xml | 2 -- .../systemui/volume/CarVolumeDialogImpl.java | 21 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/CarSystemUI/res/values/colors_car.xml b/packages/CarSystemUI/res/values/colors_car.xml index 2f720f5aba656..08e16cdbe3b36 100644 --- a/packages/CarSystemUI/res/values/colors_car.xml +++ b/packages/CarSystemUI/res/values/colors_car.xml @@ -26,6 +26,4 @@ @color/car_dark_blue_grey_600 @color/car_body1_light - - @color/car_tint diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java index 85dab57b5f21c..10a0ae5a924c8 100644 --- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java +++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java @@ -554,8 +554,7 @@ public class CarVolumeDialogImpl implements VolumeDialog { // Adding the items which are not coming from the default item. VolumeItem volumeItem = mAvailableVolumeItems.get(groupId); if (volumeItem.defaultItem) { - // Set progress here due to the progress of seekbar may not be updated. - volumeItem.listItem.setProgress(volumeItem.progress); + updateDefaultVolumeItem(volumeItem.listItem); } else { addSeekbarListItem(volumeItem, groupId, 0, null); } @@ -572,8 +571,7 @@ public class CarVolumeDialogImpl implements VolumeDialog { if (!volumeItem.defaultItem) { itr.remove(); } else { - // Set progress here due to the progress of seekbar may not be updated. - seekbarListItem.setProgress(volumeItem.progress); + updateDefaultVolumeItem(seekbarListItem); } } inAnimator = AnimatorInflater.loadAnimator( @@ -595,6 +593,21 @@ public class CarVolumeDialogImpl implements VolumeDialog { mPagedListAdapter.notifyDataSetChanged(); } + private void updateDefaultVolumeItem(SeekbarListItem seekbarListItem){ + VolumeItem volumeItem = findVolumeItem(seekbarListItem); + + // 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#addSeekbarListItem}. + // 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.listItem.setPrimaryActionIcon(primaryIcon); + volumeItem.listItem.setProgress(volumeItem.progress); + } + private final class VolumeSeekBarChangeListener implements OnSeekBarChangeListener { private final int mVolumeGroupId;