Make sure setting switch bar state is announced.
When the switch is clicked, a TYPE_VIEW_CLICKED a11y event is produced. It works fine if the switch bar is clicked, but if the switch itself is clicked the event comes from the switch, which is marked as not important for accessibility. Re-dispatching events from the switch as coming from the switch bar makes sure that the event comes from a view that accessibility services can see. Bug: 30484493 Change-Id: Ie48cc78594c64b1cc5735475e1cb5959fadaaf4a
This commit is contained in:
@@ -341,6 +341,14 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
return Switch.class.getName();
|
return Switch.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
|
||||||
|
// Since the children are marked as not important for accessibility, re-dispatch all
|
||||||
|
// of their events as if they came from this view
|
||||||
|
event.setSource(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
||||||
|
Reference in New Issue
Block a user