Update/cleanup Bluetooth Codec strings in Developer Settings

* Use the summary strings instead of the titles strings as appropriate.
* Use proper translatable strings instead of hard-coded "Streaming: "
  embedded string.

Test: UI visual observation
Change-Id: I0222afc30c75e68e2568c33c781755802d86c502
This commit is contained in:
Pavlin Radoslavov
2017-01-17 17:14:24 -08:00
parent ab9e269d06
commit dd39c073d6

View File

@@ -1760,49 +1760,50 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private void initBluetoothConfigurationValues() { private void initBluetoothConfigurationValues() {
String[] values; String[] values;
String[] titles; String[] summaries;
int index; int index;
// Init the Codec Type - Default // Init the Codec Type - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_values); values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_values);
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries);
index = 0; index = 0;
mBluetoothSelectA2dpCodec.setValue(values[index]); mBluetoothSelectA2dpCodec.setValue(values[index]);
mBluetoothSelectA2dpCodec.setSummary(titles[index]); mBluetoothSelectA2dpCodec.setSummary(summaries[index]);
// Init the Sample Rate - Default // Init the Sample Rate - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_values); values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_values);
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
index = 0; index = 0;
mBluetoothSelectA2dpSampleRate.setValue(values[index]); mBluetoothSelectA2dpSampleRate.setValue(values[index]);
mBluetoothSelectA2dpSampleRate.setSummary(titles[index]); mBluetoothSelectA2dpSampleRate.setSummary(summaries[index]);
// Init the Bits Per Sample - Default // Init the Bits Per Sample - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_values); values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_values);
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
index = 0; index = 0;
mBluetoothSelectA2dpBitsPerSample.setValue(values[index]); mBluetoothSelectA2dpBitsPerSample.setValue(values[index]);
mBluetoothSelectA2dpBitsPerSample.setSummary(titles[index]); mBluetoothSelectA2dpBitsPerSample.setSummary(summaries[index]);
// Init the Channel Mode - Default // Init the Channel Mode - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_values); values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_values);
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
index = 0; index = 0;
mBluetoothSelectA2dpChannelMode.setValue(values[index]); mBluetoothSelectA2dpChannelMode.setValue(values[index]);
mBluetoothSelectA2dpChannelMode.setSummary(titles[index]); mBluetoothSelectA2dpChannelMode.setSummary(summaries[index]);
// Init the LDAC Playback Quality - High // Init the LDAC Playback Quality - High
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_values); values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_values);
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
index = 0; index = 0;
mBluetoothSelectA2dpLdacPlaybackQuality.setValue(values[index]); mBluetoothSelectA2dpLdacPlaybackQuality.setValue(values[index]);
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(titles[index]); mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]);
} }
private void updateBluetoothA2dpConfigurationValues() { private void updateBluetoothA2dpConfigurationValues() {
int index; int index;
String[] titles; String[] summaries;
BluetoothCodecConfig codecConfig = null; BluetoothCodecConfig codecConfig = null;
String streaming;
synchronized (mBluetoothA2dpLock) { synchronized (mBluetoothA2dpLock) {
if (mBluetoothA2dp != null) { if (mBluetoothA2dp != null) {
@@ -1832,8 +1833,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
break; break;
} }
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries);
mBluetoothSelectA2dpCodec.setSummary("Streaming: " + titles[index]); streaming = getResources().getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpCodec.setSummary(streaming);
} }
// Update the Sample Rate // Update the Sample Rate
@@ -1858,8 +1860,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
break; break;
} }
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
mBluetoothSelectA2dpSampleRate.setSummary("Streaming: " + titles[index]); streaming = getResources().getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpSampleRate.setSummary(streaming);
} }
// Update the Bits Per Sample // Update the Bits Per Sample
@@ -1879,8 +1882,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
break; break;
} }
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
mBluetoothSelectA2dpBitsPerSample.setSummary("Streaming: " + titles[index]); streaming = getResources().getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpBitsPerSample.setSummary(streaming);
} }
// Update the Channel Mode // Update the Channel Mode
@@ -1897,34 +1901,41 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
break; break;
} }
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
mBluetoothSelectA2dpChannelMode.setSummary("Streaming: " + titles[index]); streaming = getResources().getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpChannelMode.setSummary(streaming);
} }
// Update the LDAC Playback Quality // Update the LDAC Playback Quality
index = -1; // The actual values are 0, 1, 2 - those are extracted
switch ((int)codecConfig.getCodecSpecific1()) { // as mod-10 remainders of a larger value.
case 1000: // The reason is because within BluetoothCodecConfig we cannot use
index = 0; // a codec-specific value of zero.
break; index = (int)codecConfig.getCodecSpecific1();
case 1001: if (index > 0) {
index = 1; index %= 10;
break; } else {
case 1002: index = -1;
index = 2; }
switch (index) {
case 0:
case 1:
case 2:
break; break;
default: default:
index = -1;
break; break;
} }
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary("Streaming: " + titles[index]); streaming = getResources().getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(streaming);
} }
} }
private void writeBluetoothConfigurationOption(Preference preference, private void writeBluetoothConfigurationOption(Preference preference,
Object newValue) { Object newValue) {
String[] titles; String[] summaries;
int index; int index;
int codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID; int codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID;
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
@@ -1942,8 +1953,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
codecType = newValue.toString(); codecType = newValue.toString();
index = mBluetoothSelectA2dpCodec.findIndexOfValue(newValue.toString()); index = mBluetoothSelectA2dpCodec.findIndexOfValue(newValue.toString());
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries);
mBluetoothSelectA2dpCodec.setSummary(titles[index]); mBluetoothSelectA2dpCodec.setSummary(summaries[index]);
} }
} }
index = mBluetoothSelectA2dpCodec.findIndexOfValue(codecType); index = mBluetoothSelectA2dpCodec.findIndexOfValue(codecType);
@@ -1996,8 +2007,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
sampleRate = newValue.toString(); sampleRate = newValue.toString();
index = mBluetoothSelectA2dpSampleRate.findIndexOfValue(newValue.toString()); index = mBluetoothSelectA2dpSampleRate.findIndexOfValue(newValue.toString());
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
mBluetoothSelectA2dpSampleRate.setSummary(titles[index]); mBluetoothSelectA2dpSampleRate.setSummary(summaries[index]);
} }
} }
index = mBluetoothSelectA2dpSampleRate.findIndexOfValue(sampleRate); index = mBluetoothSelectA2dpSampleRate.findIndexOfValue(sampleRate);
@@ -2027,8 +2038,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
bitsPerSample = newValue.toString(); bitsPerSample = newValue.toString();
index = mBluetoothSelectA2dpBitsPerSample.findIndexOfValue(newValue.toString()); index = mBluetoothSelectA2dpBitsPerSample.findIndexOfValue(newValue.toString());
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
mBluetoothSelectA2dpBitsPerSample.setSummary(titles[index]); mBluetoothSelectA2dpBitsPerSample.setSummary(summaries[index]);
} }
} }
index = mBluetoothSelectA2dpBitsPerSample.findIndexOfValue(bitsPerSample); index = mBluetoothSelectA2dpBitsPerSample.findIndexOfValue(bitsPerSample);
@@ -2055,8 +2066,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
channelMode = newValue.toString(); channelMode = newValue.toString();
index = mBluetoothSelectA2dpChannelMode.findIndexOfValue(newValue.toString()); index = mBluetoothSelectA2dpChannelMode.findIndexOfValue(newValue.toString());
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
mBluetoothSelectA2dpChannelMode.setSummary(titles[index]); mBluetoothSelectA2dpChannelMode.setSummary(summaries[index]);
} }
} }
index = mBluetoothSelectA2dpChannelMode.findIndexOfValue(channelMode); index = mBluetoothSelectA2dpChannelMode.findIndexOfValue(channelMode);
@@ -2080,20 +2091,16 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
ldacPlaybackQuality = newValue.toString(); ldacPlaybackQuality = newValue.toString();
index = mBluetoothSelectA2dpLdacPlaybackQuality.findIndexOfValue(newValue.toString()); index = mBluetoothSelectA2dpLdacPlaybackQuality.findIndexOfValue(newValue.toString());
if (index >= 0) { if (index >= 0) {
titles = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_titles); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(titles[index]); mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]);
} }
} }
index = mBluetoothSelectA2dpLdacPlaybackQuality.findIndexOfValue(ldacPlaybackQuality); index = mBluetoothSelectA2dpLdacPlaybackQuality.findIndexOfValue(ldacPlaybackQuality);
switch (index) { switch (index) {
case 0: case 0:
codecSpecific1Value = 1000;
break;
case 1: case 1:
codecSpecific1Value = 1001;
break;
case 2: case 2:
codecSpecific1Value = 1002; codecSpecific1Value = 1000 + index;
break; break;
default: default:
break; break;