diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java
index 903ff72761012..32eb5d55568c3 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java
@@ -172,5 +172,6 @@ public interface VolumeDialogController {
void onScreenOff();
void onShowSafetyWarning(int flags);
void onAccessibilityModeChanged(Boolean showA11yStream);
+ void onConnectedDeviceChanged(String deviceName);
}
}
diff --git a/packages/SystemUI/res/drawable/ic_swap.xml b/packages/SystemUI/res/drawable/ic_swap.xml
new file mode 100644
index 0000000000000..30da2a9f532f1
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_swap.xml
@@ -0,0 +1,25 @@
+
+
+
+
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/volume_dialog_row.xml b/packages/SystemUI/res/layout/volume_dialog_row.xml
index 3590b768c91b8..1d1f95b446591 100644
--- a/packages/SystemUI/res/layout/volume_dialog_row.xml
+++ b/packages/SystemUI/res/layout/volume_dialog_row.xml
@@ -38,23 +38,34 @@
android:maxLines="1"
android:textColor="?android:attr/colorControlNormal"
android:textAppearance="?android:attr/textAppearanceSmall" />
-
-
+ android:gravity="center">
+
+
+
entry : mCallbackMap.entrySet()) {
+ entry.getValue().post(new Runnable() {
+ @Override
+ public void run() {
+ entry.getKey().onConnectedDeviceChanged(deviceName);
+ }
+ });
+ }
+ }
}
@@ -1005,6 +1024,34 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
}
}
+ protected final class DeviceCallback extends AudioDeviceCallback {
+ public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
+ for (AudioDeviceInfo info : addedDevices) {
+ if (info.isSink()
+ && (info.getType() == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
+ || info.getType() == AudioDeviceInfo.TYPE_BLUETOOTH_SCO)) {
+ mConnectedDevice = info;
+ mCallbacks.onConnectedDeviceChanged(info.getProductName().toString());
+ }
+ }
+ }
+
+ public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
+ if (mConnectedDevice == null) {
+ mCallbacks.onConnectedDeviceChanged(null);
+ return;
+ }
+ for (AudioDeviceInfo info : removedDevices) {
+ if (info.isSink() == mConnectedDevice.isSink()
+ && Objects.equals(info.getProductName(), mConnectedDevice.getProductName())
+ && info.getType() == mConnectedDevice.getType()) {
+ mConnectedDevice = null;
+ mCallbacks.onConnectedDeviceChanged(null);
+ }
+ }
+ }
+ }
+
public interface UserActivityListener {
void onUserActivity();
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index 385438c65ba7c..56b7201ea274d 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -48,6 +48,7 @@ import android.os.SystemClock;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.support.v7.media.MediaRouter;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
import android.util.SparseBooleanArray;
@@ -73,6 +74,7 @@ import android.widget.TextView;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.VolumeDialog;
import com.android.systemui.plugins.VolumeDialogController;
import com.android.systemui.plugins.VolumeDialogController.State;
@@ -332,8 +334,11 @@ public class VolumeDialogImpl implements VolumeDialog {
row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
row.anim = null;
- ImageButton outputChooser = row.view.findViewById(R.id.output_chooser);
- outputChooser.setOnClickListener(mClickOutputChooser);
+ row.outputChooser = row.view.findViewById(R.id.output_chooser);
+ row.outputChooser.setOnClickListener(mClickOutputChooser);
+ row.outputChooser.findViewById(R.id.output_chooser_button)
+ .setOnClickListener(mClickOutputChooser);
+ row.connectedDevice = row.view.findViewById(R.id.volume_row_connected_device);
// forward events above the slider into the slider
row.view.setOnTouchListener(new OnTouchListener() {
@@ -422,7 +427,7 @@ public class VolumeDialogImpl implements VolumeDialog {
Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
dismissH(DISMISS_REASON_SETTINGS_CLICKED);
- mContext.startActivity(intent);
+ Dependency.get(ActivityStarter.class).startActivity(intent, true /* dismissShade */);
return true;
});
updateRingerH();
@@ -546,6 +551,13 @@ public class VolumeDialogImpl implements VolumeDialog {
}
}
+ protected void updateConnectedDeviceH(String deviceName) {
+ for (final VolumeRow row : mRows) {
+ row.connectedDevice.setText(deviceName);
+ Util.setVisOrGone(row.connectedDevice, !TextUtils.isEmpty(deviceName));
+ }
+ }
+
protected void updateRingerH() {
if (mState != null) {
final StreamState ss = mState.states.get(AudioManager.STREAM_RING);
@@ -957,6 +969,11 @@ public class VolumeDialogImpl implements VolumeDialog {
}
}
+
+ @Override
+ public void onConnectedDeviceChanged(String deviceName) {
+ updateConnectedDeviceH(deviceName);
+ }
};
private final class H extends Handler {
@@ -1155,5 +1172,7 @@ public class VolumeDialogImpl implements VolumeDialog {
private ObjectAnimator anim; // slider progress animation for non-touch-related updates
private int animTargetProgress;
private int lastAudibleLevel = 1;
+ private View outputChooser;
+ private TextView connectedDevice;
}
}