Add content description to volume title in settings.
Adds content description that is announced by talkback when a11y focus is on volume preference. This improves talkback announcement when view changes. Fixes: 285529113 Bug: 285455826 Fixes: 285487766 Test: atest VolumeSeekBarPreferenceControllerTest Test: atest VolumeSeekBarPreferenceTest Change-Id: Ibe80b4b1d489dc058df1cc79c96b034d5ddc6e56
This commit is contained in:
@@ -75,6 +75,7 @@ public class NotificationVolumePreferenceController extends
|
||||
|
||||
updateEffectsSuppressor();
|
||||
selectPreferenceIconState();
|
||||
updateContentDescription();
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
@@ -120,23 +121,32 @@ public class NotificationVolumePreferenceController extends
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectPreferenceIconState() {
|
||||
protected int getEffectiveRingerMode() {
|
||||
if (mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
return AudioManager.RINGER_MODE_SILENT;
|
||||
} else if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
|
||||
if (mHelper.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
|
||||
// Ring is in normal, but notification is in silent.
|
||||
return AudioManager.RINGER_MODE_SILENT;
|
||||
}
|
||||
}
|
||||
return mRingerMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateContentDescription() {
|
||||
if (mPreference != null) {
|
||||
if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
mMuteIcon = mVibrateIconId;
|
||||
mPreference.showIcon(mVibrateIconId);
|
||||
} else if (mRingerMode == AudioManager.RINGER_MODE_SILENT
|
||||
|| mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
mMuteIcon = mSilentIconId;
|
||||
mPreference.showIcon(mSilentIconId);
|
||||
} else { // ringmode normal: could be that we are still silent
|
||||
if (mHelper.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
|
||||
// ring is in normal, but notification is in silent
|
||||
mMuteIcon = mSilentIconId;
|
||||
mPreference.showIcon(mSilentIconId);
|
||||
} else {
|
||||
mPreference.showIcon(mNormalIconId);
|
||||
}
|
||||
int ringerMode = getEffectiveRingerMode();
|
||||
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
mPreference.updateContentDescription(
|
||||
mContext.getString(
|
||||
R.string.notification_volume_content_description_vibrate_mode));
|
||||
} else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
|
||||
mPreference.updateContentDescription(
|
||||
mContext.getString(R.string.volume_content_description_silent_mode,
|
||||
mPreference.getTitle()));
|
||||
} else {
|
||||
mPreference.updateContentDescription(mPreference.getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,6 +179,7 @@ public class NotificationVolumePreferenceController extends
|
||||
break;
|
||||
case NOTIFICATION_VOLUME_CHANGED:
|
||||
selectPreferenceIconState();
|
||||
updateContentDescription();
|
||||
updateEnabledState();
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user