diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-29 10:44:59 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-29 10:45:05 -0700 |
commit | 7650259a597dd24137420d32acc35efc44db381e (patch) | |
tree | ab184cb159301040987fea4abbc63fc0dae313e9 /core/java/android/widget/Switch.java | |
parent | a31f5e63743f3fc788acbd85474ec80eaf5c8b4d (diff) | |
download | frameworks_base-7650259a597dd24137420d32acc35efc44db381e.zip frameworks_base-7650259a597dd24137420d32acc35efc44db381e.tar.gz frameworks_base-7650259a597dd24137420d32acc35efc44db381e.tar.bz2 |
Improving accessibility feedback for two state widgets.
1. Added population of sensible text for the state of the
two state controls such as CheckBox, Switch, etc. This
is important since if they are in a layout manager which
fires an accessibility event there should be a description
of the widget.
bug:5092552
Change-Id: Ie3ca955653563496b84db379ae23a23fe88089a8
Diffstat (limited to 'core/java/android/widget/Switch.java')
-rw-r--r-- | core/java/android/widget/Switch.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index 0c80a11..57f73ac 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -364,8 +364,19 @@ public class Switch extends CompoundButton { @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); - Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; - event.getText().add(switchText.getText()); + if (isChecked()) { + CharSequence text = mOnLayout.getText(); + if (TextUtils.isEmpty(text)) { + text = mContext.getString(R.string.switch_on); + } + event.getText().add(text); + } else { + CharSequence text = mOffLayout.getText(); + if (TextUtils.isEmpty(text)) { + text = mContext.getString(R.string.switch_off); + } + event.getText().add(text); + } } private Layout makeLayout(CharSequence text) { |