Set accent color to COLOR_NOT_TINTED
Bug: 128570540 Test: Test: make -j42 RunSettingsRoboTests Change-Id: I483542156bf6cd24ed7080fed45e9f8e4d87a079
This commit is contained in:
@@ -18,11 +18,11 @@ package com.android.settings.media;
|
|||||||
|
|
||||||
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
|
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
|
||||||
|
|
||||||
import android.annotation.ColorInt;
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -82,10 +82,9 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<MediaDevice> devices = getMediaDevices();
|
final List<MediaDevice> devices = getMediaDevices();
|
||||||
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
|
|
||||||
|
|
||||||
final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
|
final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
|
||||||
final ListBuilder listBuilder = buildActiveDeviceHeader(color, connectedDevice);
|
final ListBuilder listBuilder = buildActiveDeviceHeader(connectedDevice);
|
||||||
|
|
||||||
for (MediaDevice device : devices) {
|
for (MediaDevice device : devices) {
|
||||||
if (!TextUtils.equals(connectedDevice.getId(), device.getId())) {
|
if (!TextUtils.equals(connectedDevice.getId(), device.getId())) {
|
||||||
@@ -96,9 +95,9 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
return listBuilder.build();
|
return listBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListBuilder buildActiveDeviceHeader(@ColorInt int color, MediaDevice device) {
|
private ListBuilder buildActiveDeviceHeader(MediaDevice device) {
|
||||||
final String title = device.getName();
|
final String title = device.getName();
|
||||||
final IconCompat icon = IconCompat.createWithResource(mContext, device.getIcon());
|
final IconCompat icon = getDeviceIconCompat(device);
|
||||||
|
|
||||||
final PendingIntent broadcastAction =
|
final PendingIntent broadcastAction =
|
||||||
getBroadcastIntent(mContext, device.getId(), device.hashCode());
|
getBroadcastIntent(mContext, device.getId(), device.hashCode());
|
||||||
@@ -107,7 +106,7 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
|
|
||||||
final ListBuilder listBuilder = new ListBuilder(mContext, MEDIA_OUTPUT_SLICE_URI,
|
final ListBuilder listBuilder = new ListBuilder(mContext, MEDIA_OUTPUT_SLICE_URI,
|
||||||
ListBuilder.INFINITY)
|
ListBuilder.INFINITY)
|
||||||
.setAccentColor(color)
|
.setAccentColor(COLOR_NOT_TINTED)
|
||||||
.addRow(new ListBuilder.RowBuilder()
|
.addRow(new ListBuilder.RowBuilder()
|
||||||
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
|
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
@@ -117,6 +116,17 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
return listBuilder;
|
return listBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IconCompat getDeviceIconCompat(MediaDevice device) {
|
||||||
|
Drawable drawable = device.getIcon();
|
||||||
|
if (drawable == null) {
|
||||||
|
Log.d(TAG, "getDeviceIconCompat() device : " + device.getName() + ", drawable is null");
|
||||||
|
// Use default Bluetooth device icon to handle getIcon() is null case.
|
||||||
|
drawable = mContext.getDrawable(com.android.internal.R.drawable.ic_bt_headphones_a2dp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils.createIconWithDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
private MediaDeviceUpdateWorker getWorker() {
|
private MediaDeviceUpdateWorker getWorker() {
|
||||||
if (mWorker == null) {
|
if (mWorker == null) {
|
||||||
mWorker = (MediaDeviceUpdateWorker) SliceBackgroundWorker.getInstance(getUri());
|
mWorker = (MediaDeviceUpdateWorker) SliceBackgroundWorker.getInstance(getUri());
|
||||||
@@ -136,7 +146,8 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
final String title = device.getName();
|
final String title = device.getName();
|
||||||
final PendingIntent broadcastAction =
|
final PendingIntent broadcastAction =
|
||||||
getBroadcastIntent(mContext, device.getId(), device.hashCode());
|
getBroadcastIntent(mContext, device.getId(), device.hashCode());
|
||||||
final IconCompat deviceIcon = IconCompat.createWithResource(mContext, device.getIcon());
|
final IconCompat deviceIcon = getDeviceIconCompat(device);
|
||||||
|
|
||||||
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
|
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
|
||||||
.setTitleItem(deviceIcon, ListBuilder.ICON_IMAGE)
|
.setTitleItem(deviceIcon, ListBuilder.ICON_IMAGE)
|
||||||
.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
|
||||||
|
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
import androidx.slice.Slice;
|
import androidx.slice.Slice;
|
||||||
import androidx.slice.SliceMetadata;
|
import androidx.slice.SliceMetadata;
|
||||||
@@ -66,6 +67,8 @@ public class MediaOutputSliceTest {
|
|||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private LocalMediaManager mLocalMediaManager;
|
private LocalMediaManager mLocalMediaManager;
|
||||||
|
@Mock
|
||||||
|
private Drawable mTestDrawable;
|
||||||
|
|
||||||
private final List<MediaDevice> mDevices = new ArrayList<>();
|
private final List<MediaDevice> mDevices = new ArrayList<>();
|
||||||
|
|
||||||
@@ -105,7 +108,7 @@ public class MediaOutputSliceTest {
|
|||||||
mDevices.clear();
|
mDevices.clear();
|
||||||
final MediaDevice device = mock(MediaDevice.class);
|
final MediaDevice device = mock(MediaDevice.class);
|
||||||
when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
|
when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
|
||||||
when(device.getIcon()).thenReturn(TEST_DEVICE_1_ICON);
|
when(device.getIcon()).thenReturn(mTestDrawable);
|
||||||
when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
|
when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
|
||||||
|
|
||||||
final Slice mediaSlice = mMediaOutputSlice.getSlice();
|
final Slice mediaSlice = mMediaOutputSlice.getSlice();
|
||||||
|
Reference in New Issue
Block a user