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

Commit b58f164f authored by Presubmit Automerger Backend's avatar Presubmit Automerger Backend
Browse files

[automerge] DO NOT MERGE: Downbranch merge conflict [Output Switcher] Refine...

[automerge] DO NOT MERGE: Downbranch merge conflict [Output Switcher] Refine seekbar control 2p: 11a776a9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17686878

Bug: 228606252
Change-Id: I824a7104f69649b08723c2c4c0c72a0d231a86ca
parents 19a22843 11a776a9
Loading
Loading
Loading
Loading
+10 −21
Original line number Diff line number Diff line
@@ -26,8 +26,7 @@ import android.widget.SeekBar;
 * otherwise performs click.
 */
public class MediaOutputSeekbar extends SeekBar {
    private static final int DRAGGING_THRESHOLD = 20;
    private boolean mIsDragging = false;
    private int mLastDownPosition = -1;

    public MediaOutputSeekbar(Context context) {
        super(context);
@@ -39,27 +38,17 @@ public class MediaOutputSeekbar extends SeekBar {

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int width = getWidth()
                - getPaddingLeft()
                - getPaddingRight();
        int thumbPos = getPaddingLeft()
                + width
                * getProgress()
                / getMax();
        if (event.getAction() == MotionEvent.ACTION_DOWN
                && Math.abs(event.getX() - thumbPos) < DRAGGING_THRESHOLD) {
            mIsDragging = true;
            super.onTouchEvent(event);
        } else if (event.getAction() == MotionEvent.ACTION_MOVE && mIsDragging) {
            super.onTouchEvent(event);
        } else if (event.getAction() == MotionEvent.ACTION_UP && mIsDragging) {
            mIsDragging = false;
            super.onTouchEvent(event);
        } else if (event.getAction() == MotionEvent.ACTION_UP && !mIsDragging) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            mLastDownPosition = Math.round(event.getX());
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            if (mLastDownPosition == event.getX()) {
                performClick();
        }
                return true;
            }
            mLastDownPosition = -1;
        }
        return super.onTouchEvent(event);
    }

    @Override
    public boolean performClick() {