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:
@@ -26,6 +26,7 @@ import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -54,6 +55,7 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
|
||||
if (mVibrator != null && !mVibrator.hasVibrator()) {
|
||||
mVibrator = null;
|
||||
}
|
||||
mVolumePreferenceListener = this::updateContentDescription;
|
||||
}
|
||||
|
||||
protected void updateEffectsSuppressor() {
|
||||
@@ -123,6 +125,7 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
|
||||
}
|
||||
mRingerMode = ringerMode;
|
||||
selectPreferenceIconState();
|
||||
updateContentDescription();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,10 +134,11 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
|
||||
*/
|
||||
protected void selectPreferenceIconState() {
|
||||
if (mPreference != null) {
|
||||
if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
|
||||
int ringerMode = getEffectiveRingerMode();
|
||||
if (ringerMode == AudioManager.RINGER_MODE_NORMAL) {
|
||||
mPreference.showIcon(mNormalIconId);
|
||||
} else {
|
||||
if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE && mVibrator != null) {
|
||||
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
mMuteIcon = mVibrateIconId;
|
||||
} else {
|
||||
mMuteIcon = mSilentIconId;
|
||||
@@ -144,6 +148,28 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
|
||||
}
|
||||
}
|
||||
|
||||
protected int getEffectiveRingerMode() {
|
||||
if (mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
return AudioManager.RINGER_MODE_SILENT;
|
||||
}
|
||||
return mRingerMode;
|
||||
}
|
||||
|
||||
protected void updateContentDescription() {
|
||||
if (mPreference != null) {
|
||||
int ringerMode = getEffectiveRingerMode();
|
||||
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||
mPreference.updateContentDescription(
|
||||
mContext.getString(R.string.ringer_content_description_vibrate_mode));
|
||||
} else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
|
||||
mPreference.updateContentDescription(
|
||||
mContext.getString(R.string.ringer_content_description_silent_mode));
|
||||
} else {
|
||||
mPreference.updateContentDescription(mPreference.getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean hintsMatch(int hints);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user