Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df3139db authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "D-pad should be able to push seek bar to 0 or max value"

parents 666b2b75 12a44914
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -703,9 +703,9 @@ public abstract class AbsSeekBar extends ProgressBar {
                    // fallthrough
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    increment = isLayoutRtl() ? -increment : increment;
                    int progress = getProgress() + increment;
                    if (progress > 0 && progress < getMax()) {
                        setProgress(progress, true);

                    // Let progress bar handle clamping values.
                    if (setProgress(getProgress() + increment, true)) {
                        onKeyChange();
                        return true;
                    }
@@ -729,10 +729,10 @@ public abstract class AbsSeekBar extends ProgressBar {
        if (isEnabled()) {
            final int progress = getProgress();
            if (progress > 0) {
                info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
                info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
            }
            if (progress < getMax()) {
                info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
                info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
            }
        }
    }
@@ -743,29 +743,26 @@ public abstract class AbsSeekBar extends ProgressBar {
        if (super.performAccessibilityActionInternal(action, arguments)) {
            return true;
        }

        if (!isEnabled()) {
            return false;
        }
        final int progress = getProgress();
        final int increment = Math.max(1, Math.round((float) getMax() / 5));
        switch (action) {
            case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
                if (progress <= 0) {
                    return false;

        if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
                || action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
            int increment = Math.max(1, Math.round((float) getMax() / 5));
            if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
                increment = -increment;
            }
                setProgress(progress - increment, true);

            // Let progress bar handle clamping values.
            if (setProgress(getProgress() + increment, true)) {
                onKeyChange();
                return true;
            }
            case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
                if (progress >= getMax()) {
            return false;
        }
                setProgress(progress + increment, true);
                onKeyChange();
                return true;
            }
        }

        return false;
    }

+11 −11
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.graphics.drawable.shapes.Shape;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.util.Pools.SynchronizedPool;
import android.view.Gravity;
import android.view.RemotableViewMethod;
@@ -1341,23 +1342,22 @@ public class ProgressBar extends View {
    }

    @android.view.RemotableViewMethod
    synchronized void setProgress(int progress, boolean fromUser) {
    synchronized boolean setProgress(int progress, boolean fromUser) {
        if (mIndeterminate) {
            return;
            // Not applicable.
            return false;
        }

        if (progress < 0) {
            progress = 0;
        }
        progress = MathUtils.constrain(progress, 0, mMax);

        if (progress > mMax) {
            progress = mMax;
        if (progress == mProgress) {
            // No change from current.
            return false;
        }

        if (progress != mProgress) {
        mProgress = progress;
        refreshProgress(R.id.progress, mProgress, fromUser);
        }
        return true;
    }

    /**