diff options
| author | yingleiw <yingleiw@google.com> | 2020-06-26 15:22:53 -0700 |
|---|---|---|
| committer | yingleiw <yingleiw@google.com> | 2020-07-14 17:12:07 -0700 |
| commit | e34bc33af3a7e1ca75037441fb00f0662a9f2886 (patch) | |
| tree | 19c869746b9452c2a75830a369233a5d886c11be /core/java/android/widget/CompoundButton.java | |
| parent | 17a63e29c1fe2d685f93f376f2116a4f476a4f6c (diff) | |
Delay sending accessibility events a little for temporarily detached view
In RV, a view could be temporarily detached in one draw cycle.
Accessibility events sent during this time will be lost. To prevent the
events from being lost, we will set a flag when a view is detached by
parent. And when sending accessibility events for detached view, we will
delay it a little by
ViewConfiguration.getSendRecurringAccessibilityEventsInterval. This way,
if the view is attached in one draw cycle, the events will be sent out.
Also add more setStateDescription() in CompoundButton to for safer code.
(this is not the cause of this bug though).
Fix: 151125936
Test: tested that the bug is fixed.
Change-Id: Iffca8c87bad4fa2f66862b966e351562d77d6d76
Diffstat (limited to 'core/java/android/widget/CompoundButton.java')
| -rw-r--r-- | core/java/android/widget/CompoundButton.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 5820f4bdafad..135ff9fcd989 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -183,14 +183,14 @@ public abstract class CompoundButton extends Button implements Checkable { public void setStateDescription(@Nullable CharSequence stateDescription) { mCustomStateDescription = stateDescription; if (stateDescription == null) { - setDefaultStateDescritption(); + setDefaultStateDescription(); } else { super.setStateDescription(stateDescription); } } /** @hide **/ - protected void setDefaultStateDescritption() { + protected void setDefaultStateDescription() { if (mCustomStateDescription == null) { super.setStateDescription(getButtonStateDescription()); } @@ -210,6 +210,8 @@ public abstract class CompoundButton extends Button implements Checkable { // Avoid infinite recursions if setChecked() is called from a listener if (mBroadcasting) { + // setStateDescription will not send out event if the description is unchanged. + setDefaultStateDescription(); return; } @@ -228,7 +230,7 @@ public abstract class CompoundButton extends Button implements Checkable { mBroadcasting = false; } // setStateDescription will not send out event if the description is unchanged. - setDefaultStateDescritption(); + setDefaultStateDescription(); } /** |
