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:
@@ -26,6 +26,7 @@ import android.os.Handler;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.lifecycle.OnLifecycleEvent;
|
import androidx.lifecycle.OnLifecycleEvent;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
@@ -138,14 +139,19 @@ public class NotificationVolumePreferenceController extends
|
|||||||
if (mPreference != null) {
|
if (mPreference != null) {
|
||||||
int ringerMode = getEffectiveRingerMode();
|
int ringerMode = getEffectiveRingerMode();
|
||||||
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||||
|
mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
|
||||||
mPreference.updateContentDescription(
|
mPreference.updateContentDescription(
|
||||||
mContext.getString(
|
mContext.getString(
|
||||||
R.string.notification_volume_content_description_vibrate_mode));
|
R.string.notification_volume_content_description_vibrate_mode));
|
||||||
} else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
|
} else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
|
||||||
|
mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
|
||||||
mPreference.updateContentDescription(
|
mPreference.updateContentDescription(
|
||||||
mContext.getString(R.string.volume_content_description_silent_mode,
|
mContext.getString(R.string.volume_content_description_silent_mode,
|
||||||
mPreference.getTitle()));
|
mPreference.getTitle()));
|
||||||
} else {
|
} 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());
|
mPreference.updateContentDescription(mPreference.getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -242,6 +242,11 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
|||||||
mTitle.setContentDescription(contentDescription);
|
mTitle.setContentDescription(contentDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setAccessibilityLiveRegion(int mode) {
|
||||||
|
if (mTitle == null) return;
|
||||||
|
mTitle.setAccessibilityLiveRegion(mode);
|
||||||
|
}
|
||||||
|
|
||||||
public interface Callback {
|
public interface Callback {
|
||||||
void onSampleStarting(SeekBarVolumizer sbv);
|
void onSampleStarting(SeekBarVolumizer sbv);
|
||||||
void onStreamValueChanged(int stream, int progress);
|
void onStreamValueChanged(int stream, int progress);
|
||||||
|
Reference in New Issue
Block a user