Fixed Sound Settings summary text

The summary for Sound settings was not
descriptive enough when the volume was set
to 0% so additional strings were added. Now
it will change let you know the status
of the ringer and vibration settings when
at 0% volume. Espresso tests added to test
that text is properly updated in each of
these states.

Test: make SettingsTests
Bug: 31099179
Change-Id: Id49e2d0c4b7ac0f17efcdaf31de48d5eb678ca46
This commit is contained in:
Salvador Martinez
2016-08-31 14:17:35 -07:00
parent 1721e4510f
commit b706d4e956
4 changed files with 111 additions and 6 deletions

View File

@@ -594,10 +594,21 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
@Override
public void onReceive(Context context, Intent intent) {
String percent = NumberFormat.getPercentInstance().format(
(double) mAudioManager.getStreamVolume(AudioManager.STREAM_RING) / maxVolume);
mSummaryLoader.setSummary(this,
mContext.getString(R.string.sound_settings_summary, percent));
final int ringerMode = mAudioManager.getRingerMode();
int resId;
String percent = "";
if (ringerMode == mAudioManager.RINGER_MODE_SILENT) {
resId = R.string.sound_settings_summary_silent;
} else if (ringerMode == mAudioManager.RINGER_MODE_VIBRATE){
resId = R.string.sound_settings_summary_vibrate;
}
else {
percent = NumberFormat.getPercentInstance().format(
(double) mAudioManager.getStreamVolume(
AudioManager.STREAM_RING) / maxVolume);
resId = R.string.sound_settings_summary;
}
mSummaryLoader.setSummary(this, mContext.getString(resId, percent));
}
}