Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6308e3fb authored by Michael Mikhail's avatar Michael Mikhail
Browse files

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
parent 499f965c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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());
            }
        }
+5 −0
Original line number Diff line number Diff line
@@ -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);