summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Chen <evanxinchen@google.com> 2022-03-25 15:52:34 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-03-25 15:52:34 +0000
commit20f8f2989dffdfc391244a82f601f5e12cd19adc (patch)
treeb71fd610357df99404e3014a93fbdebdde1e3c33
parentc88a1ff323efaf3d839db02c37c3e72777f1835a (diff)
parent564a1203ea3a401f9f24b04c5e8436184460dcd5 (diff)
Merge "Add a spinner for singleDevice" into tm-dev
-rw-r--r--packages/CompanionDeviceManager/res/layout/activity_confirmation.xml183
-rw-r--r--packages/CompanionDeviceManager/res/values/styles.xml7
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java18
3 files changed, 119 insertions, 89 deletions
diff --git a/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml b/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml
index c37054e9e98d..c0e6c09d69ed 100644
--- a/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml
+++ b/packages/CompanionDeviceManager/res/layout/activity_confirmation.xml
@@ -12,120 +12,135 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/activity_confirmation"
- style="@style/ContainerLayout">
+ android:id="@+id/activity_confirmation"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:minWidth="340dp">
- <!-- A header for selfManaged devices only. -->
- <include layout="@layout/vendor_header" />
+ <LinearLayout android:id="@+id/association_confirmation"
+ style="@style/ContainerLayout">
- <!-- Do NOT change the ID of the root LinearLayout above: it's referenced in CTS tests. -->
+ <!-- A header for selfManaged devices only. -->
+ <include layout="@layout/vendor_header" />
- <ImageView
- android:id="@+id/profile_icon"
- android:layout_width="match_parent"
- android:layout_height="32dp"
- android:gravity="center"
- 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" />
+ <ImageView
+ android:id="@+id/profile_icon"
+ android:layout_width="match_parent"
+ android:layout_height="32dp"
+ android:gravity="center"
+ android:layout_marginTop="18dp"
+ android:tint="@android:color/system_accent1_600"/>
- <TextView
- android:id="@+id/summary"
- style="@style/DescriptionSummary" />
+ <LinearLayout style="@style/Description">
+ <TextView
+ android:id="@+id/title"
+ style="@style/DescriptionTitle" />
- </LinearLayout>
+ <TextView
+ android:id="@+id/summary"
+ style="@style/DescriptionSummary" />
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
+ </LinearLayout>
- <LinearLayout
- android:id="@+id/multiple_device_list"
+ <RelativeLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
- android:orientation="vertical"
- android:visibility="gone">
+ android:layout_height="0dp"
+ android:layout_weight="1">
+
+ <LinearLayout
+ 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"
- style="@style/DeviceListBorder" />
+ <View
+ android:id="@+id/border_top"
+ 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
+ android:id="@+id/border_bottom"
+ style="@style/DeviceListBorder" />
+
+ </LinearLayout>
<androidx.recyclerview.widget.RecyclerView
- android:id="@+id/device_list"
+ android:id="@+id/permission_list"
android:layout_width="match_parent"
- android:scrollbars="vertical"
- android:layout_marginBottom="12dp"
- android:layout_height="200dp" />
+ android:layout_height="wrap_content" />
- <View
- android:id="@+id/border_bottom"
- style="@style/DeviceListBorder" />
+ <ProgressBar
+ android:id="@+id/spinner_multiple_device"
+ android:visibility="gone"
+ style="@style/Spinner" />
- </LinearLayout>
+ </RelativeLayout>
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/permission_list"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="vertical"
+ android:layout_marginTop="16dp">
- <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" />
+ <!-- Do NOT change the IDs of the buttons: they are referenced in CTS tests. -->
- </RelativeLayout>
+ <Button
+ android:id="@+id/btn_positive"
+ style="@style/PositiveButton"
+ android:text="@string/consent_yes" />
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:orientation="vertical"
- android:layout_marginTop="16dp">
+ <Button
+ android:id="@+id/btn_negative"
+ android:layout_marginBottom="12dp"
+ style="@style/NegativeButton"
+ android:text="@string/consent_no" />
+
+ </LinearLayout>
- <!-- Do NOT change the IDs of the buttons: they are referenced in CTS tests. -->
+ <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">
- <Button
- android:id="@+id/btn_positive"
- style="@style/PositiveButton"
- android:text="@string/consent_yes" />
+ <!-- Do NOT change the IDs of the buttons: they are referenced in CTS tests. -->
- <Button
- android:id="@+id/btn_negative"
- android:layout_marginBottom="12dp"
- style="@style/NegativeButton"
- android:text="@string/consent_no" />
+ <Button
+ android:id="@+id/btn_negative_multiple_devices"
+ style="@style/NegativeButtonMultipleDevices"
+ android:textColor="?android:textColorPrimary"
+ android:visibility="gone"
+ android:text="@string/consent_no" />
+ </LinearLayout>
</LinearLayout>
- <LinearLayout
+ <RelativeLayout
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. -->
+ android:layout_weight="1">
- <Button
- android:id="@+id/btn_negative_multiple_devices"
- style="@style/NegativeButtonMultipleDevices"
- android:textColor="?android:textColorPrimary"
+ <ProgressBar
+ android:id="@+id/spinner_single_device"
android:visibility="gone"
- android:text="@string/consent_no" />
- </LinearLayout>
+ style="@style/Spinner" />
+ </RelativeLayout>>
</LinearLayout> \ No newline at end of file
diff --git a/packages/CompanionDeviceManager/res/values/styles.xml b/packages/CompanionDeviceManager/res/values/styles.xml
index faa303219cf0..c38323f5f73c 100644
--- a/packages/CompanionDeviceManager/res/values/styles.xml
+++ b/packages/CompanionDeviceManager/res/values/styles.xml
@@ -108,4 +108,11 @@
<item name="android:background">@android:color/system_accent1_300</item>
</style>
+ <style name="Spinner"
+ parent="@android:style/Widget.Material.Light.ProgressBar.Large">
+ <item name="android:layout_width">56dp</item>
+ <item name="android:layout_height">56dp</item>
+ <item name="android:indeterminate">true</item>
+ <item name="android:layout_centerInParent">true</item>
+ </style>
</resources> \ No newline at end of file
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java
index b5968162214d..37cbf3017f0b 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java
@@ -122,7 +122,10 @@ public class CompanionDeviceActivity extends FragmentActivity implements
// Progress indicator is only shown while we are looking for the first suitable device for a
// multiple device association.
- private ProgressBar mProgressIndicator;
+ private ProgressBar mMultipleDeviceSpinner;
+ // Progress indicator is only shown while we are looking for the first suitable device for a
+ // single device association.
+ private ProgressBar mSingleDeviceSpinner;
// Present for self-managed association requests and "single-device" regular association
// regular.
@@ -255,7 +258,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
setContentView(R.layout.activity_confirmation);
mMultipleDeviceList = findViewById(R.id.multiple_device_list);
- mAssociationConfirmationDialog = findViewById(R.id.activity_confirmation);
+ mAssociationConfirmationDialog = findViewById(R.id.association_confirmation);
mVendorHeader = findViewById(R.id.vendor_header);
mTitle = findViewById(R.id.title);
@@ -269,7 +272,8 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mDeviceListRecyclerView = findViewById(R.id.device_list);
- mProgressIndicator = findViewById(R.id.spinner);
+ mMultipleDeviceSpinner = findViewById(R.id.spinner_multiple_device);
+ mSingleDeviceSpinner = findViewById(R.id.spinner_single_device);
mDeviceAdapter = new DeviceListAdapter(this, this::onListItemClick);
mPermissionListRecyclerView = findViewById(R.id.permission_list);
@@ -468,8 +472,10 @@ public class CompanionDeviceActivity extends FragmentActivity implements
deviceFilterPairs -> updateSingleDeviceUi(
deviceFilterPairs, deviceProfile, appLabel));
+ mSingleDeviceSpinner.setVisibility(View.VISIBLE);
mPermissionListRecyclerView.setVisibility(View.GONE);
mDeviceListRecyclerView.setVisibility(View.GONE);
+ mAssociationConfirmationDialog.setVisibility(View.GONE);
}
private void updateSingleDeviceUi(List<DeviceFilterPair<?>> deviceFilterPairs,
@@ -499,6 +505,8 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mTitle.setText(title);
mSummary.setText(summary);
mProfileIcon.setImageDrawable(profileIcon);
+ mSingleDeviceSpinner.setVisibility(View.GONE);
+ mAssociationConfirmationDialog.setVisibility(View.VISIBLE);
}
private void initUiForMultipleDevices(CharSequence appLabel) {
@@ -535,7 +543,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
deviceFilterPairs -> {
// Dismiss the progress bar once there's one device found for multiple devices.
if (deviceFilterPairs.size() >= 1) {
- mProgressIndicator.setVisibility(View.GONE);
+ mMultipleDeviceSpinner.setVisibility(View.GONE);
}
mDeviceAdapter.setDevices(deviceFilterPairs);
@@ -546,7 +554,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mButtonNotAllow.setVisibility(View.GONE);
mButtonNotAllowMultipleDevices.setVisibility(View.VISIBLE);
mMultipleDeviceList.setVisibility(View.VISIBLE);
- mProgressIndicator.setVisibility(View.VISIBLE);
+ mMultipleDeviceSpinner.setVisibility(View.VISIBLE);
}
private void onListItemClick(int position) {