Disable group volume control bar in output switcher systemUI dialog

-Disable static(Pre-defined) group volume seekbar
-Disable dynamic group volume seekbar
-Disable group volume seekbar in edit page

Bug: 189270378
Test: atest MediaOutputAdapterTest MediaOutputControllerTest MediaOutputBaseDialogTest MediaOutputDialogTest MediaOutputGroupAdapterTest MediaOutputGroupDialogTest
Change-Id: Ifc560e21a3ae8a4830be5c5c5d1fb94f452e36b0
This commit is contained in:
Tim Peng
2021-06-01 12:06:26 +08:00
parent 0c59d91acc
commit 0ccbd4e52c
3 changed files with 14 additions and 0 deletions

View File

@@ -81,6 +81,7 @@
android:visibility="gone"/>
<SeekBar
android:id="@+id/volume_seekbar"
style="@*android:style/Widget.DeviceDefault.SeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>

View File

@@ -202,6 +202,9 @@ public abstract class MediaOutputBaseAdapter extends
}
void initSeekbar(MediaDevice device) {
if (!mController.isVolumeControlEnabled(device)) {
disableSeekBar();
}
mSeekBar.setMax(device.getMaxVolume());
mSeekBar.setMin(0);
final int currentVolume = device.getCurrentVolume();
@@ -230,6 +233,7 @@ public abstract class MediaOutputBaseAdapter extends
}
void initSessionSeekbar() {
disableSeekBar();
mSeekBar.setMax(mController.getSessionVolumeMax());
mSeekBar.setMin(0);
final int currentVolume = mController.getSessionVolume();
@@ -318,5 +322,10 @@ public abstract class MediaOutputBaseAdapter extends
PorterDuff.Mode.SRC_IN));
return BluetoothUtils.buildAdvancedDrawable(mContext, drawable);
}
private void disableSeekBar() {
mSeekBar.setEnabled(false);
mSeekBar.setOnTouchListener((v, event) -> true);
}
}
}

View File

@@ -475,6 +475,10 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|| features.contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK));
}
boolean isVolumeControlEnabled(@NonNull MediaDevice device) {
return !device.getFeatures().contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK);
}
private final MediaController.Callback mCb = new MediaController.Callback() {
@Override
public void onMetadataChanged(MediaMetadata metadata) {