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) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(mPreferenceKey);
|
||||
mPreference.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -47,7 +47,7 @@ public class HandsFreeProfileOutputPreferenceController extends
|
||||
|
||||
if (!isOngoingCallStatus()) {
|
||||
// Without phone call, disable the switch entry.
|
||||
preference.setEnabled(false);
|
||||
mPreference.setVisible(false);
|
||||
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
||||
return;
|
||||
}
|
||||
@@ -67,12 +67,12 @@ public class HandsFreeProfileOutputPreferenceController extends
|
||||
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
||||
if (numDevices == 0) {
|
||||
// No connected devices, disable switch entry.
|
||||
preference.setEnabled(false);
|
||||
mPreference.setVisible(false);
|
||||
preference.setSummary(mContext.getText(R.string.media_output_default_summary));
|
||||
return;
|
||||
}
|
||||
|
||||
preference.setEnabled(true);
|
||||
mPreference.setVisible(true);
|
||||
CharSequence[] mediaOutputs = 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)) {
|
||||
// In cast mode, disable switch entry.
|
||||
preference.setEnabled(false);
|
||||
mPreference.setVisible(false);
|
||||
preference.setSummary(mContext.getText(R.string.media_output_summary_unavailable));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOngoingCallStatus()) {
|
||||
// Ongoing call status, switch entry for media will be disabled.
|
||||
preference.setEnabled(false);
|
||||
mPreference.setVisible(false);
|
||||
preference.setSummary(
|
||||
mContext.getText(R.string.media_out_summary_ongoing_call_state));
|
||||
return;
|
||||
@@ -79,12 +79,12 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
||||
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
||||
if (numDevices == 0) {
|
||||
// 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));
|
||||
return;
|
||||
}
|
||||
|
||||
preference.setEnabled(true);
|
||||
mPreference.setVisible(true);
|
||||
CharSequence[] mediaOutputs = new CharSequence[numDevices + 1];
|
||||
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
||||
|
||||
|
@@ -245,7 +245,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return null;
|
||||
return TEST_KEY;
|
||||
}
|
||||
}
|
||||
}
|
@@ -159,7 +159,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
||||
|
||||
/**
|
||||
* One Headset Bluetooth device is available and activated
|
||||
* Preference should be enabled
|
||||
* Preference should be visible
|
||||
* Preference summary should be activate device name
|
||||
*/
|
||||
@Test
|
||||
@@ -170,13 +170,13 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(mBluetoothDevice.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Test
|
||||
@@ -196,14 +196,14 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(secondBluetoothDevice.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hands Free Profile 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"
|
||||
*/
|
||||
@Test
|
||||
@@ -216,14 +216,14 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
mContext.getText(R.string.media_output_default_summary));
|
||||
}
|
||||
|
||||
/**
|
||||
* No available Headset BT devices
|
||||
* Preference should be disabled
|
||||
* Preference should be invisible
|
||||
* Preference summary should be "This device"
|
||||
*/
|
||||
@Test
|
||||
@@ -234,7 +234,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
mContext.getText(R.string.media_output_default_summary));
|
||||
}
|
||||
|
@@ -160,7 +160,7 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
/**
|
||||
* On going call state:
|
||||
* Preference should be disabled
|
||||
* Preference should be invisible
|
||||
* Default string should be "Unavailable during calls"
|
||||
*/
|
||||
@Test
|
||||
@@ -169,14 +169,14 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
mContext.getText(R.string.media_out_summary_ongoing_call_state));
|
||||
}
|
||||
|
||||
/**
|
||||
* No available A2dp BT devices:
|
||||
* Preference should be disabled
|
||||
* Preference should be invisible
|
||||
* Preference summary should be "This device"
|
||||
*/
|
||||
@Test
|
||||
@@ -187,14 +187,14 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Media stream is captured by something else (cast device):
|
||||
* Preference should be disabled
|
||||
* Preference should be invisible
|
||||
* Preference summary should be "unavailable"
|
||||
*/
|
||||
@Test
|
||||
@@ -203,14 +203,14 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
String defaultString = mContext.getString(R.string.media_output_summary_unavailable);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||
}
|
||||
|
||||
/**
|
||||
* One A2DP Bluetooth device is available and active.
|
||||
* Preference should be enabled
|
||||
* Preference should be visible
|
||||
* Preference summary should be activate device name
|
||||
*/
|
||||
@Test
|
||||
@@ -221,13 +221,13 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(mBluetoothDevice.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Test
|
||||
@@ -247,13 +247,13 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(secondBluetoothDevice.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"
|
||||
*/
|
||||
@Test
|
||||
@@ -266,7 +266,7 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
/**
|
||||
* 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"
|
||||
*/
|
||||
@Test
|
||||
@@ -285,7 +285,7 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
String defaultString = mContext.getString(R.string.media_output_default_summary);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(defaultString);
|
||||
}
|
||||
|
Reference in New Issue
Block a user