Read out confirmation message upon selecting options on LabeledSeekBar.
bug: 26965949
Change-Id: I2693ac6849f5c72b2bbd4f775911ea18398746f6
diff --git a/src/com/android/settings/widget/LabeledSeekBar.java b/src/com/android/settings/widget/LabeledSeekBar.java
index 9463bf7..35a7d1b 100644
--- a/src/com/android/settings/widget/LabeledSeekBar.java
+++ b/src/com/android/settings/widget/LabeledSeekBar.java
@@ -29,6 +29,7 @@
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
import java.util.List;
@@ -148,6 +149,22 @@
public LabeledSeekBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
+ super.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ sendClickEventForAccessibility(progress);
+ }
+ });
}
@Override
@@ -164,6 +181,30 @@
}
@Override
+ public void setOnSeekBarChangeListener(final OnSeekBarChangeListener l) {
+ // Tweak the listener to send accessibility event on progress changed.
+ OnSeekBarChangeListener l2 = new OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ l.onStopTrackingTouch(seekBar);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ l.onStartTrackingTouch(seekBar);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ l.onProgressChanged(seekBar, progress, fromUser);
+ sendClickEventForAccessibility(progress);
+ }
+ };
+
+ super.setOnSeekBarChangeListener(l2);
+ }
+
+ @Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mAccessHelper = new LabeledSeekBarExploreByTouchHelper(this);
@@ -185,4 +226,11 @@
return super.dispatchHoverEvent(event);
}
+
+ private void sendClickEventForAccessibility(int progress) {
+ if (mAccessHelper != null) {
+ mAccessHelper.invalidateRoot();
+ mAccessHelper.sendEventForVirtualView(progress, AccessibilityEvent.TYPE_VIEW_CLICKED);
+ }
+ }
}