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

Commit 1c3dcdbb authored by Angela Wang's avatar Angela Wang
Browse files

Make AmbientVolumeSlider compatible with a11y services

1. Prevent accessibility services focus on no-action view
2. Enable setting the content description on the slider

Flag: EXEMPT bugfix
Bug: 397355964
Bug: 397355156
Bug: 397354989
Bug: 397134669
Test: manually test with Voice Access/Switch Access/TalkBack
Change-Id: If0c40d7b91061da5e100e49e71279adb6f69e77f
parent baf689c1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1018,6 +1018,12 @@
    <string name="hearing_devices_ambient_control_left">Left</string>
    <!-- QuickSettings: The text to show the control is for right side device. [CHAR LIMIT=30] -->
    <string name="hearing_devices_ambient_control_right">Right</string>
    <!-- QuickSettings: Content description for unified ambient control slider. [CHAR LIMIT=NONE] -->
    <string name="hearing_devices_ambient_control_description">Surroundings</string>
    <!-- QuickSettings: Content description for left ambient control slider. [CHAR LIMIT=NONE] -->
    <string name="hearing_devices_ambient_control_left_description">Left surroundings</string>
    <!-- QuickSettings: Content description for left ambient control slider. [CHAR LIMIT=NONE] -->
    <string name="hearing_devices_ambient_control_right_description">Right surroundings</string>
    <!-- QuickSettings: Content description for a button, that expands ambient volume sliders [CHAR_LIMIT=NONE] -->
    <string name="hearing_devices_ambient_expand_controls">Expand to left and right separated controls</string>
    <!-- QuickSettings: Content description for a button, that collapses ambient volume sliders [CHAR LIMIT=NONE] -->
+11 −0
Original line number Diff line number Diff line
@@ -327,8 +327,19 @@ public class AmbientVolumeLayout extends LinearLayout implements AmbientVolumeUi
        slider.addOnChangeListener(mSliderOnChangeListener);
        if (side == SIDE_LEFT) {
            slider.setTitle(mContext.getString(R.string.hearing_devices_ambient_control_left));
            slider.setContentDescription(
                    mContext.getString(R.string.hearing_devices_ambient_control_left));
            slider.setSliderContentDescription(
                    mContext.getString(R.string.hearing_devices_ambient_control_left_description));
        } else if (side == SIDE_RIGHT) {
            slider.setTitle(mContext.getString(R.string.hearing_devices_ambient_control_right));
            slider.setContentDescription(
                    mContext.getString(R.string.hearing_devices_ambient_control_right));
            slider.setSliderContentDescription(
                    mContext.getString(R.string.hearing_devices_ambient_control_right_description));
        } else {
            slider.setSliderContentDescription(
                    mContext.getString(R.string.hearing_devices_ambient_control_description));
        }
        mSideToSliderMap.put(side, slider);
    }
+12 −0
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ public class AmbientVolumeSlider extends LinearLayout {
        mSlider = requireViewById(R.id.ambient_volume_slider);
        mSlider.addOnSliderTouchListener(mSliderTouchListener);
        mSlider.addOnChangeListener(mSliderChangeListener);

        setFocusable(false);
        setClickable(false);
        mSlider.setFocusable(false);
        mSlider.setClickable(false);
    }

    /**
@@ -178,6 +183,13 @@ public class AmbientVolumeSlider extends LinearLayout {
        return (int) Math.ceil((value - min) / levelGap);
    }

    /** Sets the content description to the ambient volume slider. */
    public void setSliderContentDescription(CharSequence contentDescription) {
        if (mSlider != null) {
            mSlider.setContentDescription(contentDescription);
        }
    }

    /** Interface definition for a callback invoked when a slider's value is changed. */
    public interface OnChangeListener {
        /** Called when the finger is take off from the slider. */