Add new Bluetooth UI

Bug: 246286977
Bug: 284330375
Test: atest BluetoothBondedDevicesPreferenceControllerTest
Test: atest BluetoothDevicePreferenceTest
Test: atest MultiActionPreferenceTest
Change-Id: I87e386c0ffcc9372ff4a77eb192468fdb115f886
diff --git a/res/layout/multi_action_preference.xml b/res/layout/multi_action_preference.xml
index 30f5386..375e8c8 100644
--- a/res/layout/multi_action_preference.xml
+++ b/res/layout/multi_action_preference.xml
@@ -54,7 +54,7 @@
             android:singleLine="true"
             android:textAppearance="@style/TextAppearance.CarUi.PreferenceTitle"
             app:layout_constraintStart_toEndOf="@android:id/icon"
-            app:layout_constraintEnd_toStartOf="@id/icon_chevron"
+            app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintBottom_toTopOf="@android:id/summary"
             app:layout_constraintVertical_chainStyle="packed"/>
@@ -69,20 +69,10 @@
             android:textAppearance="@style/TextAppearance.CarUi.PreferenceSummary"
             android:maxLines="2"
             app:layout_constraintStart_toEndOf="@android:id/icon"
-            app:layout_constraintEnd_toStartOf="@id/icon_chevron"
+            app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toBottomOf="@android:id/title"
             app:layout_constraintBottom_toBottomOf="parent"/>
 
-        <com.android.car.ui.uxr.DrawableStateImageView
-            android:id="@+id/icon_chevron"
-            android:layout_width="@dimen/multi_action_preference_icon_chevron_size"
-            android:layout_height="50dp"
-            android:src="@drawable/car_ui_icon_chevron"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintStart_toEndOf="@android:id/title"
-            app:layout_constraintEnd_toEndOf="parent"/>
-
     </com.android.car.ui.uxr.DrawableStateConstraintLayout>
 
     <androidx.constraintlayout.widget.Barrier
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c36cbb1..28761e9 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -150,7 +150,6 @@
     <dimen name="multi_action_preference_toggle_button_radius">11dp</dimen>
     <dimen name="multi_action_preference_toggle_button_margin">12dp</dimen>
     <dimen name="multi_action_preference_drawable_button_margin">12dp</dimen>
-    <dimen name="multi_action_preference_icon_chevron_size">50dp</dimen>
 
     <!-- Data usage -->
     <dimen name="usage_number_text_size">36sp</dimen>
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index f27fae3..3c9dd71 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -215,7 +215,6 @@
       <item type="dimen" name="multi_action_preference_drawable_button_height"/>
       <item type="dimen" name="multi_action_preference_drawable_button_margin"/>
       <item type="dimen" name="multi_action_preference_drawable_button_width"/>
-      <item type="dimen" name="multi_action_preference_icon_chevron_size"/>
       <item type="dimen" name="multi_action_preference_item_container_padding"/>
       <item type="dimen" name="multi_action_preference_item_divider_margin_end"/>
       <item type="dimen" name="multi_action_preference_toggle_button_margin"/>
@@ -454,7 +453,6 @@
       <item type="id" name="guideline_start"/>
       <item type="id" name="guideline_top"/>
       <item type="id" name="hint_text"/>
-      <item type="id" name="icon_chevron"/>
       <item type="id" name="icon_frame"/>
       <item type="id" name="key0"/>
       <item type="id" name="key1"/>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 2fd9858..d23f01b 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -34,6 +34,7 @@
         <item name="android:fragmentOpenExitAnimation">@animator/trans_left_out</item>
         <item name="android:fragmentCloseEnterAnimation">@animator/trans_left_in</item>
         <item name="android:fragmentCloseExitAnimation">@animator/trans_right_out</item>
+        <item name="colorPrimaryVariant">?android:attr/colorPrimary</item>
     </style>
 
     <style name="FallbackHome" parent="@android:style/Theme.DeviceDefault.NoActionBar">
diff --git a/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceController.java b/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceController.java
index cbaa513..08eb482 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceController.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceController.java
@@ -341,11 +341,6 @@
     }
 
     @Override
-    protected boolean shouldShowChevronIcon() {
-        return true;
-    }
-
-    @Override
     protected boolean shouldShowIcon() {
         return false;
     }
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/car/settings/bluetooth/BluetoothDevicePreference.java
index 520d025..f70f834 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDevicePreference.java
@@ -45,9 +45,6 @@
     private final CachedBluetoothDevice mCachedDevice;
     private final boolean mShowDevicesWithoutNames;
     private final boolean mShowDisconnectedStateSubtitle;
-
-    private final boolean mShowChevron;
-
     private final boolean mShowIcon;
 
     private final CachedBluetoothDevice.Callback mDeviceCallback = this::refreshUi;
@@ -56,17 +53,16 @@
 
     public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) {
         this(context, cachedDevice, /* showDisconnectedStateSubtitle= */
-                true, /* showChevron= */ false, /* showIcon= */ true);
+                true, /* showIcon= */ true);
     }
 
     public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice,
-            boolean showDisconnectedStateSubtitle, boolean showChevron, boolean showIcon) {
+            boolean showDisconnectedStateSubtitle,  boolean showIcon) {
         super(context);
         mCachedDevice = cachedDevice;
         mShowDisconnectedStateSubtitle = showDisconnectedStateSubtitle;
         mShowDevicesWithoutNames = SystemProperties.getBoolean(
                 BluetoothUtils.BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false);
-        mShowChevron = showChevron;
         mShowIcon = showIcon;
     }
 
@@ -116,8 +112,6 @@
 
         setSummary(getConnectionSummary());
 
-        showChevron(mShowChevron);
-
         if (mShowIcon) {
             Pair<Drawable, String> pair = com.android.settingslib.bluetooth.BluetoothUtils
                     .getBtClassDrawableWithDescription(getContext(), mCachedDevice);
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDevicesGroupPreferenceController.java b/src/com/android/car/settings/bluetooth/BluetoothDevicesGroupPreferenceController.java
index 38ede34..06bb4f3 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDevicesGroupPreferenceController.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDevicesGroupPreferenceController.java
@@ -93,7 +93,6 @@
     protected BluetoothDevicePreference createDevicePreference(CachedBluetoothDevice cachedDevice) {
         return new BluetoothDevicePreference(getContext(), cachedDevice,
                 shouldShowDisconnectedStateSubtitle(),
-                shouldShowChevronIcon(),
                 shouldShowIcon());
     }
 
@@ -105,13 +104,6 @@
     }
 
     /**
-     * Returns whether chevron icon should be displayed
-     */
-    protected boolean shouldShowChevronIcon() {
-        return false;
-    }
-
-    /**
      * Returns whether or not the created bluetooth device preferences should display the
      * disconnected state subtitle.
      */
diff --git a/src/com/android/car/settings/common/MultiActionPreference.java b/src/com/android/car/settings/common/MultiActionPreference.java
index 923c119..eed75df 100644
--- a/src/com/android/car/settings/common/MultiActionPreference.java
+++ b/src/com/android/car/settings/common/MultiActionPreference.java
@@ -31,7 +31,6 @@
 
 import com.android.car.settings.R;
 import com.android.car.ui.preference.CarUiPreference;
-import com.android.car.ui.uxr.DrawableStateImageView;
 
 /**
  * A class for preferences that have a main click action along with up to two group of actions that
@@ -59,8 +58,6 @@
     @Nullable
     private Integer mSummaryColor;
 
-    private boolean mShowChevron;
-
     protected BaseActionItem[] mActionItemArrayGroupOne = new BaseActionItem[1];
     protected BaseActionItem[] mActionItemArrayGroupTwo = new BaseActionItem[2];
 
@@ -182,9 +179,6 @@
             summary.setTextColor(mSummaryColor);
         }
 
-        DrawableStateImageView chevronIcon = requireViewByRefId(holder.itemView, R.id.icon_chevron);
-        chevronIcon.setVisibility(mShowChevron ? View.VISIBLE : View.INVISIBLE);
-
         View actionContainerGroupOne = requireViewByRefId(holder.itemView,
                 R.id.multi_action_preference_second_action_container1);
         FrameLayout container0 = requireViewByRefId(holder.itemView,
@@ -252,14 +246,6 @@
     }
 
     /**
-     * Shows or hides chevron icon
-     */
-    public void showChevron(boolean show) {
-        mShowChevron = show;
-        notifyChanged();
-    }
-
-    /**
      * Retrieve the specified BaseActionItem based on the index in the first group of actions
      */
     public BaseActionItem getGroupOneActionItem(ActionItemGroupOne actionItem) {
diff --git a/tests/unit/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceControllerTest.java b/tests/unit/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceControllerTest.java
index e1b6fb0..3282a9e 100644
--- a/tests/unit/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/car/settings/bluetooth/BluetoothBondedDevicesPreferenceControllerTest.java
@@ -236,6 +236,12 @@
         assertThat(connectBluetoothButton.isEnabled()).isTrue();
         connectBluetoothButton.onClick();
 
+        when(mBondedCachedDevice.isConnected()).thenReturn(true);
+
+        // Need to call onDeviceBondStateChanged to notify the listener.
+        // We can pass in any values since refreshUi() doesn't take any arguments
+        mPreferenceController.onDeviceBondStateChanged(
+                /* cachedDevice= */ null, /* bondState= */ -1);
         assertThat(connectBluetoothButton.isVisible()).isFalse();
 
         ToggleButtonActionItem phoneProfileButton =
diff --git a/tests/unit/src/com/android/car/settings/common/MultiActionPreferenceTest.java b/tests/unit/src/com/android/car/settings/common/MultiActionPreferenceTest.java
index 0396ed2..02b6322 100644
--- a/tests/unit/src/com/android/car/settings/common/MultiActionPreferenceTest.java
+++ b/tests/unit/src/com/android/car/settings/common/MultiActionPreferenceTest.java
@@ -60,8 +60,8 @@
         MockitoAnnotations.initMocks(this);
         mRootView = View.inflate(mContext, R.layout.multi_action_preference, null);
         mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
-        // Mocked int and boolean values from TypedArray seem to be 0, so default values can't be
-        // used. Must manually set tested values
+        mContext.setTheme(R.style.CarSettingTheme);
+        mTypedArray = spy(mContext.obtainStyledAttributes(null, R.styleable.MultiActionPreference));
         doReturn(mTypedArray).when(mContext).obtainStyledAttributes(nullable(AttributeSet.class),
                 eq(R.styleable.MultiActionPreference));
     }
@@ -268,9 +268,9 @@
     @Test
     @UiThreadTest
     public void toggleButtons_onClickRestricted_checkedStateDoesNotChange() {
-        when(mTypedArray.getInteger(eq(R.styleable.MultiActionPreference_group_two_action_item_one),
+        when(mTypedArray.getInt(eq(R.styleable.MultiActionPreference_group_two_action_item_one),
                 anyInt())).thenReturn(0);
-        when(mTypedArray.getInteger(eq(R.styleable.MultiActionPreference_group_two_action_item_two),
+        when(mTypedArray.getInt(eq(R.styleable.MultiActionPreference_group_two_action_item_two),
                 anyInt())).thenReturn(0);
         mPref = new MultiActionPreference(mContext);
         mPref.getGroupTwoActionItem(MultiActionPreference.ActionItemGroupTwo.ACTION_ITEM1)