Show volume bar if MediaDevice is active device

This CL before, the volume bar will shown on the top device.
In this CL, the volume bar will shown on the active device.

Bug: 148765806
Test: manually
Change-Id: Id261201a4227151667c67ab91864cc349941372e
This commit is contained in:
hughchen
2020-02-06 14:06:06 +08:00
committed by tim peng
parent 978b19ec63
commit 1ab6dd7a71

View File

@@ -89,20 +89,28 @@ public class MediaOutputSlice implements CustomSliceable {
final MediaDevice topDevice = isTouched ? worker.getTopDevice() : connectedDevice; final MediaDevice topDevice = isTouched ? worker.getTopDevice() : connectedDevice;
if (topDevice != null) { if (topDevice != null) {
listBuilder.addInputRange(getActiveDeviceHeaderRow(topDevice)); addRow(topDevice, connectedDevice, listBuilder);
worker.setTopDevice(topDevice); worker.setTopDevice(topDevice);
} }
for (MediaDevice device : devices) { for (MediaDevice device : devices) {
if (topDevice == null if (topDevice == null
|| !TextUtils.equals(topDevice.getId(), device.getId())) { || !TextUtils.equals(topDevice.getId(), device.getId())) {
listBuilder.addRow(getMediaDeviceRow(device)); addRow(device, connectedDevice, listBuilder);
} }
} }
return listBuilder.build(); return listBuilder.build();
} }
private void addRow(MediaDevice device, MediaDevice connectedDevice, ListBuilder listBuilder) {
if (TextUtils.equals(device.getId(), connectedDevice.getId())) {
listBuilder.addInputRange(getActiveDeviceHeaderRow(device));
} else {
listBuilder.addRow(getMediaDeviceRow(device));
}
}
private ListBuilder.InputRangeBuilder getActiveDeviceHeaderRow(MediaDevice device) { private ListBuilder.InputRangeBuilder getActiveDeviceHeaderRow(MediaDevice device) {
final String title = device.getName(); final String title = device.getName();
final IconCompat icon = getDeviceIconCompat(device); final IconCompat icon = getDeviceIconCompat(device);