Apply RangeBuilder amination for media transferring
-Replace transferring string with animation
-Set RANGE_MODE_INDETERMINATE mode when transferring
-Add padding parameter for indeterminate progress bar
Bug: 153615031
Test: make -j42 RunSettingsRoboTests
Change-Id: I11c99aaf0c9d585dc834b06919f062d44eefbf65
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a60fbd5..1c60208 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -574,6 +574,10 @@
<!-- Align text with slider -->
<item name="titleStartPadding">11dp</item>
<item name="subContentStartPadding">11dp</item>
+
+ <!-- Padding for indeterminate progress bar -->
+ <item name="progressBarStartPadding">12dp</item>
+ <item name="progressBarEndPadding">16dp</item>
</style>
<style name="DisclaimerPositiveButton" parent="@style/SudGlifButton.Primary">
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 82a7bd2..94a4f50 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -229,7 +229,11 @@
listBuilder.addRow(builder);
}
} else {
- listBuilder.addRow(getMediaDeviceRow(device));
+ if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) {
+ listBuilder.addRange(getTransferringMediaDeviceRow(device));
+ } else {
+ listBuilder.addRow(getMediaDeviceRow(device));
+ }
}
}
@@ -279,6 +283,19 @@
return devices;
}
+ private ListBuilder.RangeBuilder getTransferringMediaDeviceRow(MediaDevice device) {
+ final IconCompat deviceIcon = getDeviceIconCompat(device);
+ final SliceAction sliceAction = SliceAction.create(getBroadcastIntent(mContext,
+ device.getId(), device.hashCode()), deviceIcon, ListBuilder.ICON_IMAGE,
+ mContext.getText(R.string.media_output_switching));
+
+ return new ListBuilder.RangeBuilder()
+ .setTitleItem(deviceIcon, ListBuilder.ICON_IMAGE)
+ .setMode(ListBuilder.RANGE_MODE_INDETERMINATE)
+ .setTitle(device.getName())
+ .setPrimaryAction(sliceAction);
+ }
+
private ListBuilder.RowBuilder getMediaDeviceRow(MediaDevice device) {
final String deviceName = device.getName();
final PendingIntent broadcastAction =
@@ -290,15 +307,11 @@
if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE
&& !device.isConnected()) {
final int state = device.getState();
- if (state == LocalMediaManager.MediaDeviceState.STATE_CONNECTING
- || state == LocalMediaManager.MediaDeviceState.STATE_CONNECTING_FAILED) {
+ if (state == LocalMediaManager.MediaDeviceState.STATE_CONNECTING_FAILED) {
rowBuilder.setTitle(deviceName);
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
ListBuilder.ICON_IMAGE, deviceName));
- rowBuilder.setSubtitle(
- (state == LocalMediaManager.MediaDeviceState.STATE_CONNECTING)
- ? mContext.getText(R.string.media_output_switching)
- : mContext.getText(R.string.bluetooth_connect_failed));
+ rowBuilder.setSubtitle(mContext.getText(R.string.bluetooth_connect_failed));
} else {
// Append status to title only for the disconnected Bluetooth device.
final SpannableString spannableTitle = new SpannableString(
@@ -316,14 +329,8 @@
rowBuilder.setTitle(deviceName);
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
ListBuilder.ICON_IMAGE, deviceName));
- switch (device.getState()) {
- case LocalMediaManager.MediaDeviceState.STATE_CONNECTING:
- rowBuilder.setSubtitle(mContext.getText(R.string.media_output_switching));
- break;
- case LocalMediaManager.MediaDeviceState.STATE_CONNECTING_FAILED:
- rowBuilder.setSubtitle(mContext.getText(
- R.string.media_output_switch_error_text));
- break;
+ if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING_FAILED) {
+ rowBuilder.setSubtitle(mContext.getText(R.string.media_output_switch_error_text));
}
}