Introduce a progessBar for multiple devices
And a progessBar for multiple devices dialog
only. The progessBar will disapear after the
first device is found.
Test: atest CtsCompanionDeviceManagerCoreTestCases
atest CtsCompanionDeviceManagerUiAutomationTestCases
atest CtsOsTestCases:CompanionDeviceManagerTest
Bug: 211722613
Change-Id: Id79820099837fae7dc273ce038f772910258fa07
This commit is contained in:
@@ -84,6 +84,16 @@
|
||||
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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user