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

Commit 64d737ca authored by chelseahao's avatar chelseahao
Browse files

Use fast pair rainbow icon for devices.

Also did some style update.

Test: atest
Bug: b/323074648, b/363639734
Flag: EXEMPT bugfix
Change-Id: Ib038acf22195c95e8284398ac7e92127281302d7
parent c0390ae1
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import android.os.Handler;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.EnableFlags;
import android.provider.Settings;
import android.provider.Settings;
import android.testing.TestableLooper;
import android.testing.TestableLooper;
import android.util.Pair;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.LinearLayout;
@@ -166,6 +167,7 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        when(mCachedDevice.isActiveDevice(BluetoothProfile.HEARING_AID)).thenReturn(true);
        when(mCachedDevice.isActiveDevice(BluetoothProfile.HEARING_AID)).thenReturn(true);
        when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
        when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
        when(mCachedDevice.isConnectedHapClientDevice()).thenReturn(true);
        when(mCachedDevice.isConnectedHapClientDevice()).thenReturn(true);
        when(mCachedDevice.getDrawableWithDescription()).thenReturn(new Pair<>(mDrawable, ""));
        when(mHearingDeviceItem.getCachedBluetoothDevice()).thenReturn(mCachedDevice);
        when(mHearingDeviceItem.getCachedBluetoothDevice()).thenReturn(mCachedDevice);


        mContext.setMockPackageManager(mPackageManager);
        mContext.setMockPackageManager(mPackageManager);
+9 −4
Original line number Original line Diff line number Diff line
@@ -18,7 +18,9 @@ package com.android.systemui.bluetooth.qsdialog


import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothDevice
import android.graphics.drawable.Drawable
import android.testing.TestableLooper
import android.testing.TestableLooper
import android.util.Pair
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.CachedBluetoothDevice
@@ -64,6 +66,7 @@ class BluetoothDeviceMetadataInteractorTest : SysuiTestCase() {
    @Mock private lateinit var bluetoothDevice1: BluetoothDevice
    @Mock private lateinit var bluetoothDevice1: BluetoothDevice
    @Mock private lateinit var cachedDevice2: CachedBluetoothDevice
    @Mock private lateinit var cachedDevice2: CachedBluetoothDevice
    @Mock private lateinit var bluetoothDevice2: BluetoothDevice
    @Mock private lateinit var bluetoothDevice2: BluetoothDevice
    @Mock private lateinit var drawable: Drawable
    @Captor
    @Captor
    private lateinit var argumentCaptor: ArgumentCaptor<BluetoothAdapter.OnMetadataChangedListener>
    private lateinit var argumentCaptor: ArgumentCaptor<BluetoothAdapter.OnMetadataChangedListener>
    private lateinit var interactor: BluetoothDeviceMetadataInteractor
    private lateinit var interactor: BluetoothDeviceMetadataInteractor
@@ -77,12 +80,14 @@ class BluetoothDeviceMetadataInteractorTest : SysuiTestCase() {
            whenever(cachedDevice1.name).thenReturn(DEVICE_NAME)
            whenever(cachedDevice1.name).thenReturn(DEVICE_NAME)
            whenever(cachedDevice1.address).thenReturn(DEVICE_ADDRESS)
            whenever(cachedDevice1.address).thenReturn(DEVICE_ADDRESS)
            whenever(cachedDevice1.connectionSummary).thenReturn(CONNECTION_SUMMARY)
            whenever(cachedDevice1.connectionSummary).thenReturn(CONNECTION_SUMMARY)
            whenever(cachedDevice1.drawableWithDescription).thenReturn(Pair.create(drawable, ""))
            whenever(bluetoothDevice1.address).thenReturn(DEVICE_ADDRESS)
            whenever(bluetoothDevice1.address).thenReturn(DEVICE_ADDRESS)


            whenever(cachedDevice2.device).thenReturn(bluetoothDevice2)
            whenever(cachedDevice2.device).thenReturn(bluetoothDevice2)
            whenever(cachedDevice2.name).thenReturn(DEVICE_NAME)
            whenever(cachedDevice2.name).thenReturn(DEVICE_NAME)
            whenever(cachedDevice2.address).thenReturn(DEVICE_ADDRESS)
            whenever(cachedDevice2.address).thenReturn(DEVICE_ADDRESS)
            whenever(cachedDevice2.connectionSummary).thenReturn(CONNECTION_SUMMARY)
            whenever(cachedDevice2.connectionSummary).thenReturn(CONNECTION_SUMMARY)
            whenever(cachedDevice2.drawableWithDescription).thenReturn(Pair.create(drawable, ""))
            whenever(bluetoothDevice2.address).thenReturn(DEVICE_ADDRESS)
            whenever(bluetoothDevice2.address).thenReturn(DEVICE_ADDRESS)


            interactor = bluetoothDeviceMetadataInteractor
            interactor = bluetoothDeviceMetadataInteractor
@@ -175,14 +180,14 @@ class BluetoothDeviceMetadataInteractorTest : SysuiTestCase() {
                    .addOnMetadataChangedListener(
                    .addOnMetadataChangedListener(
                        eq(bluetoothDevice1),
                        eq(bluetoothDevice1),
                        any(),
                        any(),
                        argumentCaptor.capture()
                        argumentCaptor.capture(),
                    )
                    )


                val listener = argumentCaptor.value
                val listener = argumentCaptor.value
                listener.onMetadataChanged(
                listener.onMetadataChanged(
                    bluetoothDevice1,
                    bluetoothDevice1,
                    BluetoothDevice.METADATA_UNTETHERED_LEFT_BATTERY,
                    BluetoothDevice.METADATA_UNTETHERED_LEFT_BATTERY,
                    ByteArray(0)
                    ByteArray(0),
                )
                )
                assertThat(update).isEqualTo(Unit)
                assertThat(update).isEqualTo(Unit)
            }
            }
@@ -203,14 +208,14 @@ class BluetoothDeviceMetadataInteractorTest : SysuiTestCase() {
                    .addOnMetadataChangedListener(
                    .addOnMetadataChangedListener(
                        eq(bluetoothDevice1),
                        eq(bluetoothDevice1),
                        any(),
                        any(),
                        argumentCaptor.capture()
                        argumentCaptor.capture(),
                    )
                    )


                val listener = argumentCaptor.value
                val listener = argumentCaptor.value
                listener.onMetadataChanged(
                listener.onMetadataChanged(
                    bluetoothDevice1,
                    bluetoothDevice1,
                    BluetoothDevice.METADATA_MODEL_NAME,
                    BluetoothDevice.METADATA_MODEL_NAME,
                    ByteArray(0)
                    ByteArray(0),
                )
                )


                assertThat(update).isNull()
                assertThat(update).isNull()
+6 −5
Original line number Original line Diff line number Diff line
@@ -27,8 +27,8 @@


    <ImageView
    <ImageView
        android:id="@+id/bluetooth_device_icon"
        android:id="@+id/bluetooth_device_icon"
        android:layout_width="24dp"
        android:layout_width="36dp"
        android:layout_height="24dp"
        android:layout_height="36dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
@@ -36,8 +36,8 @@


    <TextView
    <TextView
        android:layout_width="0dp"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/bluetooth_device_name"
        android:id="@+id/bluetooth_device_name"
        style="@style/BluetoothTileDialog.DeviceName"
        android:textDirection="locale"
        android:textDirection="locale"
        android:textAlignment="gravity"
        android:textAlignment="gravity"
        android:paddingStart="20dp"
        android:paddingStart="20dp"
@@ -54,8 +54,8 @@


    <TextView
    <TextView
        android:layout_width="0dp"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/bluetooth_device_summary"
        android:id="@+id/bluetooth_device_summary"
        style="@style/BluetoothTileDialog.DeviceSummary"
        android:paddingStart="20dp"
        android:paddingStart="20dp"
        android:paddingEnd="10dp"
        android:paddingEnd="10dp"
        android:paddingBottom="15dp"
        android:paddingBottom="15dp"
@@ -65,7 +65,8 @@
        app:layout_constraintStart_toEndOf="@+id/bluetooth_device_icon"
        app:layout_constraintStart_toEndOf="@+id/bluetooth_device_icon"
        app:layout_constraintEnd_toStartOf="@+id/guideline"
        app:layout_constraintEnd_toStartOf="@+id/guideline"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:gravity="center_vertical" />
        android:gravity="center_vertical"
        android:textSize="14sp" />


    <androidx.constraintlayout.widget.Guideline
    <androidx.constraintlayout.widget.Guideline
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
+15 −11
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@
        android:ellipsize="end"
        android:ellipsize="end"
        android:gravity="center_vertical|center_horizontal"
        android:gravity="center_vertical|center_horizontal"
        android:text="@string/quick_settings_bluetooth_label"
        android:text="@string/quick_settings_bluetooth_label"
        android:textAppearance="@style/TextAppearance.Dialog.Title"
        android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
        android:textSize="24sp"
        android:textSize="24sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
@@ -49,7 +49,8 @@
        android:gravity="center_vertical|center_horizontal"
        android:gravity="center_vertical|center_horizontal"
        android:maxLines="2"
        android:maxLines="2"
        android:text="@string/quick_settings_bluetooth_tile_subtitle"
        android:text="@string/quick_settings_bluetooth_tile_subtitle"
        android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
        android:textSize="14sp"
        android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_title" />
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_title" />
@@ -105,7 +106,7 @@
                android:paddingStart="36dp"
                android:paddingStart="36dp"
                android:text="@string/turn_on_bluetooth"
                android:text="@string/turn_on_bluetooth"
                android:clickable="false"
                android:clickable="false"
                android:textAppearance="@style/TextAppearance.Dialog.Title"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textSize="16sp"
                android:textSize="16sp"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_toggle"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_toggle"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintStart_toStartOf="parent"
@@ -146,7 +147,7 @@
                android:paddingEnd="15dp"
                android:paddingEnd="15dp"
                android:paddingStart="36dp"
                android:paddingStart="36dp"
                android:clickable="false"
                android:clickable="false"
                android:textAppearance="@style/TextAppearance.Dialog.Title"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textSize="16sp"
                android:textSize="16sp"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_auto_on_toggle"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_auto_on_toggle"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintStart_toStartOf="parent"
@@ -187,7 +188,8 @@
                android:layout_marginTop="20dp"
                android:layout_marginTop="20dp"
                android:paddingStart="36dp"
                android:paddingStart="36dp"
                android:paddingEnd="40dp"
                android:paddingEnd="40dp"
                android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/bluetooth_auto_on_toggle_info_icon" />
                app:layout_constraintTop_toBottomOf="@id/bluetooth_auto_on_toggle_info_icon" />
@@ -204,7 +206,7 @@
                android:id="@+id/see_all_button"
                android:id="@+id/see_all_button"
                style="@style/BluetoothTileDialog.Device"
                style="@style/BluetoothTileDialog.Device"
                android:paddingEnd="0dp"
                android:paddingEnd="0dp"
                android:paddingStart="20dp"
                android:paddingStart="26dp"
                android:background="@drawable/bluetooth_tile_dialog_bg_off"
                android:background="@drawable/bluetooth_tile_dialog_bg_off"
                android:layout_width="0dp"
                android:layout_width="0dp"
                android:layout_height="64dp"
                android:layout_height="64dp"
@@ -214,11 +216,11 @@
                app:layout_constraintTop_toBottomOf="@+id/device_list"
                app:layout_constraintTop_toBottomOf="@+id/device_list"
                app:layout_constraintBottom_toTopOf="@+id/pair_new_device_button"
                app:layout_constraintBottom_toTopOf="@+id/pair_new_device_button"
                android:drawableStart="@drawable/ic_arrow_forward"
                android:drawableStart="@drawable/ic_arrow_forward"
                android:drawablePadding="20dp"
                android:drawablePadding="26dp"
                android:drawableTint="?android:attr/textColorPrimary"
                android:drawableTint="?android:attr/textColorPrimary"
                android:text="@string/see_all_bluetooth_devices"
                android:text="@string/see_all_bluetooth_devices"
                android:textSize="14sp"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.Dialog.Title"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textDirection="locale"
                android:textDirection="locale"
                android:textAlignment="viewStart"
                android:textAlignment="viewStart"
                android:maxLines="1"
                android:maxLines="1"
@@ -229,7 +231,7 @@
                android:id="@+id/pair_new_device_button"
                android:id="@+id/pair_new_device_button"
                style="@style/BluetoothTileDialog.Device"
                style="@style/BluetoothTileDialog.Device"
                android:paddingEnd="0dp"
                android:paddingEnd="0dp"
                android:paddingStart="20dp"
                android:paddingStart="26dp"
                android:background="@drawable/bluetooth_tile_dialog_bg_off"
                android:background="@drawable/bluetooth_tile_dialog_bg_off"
                android:layout_width="0dp"
                android:layout_width="0dp"
                android:layout_height="64dp"
                android:layout_height="64dp"
@@ -238,11 +240,11 @@
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/see_all_button"
                app:layout_constraintTop_toBottomOf="@+id/see_all_button"
                android:drawableStart="@drawable/ic_add"
                android:drawableStart="@drawable/ic_add"
                android:drawablePadding="20dp"
                android:drawablePadding="26dp"
                android:drawableTint="?android:attr/textColorPrimary"
                android:drawableTint="?android:attr/textColorPrimary"
                android:text="@string/pair_new_bluetooth_devices"
                android:text="@string/pair_new_bluetooth_devices"
                android:textSize="14sp"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.Dialog.Title"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textDirection="locale"
                android:textDirection="locale"
                android:textAlignment="viewStart"
                android:textAlignment="viewStart"
                android:maxLines="1"
                android:maxLines="1"
@@ -259,6 +261,7 @@
            <Button
            <Button
                android:id="@+id/audio_sharing_button"
                android:id="@+id/audio_sharing_button"
                style="@style/BluetoothTileDialog.AudioSharingButton"
                style="@style/BluetoothTileDialog.AudioSharingButton"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:layout_width="wrap_content"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="9dp"
                android:layout_marginTop="9dp"
@@ -282,6 +285,7 @@
            <Button
            <Button
                android:id="@+id/done_button"
                android:id="@+id/done_button"
                style="@style/Widget.Dialog.Button"
                style="@style/Widget.Dialog.Button"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:layout_width="wrap_content"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="9dp"
                android:layout_marginTop="9dp"
+5 −19
Original line number Original line Diff line number Diff line
@@ -1457,28 +1457,14 @@
        <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item>
        <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item>
    </style>
    </style>


    <style name="BluetoothTileDialog.Device.Active">
    <style name="TextAppearance.BluetoothTileDialog">
        <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item>
        <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
    </style>
        <item name="android:textDirection">locale</item>

        <item name="android:textAlignment">gravity</item>
    <style name="BluetoothTileDialog.DeviceName">
        <item name="android:textSize">14sp</item>
        <item name="android:textAppearance">@style/TextAppearance.Dialog.Title</item>
        <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item>
        <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item>
    </style>
    </style>


    <style name="BluetoothTileDialog.DeviceSummary">
    <style name="TextAppearance.BluetoothTileDialog.Active">
        <item name="android:ellipsize">end</item>
        <item name="android:maxLines">2</item>
        <item name="android:textAppearance">@style/TextAppearance.Dialog.Body.Message</item>
        <item name="android:textColor">?androidprv:attr/materialColorOnSurfaceVariant</item>
    </style>

    <style name="BluetoothTileDialog.DeviceName.Active">
        <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item>
    </style>

    <style name="BluetoothTileDialog.DeviceSummary.Active">
        <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item>
        <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item>
    </style>
    </style>


Loading