diff options
| author | 2022-04-12 05:42:21 +0000 | |
|---|---|---|
| committer | 2022-04-12 05:42:21 +0000 | |
| commit | eda5ea3e38fbb0298447ee2178786adf83ca8c7f (patch) | |
| tree | 377795e53fa6938224386e2179ec7f2cefe1f18a | |
| parent | 466dcdd65021999c3cdf47d2883f2debf36a8751 (diff) | |
| parent | 11a776a9083a81a3bf43120859ab6fc80ed9461f (diff) | |
Merge "DO NOT MERGE: Downbranch merge conflict [Output Switcher] Refine seekbar control" into tm-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputSeekbar.java | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputSeekbar.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputSeekbar.java index 0a3c5bf24b8b..72f308e4f6b1 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputSeekbar.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputSeekbar.java @@ -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,26 +38,16 @@ 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) { - performClick(); + 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 true; + return super.onTouchEvent(event); } @Override |