From e88a05601c1a69ca77b05eaab4cc10a0efdf1e05 Mon Sep 17 00:00:00 2001 From: Anna Galusza Date: Thu, 18 Feb 2016 13:26:29 -0800 Subject: [PATCH] Don't read state twice ("on on"/"off off") in Settings Toggle preferences. Bug: 26967006 Change-Id: I329aabc577ed8b3dc56fe86d9f7bc8f64461c2a0 --- src/com/android/settings/widget/SwitchBar.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java index bf093d41451..019103f2571 100644 --- a/src/com/android/settings/widget/SwitchBar.java +++ b/src/com/android/settings/widget/SwitchBar.java @@ -318,11 +318,15 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC requestLayout(); } + @Override + public CharSequence getAccessibilityClassName() { + return Switch.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(Switch.class.getName()); info.setText(mTextView.getText()); info.setCheckable(true); info.setChecked(mSwitch.isChecked()); @@ -332,7 +336,10 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(Switch.class.getName()); + // Don't say "on on" or "off off" - rather, speak the state only once. We need to specify + // this explicitly as each of our children (the textview and the checkbox) contribute to + // the state once, giving us duplicate text by default. + event.setContentDescription(mTextView.getText()); event.setChecked(mSwitch.isChecked()); } }