summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Chen <evanxinchen@google.com> 2022-03-18 21:10:49 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-03-18 21:10:49 +0000
commitf0dcefc23fd160b2e28b8a618fa8461f36c3a33d (patch)
tree70d6f33f934481561dd6268c24fba8ae1676123f
parent9197321f904fa12a824522be429d5362ebc55d55 (diff)
parente4d52246623b5e7a706afd5eedc3764189d3e1a5 (diff)
Merge changes from topics "presubmit-am-1a8adc3a42824e489007f2ef846a0f71", "presubmit-am-71bbe918d83d491e8ccb96c26458149c", "presubmit-am-e80e22a9aeb8442eb3b3332c3b2ea804" into tm-dev
* changes: CDM UI cleanUp Introduce a progessBar for multiple devices Make the Allow button at the top
-rw-r--r--packages/CompanionDeviceManager/res/color/selector.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/btn_negative_multiple_devices.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/btn_negative_top.xml5
-rw-r--r--packages/CompanionDeviceManager/res/drawable/btn_positive_bottom.xml5
-rw-r--r--packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/ic_apps.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/ic_device_other.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/ic_notifications.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/ic_storage.xml1
-rw-r--r--packages/CompanionDeviceManager/res/drawable/ic_watch.xml1
-rw-r--r--packages/CompanionDeviceManager/res/layout/activity_confirmation.xml75
-rw-r--r--packages/CompanionDeviceManager/res/layout/data_transfer_confirmation.xml50
-rw-r--r--packages/CompanionDeviceManager/res/layout/helper_confirmation.xml17
-rw-r--r--packages/CompanionDeviceManager/res/layout/list_item_device.xml1
-rw-r--r--packages/CompanionDeviceManager/res/layout/list_item_permission.xml8
-rw-r--r--packages/CompanionDeviceManager/res/layout/vendor_header.xml7
-rw-r--r--packages/CompanionDeviceManager/res/values/styles.xml66
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java27
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java3
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceListAdapter.java9
20 files changed, 173 insertions, 108 deletions
diff --git a/packages/CompanionDeviceManager/res/color/selector.xml b/packages/CompanionDeviceManager/res/color/selector.xml
index 56e5dca0f72f..aebc5d5adf6e 100644
--- a/packages/CompanionDeviceManager/res/color/selector.xml
+++ b/packages/CompanionDeviceManager/res/color/selector.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/btn_negative_multiple_devices.xml b/packages/CompanionDeviceManager/res/drawable/btn_negative_multiple_devices.xml
index ece7bbafc654..ebe16a7a14e5 100644
--- a/packages/CompanionDeviceManager/res/drawable/btn_negative_multiple_devices.xml
+++ b/packages/CompanionDeviceManager/res/drawable/btn_negative_multiple_devices.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/btn_negative_top.xml b/packages/CompanionDeviceManager/res/drawable/btn_negative_top.xml
index 7df92bb145cb..3cd7929bdd83 100644
--- a/packages/CompanionDeviceManager/res/drawable/btn_negative_top.xml
+++ b/packages/CompanionDeviceManager/res/drawable/btn_negative_top.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
@@ -17,6 +18,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/system_accent1_100"/>
- <corners android:topLeftRadius="12dp" android:topRightRadius="12dp"
- android:bottomLeftRadius="4dp" android:bottomRightRadius="4dp"/>
+ <corners android:topLeftRadius="4dp" android:topRightRadius="4dp"
+ android:bottomLeftRadius="12dp" android:bottomRightRadius="12dp"/>
</shape>
diff --git a/packages/CompanionDeviceManager/res/drawable/btn_positive_bottom.xml b/packages/CompanionDeviceManager/res/drawable/btn_positive_bottom.xml
index 55e96f6d7512..2cff4737cabf 100644
--- a/packages/CompanionDeviceManager/res/drawable/btn_positive_bottom.xml
+++ b/packages/CompanionDeviceManager/res/drawable/btn_positive_bottom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
@@ -17,6 +18,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/system_accent1_100"/>
- <corners android:topLeftRadius="4dp" android:topRightRadius="4dp"
- android:bottomLeftRadius="12dp" android:bottomRightRadius="12dp"/>
+ <corners android:topLeftRadius="12dp" android:topRightRadius="12dp"
+ android:bottomLeftRadius="4dp" android:bottomRightRadius="4dp"/>
</shape>
diff --git a/packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml b/packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml
index f9ec5d0dce55..8e92051faf6c 100644
--- a/packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml
+++ b/packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/ic_apps.xml b/packages/CompanionDeviceManager/res/drawable/ic_apps.xml
index 93a0cba769c6..d1ec8637775c 100644
--- a/packages/CompanionDeviceManager/res/drawable/ic_apps.xml
+++ b/packages/CompanionDeviceManager/res/drawable/ic_apps.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/ic_device_other.xml b/packages/CompanionDeviceManager/res/drawable/ic_device_other.xml
index f8515c33d57f..2a8eb24bcf1f 100644
--- a/packages/CompanionDeviceManager/res/drawable/ic_device_other.xml
+++ b/packages/CompanionDeviceManager/res/drawable/ic_device_other.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/ic_notifications.xml b/packages/CompanionDeviceManager/res/drawable/ic_notifications.xml
index 4ac4d04b184e..e5825bcbf70c 100644
--- a/packages/CompanionDeviceManager/res/drawable/ic_notifications.xml
+++ b/packages/CompanionDeviceManager/res/drawable/ic_notifications.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/ic_storage.xml b/packages/CompanionDeviceManager/res/drawable/ic_storage.xml
index d8b7f59185c8..406a3b5dada5 100644
--- a/packages/CompanionDeviceManager/res/drawable/ic_storage.xml
+++ b/packages/CompanionDeviceManager/res/drawable/ic_storage.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/drawable/ic_watch.xml b/packages/CompanionDeviceManager/res/drawable/ic_watch.xml
index 44a40b9fede3..d7a28d949997 100644
--- a/packages/CompanionDeviceManager/res/drawable/ic_watch.xml
+++ b/packages/CompanionDeviceManager/res/drawable/ic_watch.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
diff --git a/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml b/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml
index 8eec33aeb4ee..c37054e9e98d 100644
--- a/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml
+++ b/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
-
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@@ -20,35 +19,26 @@
<!-- A header for selfManaged devices only. -->
<include layout="@layout/vendor_header" />
+ <!-- Do NOT change the ID of the root LinearLayout above: it's referenced in CTS tests. -->
+
<ImageView
android:id="@+id/profile_icon"
android:layout_width="match_parent"
android:layout_height="32dp"
android:gravity="center"
- android:layout_marginBottom="12dp"
- android:layout_marginTop="1dp"
+ android:layout_marginTop="18dp"
android:tint="@android:color/system_accent1_600"/>
- <!-- Do NOT change the ID of the root LinearLayout above: it's referenced in CTS tests. -->
+ <LinearLayout style="@style/Description">
+ <TextView
+ android:id="@+id/title"
+ style="@style/DescriptionTitle" />
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:paddingHorizontal="12dp"
- android:layout_marginBottom="12dp"
- style="@*android:style/TextAppearance.Widget.Toolbar.Title" />
+ <TextView
+ android:id="@+id/summary"
+ style="@style/DescriptionSummary" />
- <TextView
- android:id="@+id/summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
- android:gravity="center"
- android:textColor="?android:attr/textColorSecondary"
- android:textSize="14sp" />
+ </LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
@@ -59,18 +49,20 @@
android:id="@+id/multiple_device_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginTop="12dp"
+ android:layout_marginBottom="12dp"
android:orientation="vertical"
android:visibility="gone">
<View
android:id="@+id/border_top"
- android:layout_marginTop="12dp"
style="@style/DeviceListBorder" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/device_list"
android:layout_width="match_parent"
android:scrollbars="vertical"
+ android:layout_marginBottom="12dp"
android:layout_height="200dp" />
<View
@@ -84,35 +76,56 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+ <ProgressBar
+ android:id="@+id/spinner"
+ android:layout_width="56dp"
+ android:layout_height="56dp"
+ android:layout_centerInParent="true"
+ android:indeterminate="true"
+ android:tint="@android:color/system_accent1_600"
+ android:visibility="gone"
+ style="?android:attr/progressBarStyleLarge" />
+
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:gravity="center"
android:orientation="vertical"
- android:layout_marginTop="24dp">
+ android:layout_marginTop="16dp">
<!-- Do NOT change the IDs of the buttons: they are referenced in CTS tests. -->
<Button
+ android:id="@+id/btn_positive"
+ style="@style/PositiveButton"
+ android:text="@string/consent_yes" />
+
+ <Button
android:id="@+id/btn_negative"
+ android:layout_marginBottom="12dp"
style="@style/NegativeButton"
android:text="@string/consent_no" />
- <Button
- android:id="@+id/btn_positive"
- style="@style/PositiveButton"
- android:text="@string/consent_yes" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="bottom|right"
+ android:orientation="vertical"
+ android:layout_marginRight="16dp"
+ android:layout_marginBottom="16dp">
+
+ <!-- Do NOT change the IDs of the buttons: they are referenced in CTS tests. -->
<Button
android:id="@+id/btn_negative_multiple_devices"
- android:layout_marginLeft="170dp"
- android:layout_marginBottom="10dp"
style="@style/NegativeButtonMultipleDevices"
- android:textColor = "?android:textColorPrimary"
+ android:textColor="?android:textColorPrimary"
android:visibility="gone"
android:text="@string/consent_no" />
-
</LinearLayout>
</LinearLayout> \ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/layout/data_transfer_confirmation.xml b/packages/CompanionDeviceManager/res/layout/data_transfer_confirmation.xml
index 7c508147e0ac..3d0849356281 100644
--- a/packages/CompanionDeviceManager/res/layout/data_transfer_confirmation.xml
+++ b/packages/CompanionDeviceManager/res/layout/data_transfer_confirmation.xml
@@ -15,54 +15,42 @@
~ limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/activity_confirmation"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/dialog_background"
- android:elevation="16dp"
- android:maxHeight="400dp"
- android:orientation="vertical"
- android:padding="18dp"
- android:layout_gravity="center">
+ android:id="@+id/data_transfer_confirmation"
+ style="@style/ContainerLayout">
<!-- Do NOT change the ID of the root LinearLayout above: it's referenced in CTS tests. -->
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:paddingHorizontal="12dp"
- style="@*android:style/TextAppearance.Widget.Toolbar.Title"/>
+ <LinearLayout style="@style/Description">
+ <TextView
+ android:id="@+id/title"
+ style="@style/DescriptionTitle" />
- <TextView
- android:id="@+id/summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
- android:gravity="center"
- android:textColor="?android:attr/textColorSecondary"
- android:textSize="14sp" />
+ <TextView
+ android:id="@+id/summary"
+ style="@style/DescriptionSummary" />
+
+ </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:gravity="center"
android:orientation="vertical"
- android:layout_marginTop="24dp">
+ android:layout_marginTop="16dp">
<!-- Do NOT change the IDs of the buttons: they are referenced in CTS tests. -->
<Button
- android:id="@+id/btn_negative"
- style="@style/NegativeButton"
- android:text="@string/consent_no" />
-
- <Button
android:id="@+id/btn_positive"
style="@style/PositiveButton"
android:text="@string/consent_yes" />
+ <Button
+ android:id="@+id/btn_negative"
+ android:layout_marginBottom="12dp"
+ style="@style/NegativeButton"
+ android:text="@string/consent_no" />
+
</LinearLayout>
</LinearLayout> \ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml b/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml
index c177039891d2..a22ca941c5eb 100644
--- a/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml
+++ b/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
@@ -17,6 +18,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/helper_confirmation"
android:theme="@style/ChooserActivity"
+ android:padding="12dp"
style="@style/ContainerLayout">
<ImageView
@@ -24,8 +26,8 @@
android:layout_width="match_parent"
android:layout_height="32dp"
android:gravity="center"
- android:layout_marginBottom="12dp"
- android:layout_marginTop="1dp"/>
+ android:layout_marginTop="12dp"
+ android:layout_marginBottom="12dp"/>
<TextView
android:id="@+id/helper_title"
@@ -33,17 +35,18 @@
android:layout_height="wrap_content"
android:gravity="center"
android:paddingHorizontal="12dp"
- style="@*android:style/TextAppearance.Widget.Toolbar.Title"
- android:textSize="20sp" />
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="22sp" />
<TextView
android:id="@+id/helper_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginLeft="24dp"
+ android:layout_marginRight="24dp"
android:layout_marginTop="12dp"
- android:layout_marginLeft="20dp"
android:layout_marginBottom="24dp"
- android:gravity="start"
+ android:gravity="center"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp" />
@@ -51,6 +54,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
+ android:layout_marginRight="12dp"
+ android:layout_marginBottom="12dp"
android:gravity="end">
<Button
diff --git a/packages/CompanionDeviceManager/res/layout/list_item_device.xml b/packages/CompanionDeviceManager/res/layout/list_item_device.xml
index 3c8a81f4fe83..eeb988f364b2 100644
--- a/packages/CompanionDeviceManager/res/layout/list_item_device.xml
+++ b/packages/CompanionDeviceManager/res/layout/list_item_device.xml
@@ -28,6 +28,7 @@
android:id="@android:id/icon"
android:layout_width="24dp"
android:layout_height="24dp"
+ android:layout_marginLeft="24dp"
android:layout_marginRight="12dp"
android:tint="@android:color/system_accent1_600"/>
diff --git a/packages/CompanionDeviceManager/res/layout/list_item_permission.xml b/packages/CompanionDeviceManager/res/layout/list_item_permission.xml
index 79aa4e7e8927..3dce38d0dc20 100644
--- a/packages/CompanionDeviceManager/res/layout/list_item_permission.xml
+++ b/packages/CompanionDeviceManager/res/layout/list_item_permission.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
@@ -19,13 +20,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:padding="5dp">
+ android:paddingLeft="32dp"
+ android:paddingRight="32dp"
+ android:paddingBottom="14dp">
<ImageView
android:id="@+id/permission_icon"
android:layout_width="24dp"
android:layout_height="24dp"
- android:layout_marginTop="7dp"
+ android:layout_marginTop="8dp"
android:layout_marginEnd="12dp"
android:tint="@android:color/system_accent1_600"
android:contentDescription="Permission Icon"/>
@@ -48,6 +51,7 @@
android:id="@+id/permission_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingRight="24dp"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"/>
diff --git a/packages/CompanionDeviceManager/res/layout/vendor_header.xml b/packages/CompanionDeviceManager/res/layout/vendor_header.xml
index d04eadfb62f4..5f6aa9419c6e 100644
--- a/packages/CompanionDeviceManager/res/layout/vendor_header.xml
+++ b/packages/CompanionDeviceManager/res/layout/vendor_header.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
@@ -21,7 +22,10 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
- android:layout_marginBottom="16dp"
+ android:paddingTop="24dp"
+ android:paddingBottom="4dp"
+ android:paddingLeft="24dp"
+ android:paddingRight="24dp"
android:visibility="gone" >
<ImageView
@@ -42,7 +46,6 @@
style="?android:attr/actionOverflowButtonStyle"
android:layout_width="31dp"
android:layout_height="32dp"
- android:layout_marginLeft="100dp"
android:layout_alignParentRight="true" />
</RelativeLayout> \ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/values/styles.xml b/packages/CompanionDeviceManager/res/values/styles.xml
index 6eaffd4c3cfe..a55f30c9be6a 100644
--- a/packages/CompanionDeviceManager/res/values/styles.xml
+++ b/packages/CompanionDeviceManager/res/values/styles.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
@@ -16,51 +17,86 @@
<resources>
<style name="ContainerLayout">
- <item name="android:padding">18dp</item>
- <item name="android:elevation">16dp</item>
- <item name="android:maxHeight">400dp</item>
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
<item name="android:orientation">vertical</item>
<item name="android:layout_gravity">center</item>
+ <item name="android:minWidth">340dp</item>
+ <item name="android:background">@drawable/dialog_background</item>
+ </style>
+
+ <style name="Description">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:background">@drawable/dialog_background</item>
+ <item name="android:orientation">vertical</item>
+ <item name="android:layout_marginTop">18dp</item>
+ <item name="android:layout_marginBottom">18dp</item>
+ <item name="android:layout_marginLeft">24dp</item>
+ <item name="android:layout_marginRight">24dp</item>
+ </style>
+
+ <style name="DescriptionTitle"
+ parent="@*android:style/TextAppearance.Widget.Toolbar.Title">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:layout_marginLeft">14dp</item>
+ <item name="android:layout_marginRight">14dp</item>
+ <item name="android:textSize">20sp</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ </style>
+
+ <style name="DescriptionSummary">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:layout_marginTop">18dp</item>
+ <item name="android:layout_marginLeft">18dp</item>
+ <item name="android:layout_marginRight">18dp</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="VendorHelperOkButton"
parent="@android:style/Widget.Material.Button.Borderless.Colored">
<item name="android:layout_width">50dp</item>
- <item name="android:layout_height">35dp</item>
+ <item name="android:layout_height">36dp</item>
<item name="android:layout_marginTop">20dp</item>
<item name="android:textColor">@android:color/system_neutral1_900</item>
<item name="android:background">@drawable/helper_ok_button</item>
</style>
- <style name="NegativeButton"
+ <style name="PositiveButton"
parent="@android:style/Widget.Material.Button.Borderless.Colored">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_width">300dp</item>
+ <item name="android:layout_height">56dp</item>
+ <item name="android:layout_marginLeft">24dp</item>
+ <item name="android:layout_marginRight">24dp</item>
+ <item name="android:layout_marginBottom">2dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/system_neutral1_900</item>
- <item name="android:background">@drawable/btn_negative_top</item>
+ <item name="android:background">@drawable/btn_positive_bottom</item>
</style>
- <style name="PositiveButton"
+ <style name="NegativeButton"
parent="@android:style/Widget.Material.Button.Borderless.Colored">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_width">300dp</item>
+ <item name="android:layout_height">56dp</item>
+ <item name="android:layout_marginLeft">24dp</item>
+ <item name="android:layout_marginRight">24dp</item>
+ <item name="android:layout_marginTop">2dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/system_neutral1_900</item>
<item name="android:layout_marginTop">4dp</item>
- <item name="android:background">@drawable/btn_positive_bottom</item>
+ <item name="android:background">@drawable/btn_negative_top</item>
</style>
<style name="NegativeButtonMultipleDevices"
parent="@android:style/Widget.Material.Button.Colored">
<item name="android:layout_width">100dp</item>
- <item name="android:layout_height">35dp</item>
- <item name="android:layout_marginTop">20dp</item>
+ <item name="android:layout_height">36dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:background">@drawable/btn_negative_multiple_devices</item>
</style>
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java
index f752b697c4a5..0bdf65d8ef55 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java
@@ -57,6 +57,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -116,14 +117,14 @@ public class CompanionDeviceActivity extends FragmentActivity implements
private ImageButton mVendorHeaderButton;
// Progress indicator is only shown while we are looking for the first suitable device for a
- // "regular" (ie. not self-managed) association.
- private View mProgressIndicator;
+ // multiple device association.
+ private ProgressBar mProgressIndicator;
// Present for self-managed association requests and "single-device" regular association
// regular.
private Button mButtonAllow;
private Button mButtonNotAllow;
- // Present for multiple device association requests only.
+ // Present for multiple devices' association requests only.
private Button mButtonNotAllowMultipleDevices;
private LinearLayout mAssociationConfirmationDialog;
@@ -263,6 +264,8 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mVendorHeaderButton = findViewById(R.id.vendor_header_button);
mDeviceListRecyclerView = findViewById(R.id.device_list);
+
+ mProgressIndicator = findViewById(R.id.spinner);
mDeviceAdapter = new DeviceListAdapter(this, this::onListItemClick);
mPermissionListRecyclerView = findViewById(R.id.permission_list);
@@ -502,21 +505,25 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mSummary.setText(summary);
mProfileIcon.setImageDrawable(profileIcon);
- mDeviceAdapter = new DeviceListAdapter(this, this::onListItemClick);
-
- // TODO: hide the list and show a spinner until a first device matching device is found.
mDeviceListRecyclerView.setAdapter(mDeviceAdapter);
mDeviceListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
- CompanionDeviceDiscoveryService.getScanResult().observe(
- /* lifecycleOwner */ this,
- /* observer */ mDeviceAdapter);
+ CompanionDeviceDiscoveryService.getScanResult().observe(this,
+ deviceFilterPairs -> {
+ // Dismiss the progress bar once there's one device found for multiple devices.
+ if (deviceFilterPairs.size() >= 1) {
+ mProgressIndicator.setVisibility(View.GONE);
+ }
+
+ mDeviceAdapter.setDevices(deviceFilterPairs);
+ });
// "Remove" consent button: users would need to click on the list item.
mButtonAllow.setVisibility(View.GONE);
mButtonNotAllow.setVisibility(View.GONE);
mButtonNotAllowMultipleDevices.setVisibility(View.VISIBLE);
mMultipleDeviceList.setVisibility(View.VISIBLE);
+ mProgressIndicator.setVisibility(View.VISIBLE);
}
private void onListItemClick(int position) {
@@ -564,7 +571,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
CompanionVendorHelperDialogFragment.newInstance(mRequest.getPackageName(),
mRequest.getUserId(), mRequest.getDeviceProfile());
- mAssociationConfirmationDialog.setVisibility(View.GONE);
+ mAssociationConfirmationDialog.setVisibility(View.INVISIBLE);
fragmentDialog.show(fragmentManager, /* Tag */ FRAGMENT_DIALOG_TAG);
}
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java
index 5f07fcfd8565..e8a1a5cc1916 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java
@@ -150,6 +150,8 @@ public class CompanionDeviceDiscoveryService extends Service {
mBtAdapter = mBtManager.getAdapter();
mBleScanner = mBtAdapter.getBluetoothLeScanner();
mWifiManager = getSystemService(WifiManager.class);
+
+ sScanResultsLiveData.setValue(Collections.emptyList());
}
@Override
@@ -186,7 +188,6 @@ public class CompanionDeviceDiscoveryService extends Service {
mStopAfterFirstMatch = request.isSingleDevice();
mDiscoveryStarted = true;
sStateLiveData.setValue(DiscoveryState.DISCOVERY_IN_PROGRESS);
- sScanResultsLiveData.setValue(Collections.emptyList());
final List<DeviceFilter<?>> allFilters = request.getDeviceFilters();
final List<BluetoothDeviceFilter> btFilters =
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceListAdapter.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceListAdapter.java
index 8babd3ade1eb..328c67ebb216 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceListAdapter.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceListAdapter.java
@@ -25,15 +25,13 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
-import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
/**
* Adapter for the list of "found" devices.
*/
-class DeviceListAdapter extends RecyclerView.Adapter<DeviceListAdapter.ViewHolder> implements
- Observer<List<DeviceFilterPair<?>>> {
+class DeviceListAdapter extends RecyclerView.Adapter<DeviceListAdapter.ViewHolder> {
public int mSelectedPosition = RecyclerView.NO_POSITION;
private final Context mContext;
@@ -96,9 +94,8 @@ class DeviceListAdapter extends RecyclerView.Adapter<DeviceListAdapter.ViewHolde
mSelectedPosition = position;
}
- @Override
- public void onChanged(List<DeviceFilterPair<?>> deviceFilterPairs) {
- mDevices = deviceFilterPairs;
+ void setDevices(List<DeviceFilterPair<?>> devices) {
+ mDevices = devices;
notifyDataSetChanged();
}