Trigger talkback for notification volume change

Triggers talkback to say the content description of the title of
notification volume when notification volume is set to vibrate or silent
mode.

Fixes: 285453719
Fixes: 285455826
Test: manually checked when the ring volume is set to 0% and when the
notification volume is set to 0%. Check the video in the bug link.

Change-Id: I4bd65bdbfa41793fc8e32c295185363ca36cc0d7
This commit is contained in:
Michael Mikhail
2023-06-26 20:16:30 +00:00
parent 499f965c1c
commit 6308e3fb2a
2 changed files with 11 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.service.notification.NotificationListenerService;
import android.view.View;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.PreferenceScreen;
@@ -138,14 +139,19 @@ public class NotificationVolumePreferenceController extends
if (mPreference != null) {
int ringerMode = getEffectiveRingerMode();
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
mPreference.updateContentDescription(
mContext.getString(
R.string.notification_volume_content_description_vibrate_mode));
} else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
mPreference.updateContentDescription(
mContext.getString(R.string.volume_content_description_silent_mode,
mPreference.getTitle()));
} else {
// Set a11y mode to none in order not to trigger talkback while changing
// notification volume in normal mode.
mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE);
mPreference.updateContentDescription(mPreference.getTitle());
}
}

View File

@@ -242,6 +242,11 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
mTitle.setContentDescription(contentDescription);
}
protected void setAccessibilityLiveRegion(int mode) {
if (mTitle == null) return;
mTitle.setAccessibilityLiveRegion(mode);
}
public interface Callback {
void onSampleStarting(SeekBarVolumizer sbv);
void onStreamValueChanged(int stream, int progress);