Loading core/java/android/widget/AbsSeekBar.java +2 −1 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ public abstract class AbsSeekBar extends ProgressBar { @Override void onProgressRefresh(float scale, boolean fromUser) { super.onProgressRefresh(scale, fromUser); Drawable thumb = mThumb; if (thumb != null) { setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE); Loading core/java/android/widget/ProgressBar.java +52 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.widget; import com.android.internal.R; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; Loading @@ -41,6 +43,8 @@ import android.view.Gravity; import android.view.RemotableViewMethod; import android.view.View; import android.view.ViewDebug; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationUtils; Loading @@ -49,8 +53,6 @@ import android.view.animation.LinearInterpolator; import android.view.animation.Transformation; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; /** * <p> Loading Loading @@ -125,6 +127,7 @@ import com.android.internal.R; public class ProgressBar extends View { private static final int MAX_LEVEL = 10000; private static final int ANIMATION_RESOLUTION = 200; private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200; int mMinWidth; int mMaxWidth; Loading Loading @@ -156,6 +159,8 @@ public class ProgressBar extends View { private int mAnimationResolution; private AccessibilityEventSender mAccessibilityEventSender; /** * Create a new progress bar with range 0...100 and initial progress of 0. * @param context the application environment Loading Loading @@ -544,6 +549,9 @@ public class ProgressBar extends View { } void onProgressRefresh(float scale, boolean fromUser) { if (AccessibilityManager.getInstance(mContext).isEnabled()) { scheduleAccessibilityEventSender(); } } private synchronized void refreshProgress(int id, int progress, boolean fromUser) { Loading Loading @@ -1007,8 +1015,48 @@ public class ProgressBar extends View { if (mIndeterminate) { stopAnimation(); } if(mRefreshProgressRunnable != null) { removeCallbacks(mRefreshProgressRunnable); } 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(); } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (!super.dispatchPopulateAccessibilityEvent(event)) { event.setItemCount(mMax); event.setCurrentItemIndex(mProgress); } return true; } /** * 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); } /** * Command for sending an accessibility event. */ private class AccessibilityEventSender implements Runnable { public void run() { sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); } } } Loading
core/java/android/widget/AbsSeekBar.java +2 −1 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ public abstract class AbsSeekBar extends ProgressBar { @Override void onProgressRefresh(float scale, boolean fromUser) { super.onProgressRefresh(scale, fromUser); Drawable thumb = mThumb; if (thumb != null) { setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE); Loading
core/java/android/widget/ProgressBar.java +52 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.widget; import com.android.internal.R; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; Loading @@ -41,6 +43,8 @@ import android.view.Gravity; import android.view.RemotableViewMethod; import android.view.View; import android.view.ViewDebug; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationUtils; Loading @@ -49,8 +53,6 @@ import android.view.animation.LinearInterpolator; import android.view.animation.Transformation; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; /** * <p> Loading Loading @@ -125,6 +127,7 @@ import com.android.internal.R; public class ProgressBar extends View { private static final int MAX_LEVEL = 10000; private static final int ANIMATION_RESOLUTION = 200; private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200; int mMinWidth; int mMaxWidth; Loading Loading @@ -156,6 +159,8 @@ public class ProgressBar extends View { private int mAnimationResolution; private AccessibilityEventSender mAccessibilityEventSender; /** * Create a new progress bar with range 0...100 and initial progress of 0. * @param context the application environment Loading Loading @@ -544,6 +549,9 @@ public class ProgressBar extends View { } void onProgressRefresh(float scale, boolean fromUser) { if (AccessibilityManager.getInstance(mContext).isEnabled()) { scheduleAccessibilityEventSender(); } } private synchronized void refreshProgress(int id, int progress, boolean fromUser) { Loading Loading @@ -1007,8 +1015,48 @@ public class ProgressBar extends View { if (mIndeterminate) { stopAnimation(); } if(mRefreshProgressRunnable != null) { removeCallbacks(mRefreshProgressRunnable); } 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(); } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (!super.dispatchPopulateAccessibilityEvent(event)) { event.setItemCount(mMax); event.setCurrentItemIndex(mProgress); } return true; } /** * 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); } /** * Command for sending an accessibility event. */ private class AccessibilityEventSender implements Runnable { public void run() { sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); } } }