From 63bce03cc69be4a45230aa8bbd89dbde60681067 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Sat, 23 Jul 2011 19:52:17 -0700 Subject: Switch state text not added to accessibility events. 1. Adding the text to the events now. bug:5071053 Change-Id: If36afb1f5327720fc002b8c49e5d7b00c5f189f7 --- core/java/android/widget/Switch.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index b7565f3..0c80a11 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -34,6 +34,7 @@ import android.view.Gravity; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.ViewConfiguration; +import android.view.accessibility.AccessibilityEvent; import com.android.internal.R; @@ -360,6 +361,13 @@ public class Switch extends CompoundButton { } } + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + super.onPopulateAccessibilityEvent(event); + Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; + event.getText().add(switchText.getText()); + } + private Layout makeLayout(CharSequence text) { return new StaticLayout(text, mTextPaint, (int) Math.ceil(Layout.getDesiredWidth(text, mTextPaint)), -- cgit v1.1