diff options
| author | yingleiw <yingleiw@google.com> | 2019-10-21 16:04:05 -0700 |
|---|---|---|
| committer | yingleiw <yingleiw@google.com> | 2019-10-21 17:03:03 -0700 |
| commit | 3e7bf9063469b424bb867820cf8567f4ee4a9576 (patch) | |
| tree | f4c36d5a785baa3160e612c09ff0eca70f6a42b1 /core/java/android/widget/ProgressBar.java | |
| parent | 1cc77c6ebe8e1d5ef86addc61183ab04136540cf (diff) | |
remove accessibility event throttling in Progressbar
The current throttling is not good: when we update progress periodically
at an interval smaller than 200ms, no progress is announced except
for the last 100% in talkback. We will reply on the throttling when
sending out state change events after adopting the accessibility state
api: we only send out state change events when the state description
actually changes.
Bug: 143079143
Test: tested with talkback test when updating progress at different
frequencies.
Change-Id: I7480a3420130fc42645df17074b093cdced430ae
Diffstat (limited to 'core/java/android/widget/ProgressBar.java')
| -rw-r--r-- | core/java/android/widget/ProgressBar.java | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 2e9574345692..d58d858c3b8a 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -163,7 +163,6 @@ import java.util.ArrayList; public class ProgressBar extends View { private static final int MAX_LEVEL = 10000; - private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200; /** Interpolator used for smooth progress animations. */ private static final DecelerateInterpolator PROGRESS_ANIM_INTERPOLATOR = @@ -244,8 +243,6 @@ public class ProgressBar extends View { private final ArrayList<RefreshData> mRefreshData = new ArrayList<RefreshData>(); - private AccessibilityEventSender mAccessibilityEventSender; - /** * Create a new progress bar with range 0...100 and initial progress of 0. * @param context the application environment @@ -1556,7 +1553,7 @@ public class ProgressBar extends View { void onProgressRefresh(float scale, boolean fromUser, int progress) { if (AccessibilityManager.getInstance(mContext).isEnabled()) { - scheduleAccessibilityEventSender(); + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); } } @@ -2250,9 +2247,6 @@ public class ProgressBar extends View { removeCallbacks(mRefreshProgressRunnable); mRefreshIsPosted = false; } - if (mAccessibilityEventSender != null) { - removeCallbacks(mAccessibilityEventSender); - } // This should come after stopAnimation(), otherwise an invalidate message remains in the // queue, which can prevent the entire view hierarchy from being GC'ed during a rotation super.onDetachedFromWindow(); @@ -2285,22 +2279,6 @@ public class ProgressBar extends View { } } - /** - * Schedule a command for sending an accessibility event. - * </br> - * Note: A command is used to ensure that accessibility events - * are sent at most one in a given time frame to save - * system resources while the progress changes quickly. - */ - private void scheduleAccessibilityEventSender() { - if (mAccessibilityEventSender == null) { - mAccessibilityEventSender = new AccessibilityEventSender(); - } else { - removeCallbacks(mAccessibilityEventSender); - } - postDelayed(mAccessibilityEventSender, TIMEOUT_SEND_ACCESSIBILITY_EVENT); - } - /** @hide */ @Override protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { @@ -2324,15 +2302,6 @@ public class ProgressBar extends View { return isIndeterminate() && getWindowVisibility() == VISIBLE && isShown(); } - /** - * Command for sending an accessibility event. - */ - private class AccessibilityEventSender implements Runnable { - public void run() { - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); - } - } - private static class ProgressTintInfo { ColorStateList mIndeterminateTintList; BlendMode mIndeterminateBlendMode; |
