Merge "Hide the audio switcher if it is not relevant" into pi-dev
am: 3f5444b9e4
Change-Id: Ie376aafe5ebfff928e5011ac772f5faaeb494c0d
This commit is contained in:
@@ -134,6 +134,7 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mPreference = screen.findPreference(mPreferenceKey);
|
mPreference = screen.findPreference(mPreferenceKey);
|
||||||
|
mPreference.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -47,7 +47,7 @@ public class HandsFreeProfileOutputPreferenceController extends
|
|||||||
|
|
||||||
if (!isOngoingCallStatus()) {
|
if (!isOngoingCallStatus()) {
|
||||||
// Without phone call, disable the switch entry.
|
// Without phone call, disable the switch entry.
|
||||||
preference.setEnabled(false);
|
mPreference.setVisible(false);
|
||||||
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -67,12 +67,12 @@ public class HandsFreeProfileOutputPreferenceController extends
|
|||||||
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
||||||
if (numDevices == 0) {
|
if (numDevices == 0) {
|
||||||
// No connected devices, disable switch entry.
|
// No connected devices, disable switch entry.
|
||||||
preference.setEnabled(false);
|
mPreference.setVisible(false);
|
||||||
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
preference.setEnabled(true);
|
mPreference.setVisible(true);
|
||||||
CharSequence[] mediaOutputs = new CharSequence[numDevices + 1];
|
CharSequence[] mediaOutputs = new CharSequence[numDevices + 1];
|
||||||
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
||||||
|
|
||||||
|
@@ -52,14 +52,14 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
|||||||
|
|
||||||
if (isStreamFromOutputDevice(STREAM_MUSIC, DEVICE_OUT_REMOTE_SUBMIX)) {
|
if (isStreamFromOutputDevice(STREAM_MUSIC, DEVICE_OUT_REMOTE_SUBMIX)) {
|
||||||
// In cast mode, disable switch entry.
|
// In cast mode, disable switch entry.
|
||||||
preference.setEnabled(false);
|
mPreference.setVisible(false);
|
||||||
preference.setSummary(mContext.getText(R.string.media_output_summary_unavailable));
|
preference.setSummary(mContext.getText(R.string.media_output_summary_unavailable));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOngoingCallStatus()) {
|
if (isOngoingCallStatus()) {
|
||||||
// Ongoing call status, switch entry for media will be disabled.
|
// Ongoing call status, switch entry for media will be disabled.
|
||||||
preference.setEnabled(false);
|
mPreference.setVisible(false);
|
||||||
preference.setSummary(
|
preference.setSummary(
|
||||||
mContext.getText(R.string.media_out_summary_ongoing_call_state));
|
mContext.getText(R.string.media_out_summary_ongoing_call_state));
|
||||||
return;
|
return;
|
||||||
@@ -79,12 +79,12 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
|||||||
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
||||||
if (numDevices == 0) {
|
if (numDevices == 0) {
|
||||||
// Disable switch entry if there is no connected devices.
|
// Disable switch entry if there is no connected devices.
|
||||||
preference.setEnabled(false);
|
mPreference.setVisible(false);
|
||||||
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
preference.setEnabled(true);
|
mPreference.setVisible(true);
|
||||||
CharSequence[] mediaOutputs = new CharSequence[numDevices + 1];
|
CharSequence[] mediaOutputs = new CharSequence[numDevices + 1];
|
||||||
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
||||||
|
|
||||||
|
@@ -245,7 +245,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return null;
|
return TEST_KEY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -159,7 +159,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One Headset Bluetooth device is available and activated
|
* One Headset Bluetooth device is available and activated
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be activate device name
|
* Preference summary should be activate device name
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -170,13 +170,13 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mBluetoothDevice.getName());
|
assertThat(mPreference.getSummary()).isEqualTo(mBluetoothDevice.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More than one Headset Bluetooth devices are available, and second device is active.
|
* More than one Headset Bluetooth devices are available, and second device is active.
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be activate device name
|
* Preference summary should be activate device name
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -196,14 +196,14 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(secondBluetoothDevice.getName());
|
assertThat(mPreference.getSummary()).isEqualTo(secondBluetoothDevice.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hands Free Profile Bluetooth device(s) are available, but wired headset is plugged in
|
* Hands Free Profile Bluetooth device(s) are available, but wired headset is plugged in
|
||||||
* and activated.
|
* and activated.
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be "This device"
|
* Preference summary should be "This device"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -216,14 +216,14 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(
|
assertThat(mPreference.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.media_output_default_summary));
|
mContext.getText(R.string.media_output_default_summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No available Headset BT devices
|
* No available Headset BT devices
|
||||||
* Preference should be disabled
|
* Preference should be invisible
|
||||||
* Preference summary should be "This device"
|
* Preference summary should be "This device"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -234,7 +234,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isVisible()).isFalse();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(
|
assertThat(mPreference.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.media_output_default_summary));
|
mContext.getText(R.string.media_output_default_summary));
|
||||||
}
|
}
|
||||||
|
@@ -160,7 +160,7 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* On going call state:
|
* On going call state:
|
||||||
* Preference should be disabled
|
* Preference should be invisible
|
||||||
* Default string should be "Unavailable during calls"
|
* Default string should be "Unavailable during calls"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -169,14 +169,14 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isVisible()).isFalse();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(
|
assertThat(mPreference.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.media_out_summary_ongoing_call_state));
|
mContext.getText(R.string.media_out_summary_ongoing_call_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No available A2dp BT devices:
|
* No available A2dp BT devices:
|
||||||
* Preference should be disabled
|
* Preference should be invisible
|
||||||
* Preference summary should be "This device"
|
* Preference summary should be "This device"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -187,14 +187,14 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isVisible()).isFalse();
|
||||||
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media stream is captured by something else (cast device):
|
* Media stream is captured by something else (cast device):
|
||||||
* Preference should be disabled
|
* Preference should be invisible
|
||||||
* Preference summary should be "unavailable"
|
* Preference summary should be "unavailable"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -203,14 +203,14 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isVisible()).isFalse();
|
||||||
String defaultString = mContext.getString(R.string.media_output_summary_unavailable);
|
String defaultString = mContext.getString(R.string.media_output_summary_unavailable);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One A2DP Bluetooth device is available and active.
|
* One A2DP Bluetooth device is available and active.
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be activate device name
|
* Preference summary should be activate device name
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -221,13 +221,13 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mBluetoothDevice.getName());
|
assertThat(mPreference.getSummary()).isEqualTo(mBluetoothDevice.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More than one A2DP Bluetooth devices are available, and second device is active.
|
* More than one A2DP Bluetooth devices are available, and second device is active.
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be activate device name
|
* Preference summary should be activate device name
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -247,13 +247,13 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(secondBluetoothDevice.getName());
|
assertThat(mPreference.getSummary()).isEqualTo(secondBluetoothDevice.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A2DP Bluetooth device(s) are available, but wired headset is plugged in and activated
|
* A2DP Bluetooth device(s) are available, but wired headset is plugged in and activated
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be "This device"
|
* Preference summary should be "This device"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -266,7 +266,7 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A2DP Bluetooth device(s) are available, but current device speaker is activated
|
* A2DP Bluetooth device(s) are available, but current device speaker is activated
|
||||||
* Preference should be enabled
|
* Preference should be visible
|
||||||
* Preference summary should be "This device"
|
* Preference summary should be "This device"
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@@ -285,7 +285,7 @@ public class MediaOutputPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user