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

Commit 43fcc7b8 authored by hughchen's avatar hughchen
Browse files

Set accent color to COLOR_NOT_TINTED

Bug: 128570540
Test: Test: make -j42 RunSettingsRoboTests
Change-Id: I483542156bf6cd24ed7080fed45e9f8e4d87a079
parent dee673b0
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -18,11 +18,11 @@ package com.android.settings.media;

import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;

import android.annotation.ColorInt;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
@@ -82,10 +82,9 @@ public class MediaOutputSlice implements CustomSliceable {
        }

        final List<MediaDevice> devices = getMediaDevices();
        @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);

        final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
        final ListBuilder listBuilder = buildActiveDeviceHeader(color, connectedDevice);
        final ListBuilder listBuilder = buildActiveDeviceHeader(connectedDevice);

        for (MediaDevice device : devices) {
            if (!TextUtils.equals(connectedDevice.getId(), device.getId())) {
@@ -96,9 +95,9 @@ public class MediaOutputSlice implements CustomSliceable {
        return listBuilder.build();
    }

    private ListBuilder buildActiveDeviceHeader(@ColorInt int color, MediaDevice device) {
    private ListBuilder buildActiveDeviceHeader(MediaDevice device) {
        final String title = device.getName();
        final IconCompat icon = IconCompat.createWithResource(mContext, device.getIcon());
        final IconCompat icon = getDeviceIconCompat(device);

        final PendingIntent broadcastAction =
                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,
                ListBuilder.INFINITY)
                .setAccentColor(color)
                .setAccentColor(COLOR_NOT_TINTED)
                .addRow(new ListBuilder.RowBuilder()
                        .setTitleItem(icon, ListBuilder.ICON_IMAGE)
                        .setTitle(title)
@@ -117,6 +116,17 @@ public class MediaOutputSlice implements CustomSliceable {
        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() {
        if (mWorker == null) {
            mWorker = (MediaDeviceUpdateWorker) SliceBackgroundWorker.getInstance(getUri());
@@ -136,7 +146,8 @@ public class MediaOutputSlice implements CustomSliceable {
        final String title = device.getName();
        final PendingIntent broadcastAction =
                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()
                .setTitleItem(deviceIcon, ListBuilder.ICON_IMAGE)
                .setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
+4 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;

import androidx.slice.Slice;
import androidx.slice.SliceMetadata;
@@ -66,6 +67,8 @@ public class MediaOutputSliceTest {

    @Mock
    private LocalMediaManager mLocalMediaManager;
    @Mock
    private Drawable mTestDrawable;

    private final List<MediaDevice> mDevices = new ArrayList<>();

@@ -105,7 +108,7 @@ public class MediaOutputSliceTest {
        mDevices.clear();
        final MediaDevice device = mock(MediaDevice.class);
        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);

        final Slice mediaSlice = mMediaOutputSlice.getSlice();