diff options
| author | Gilles Debunne <debunne@google.com> | 2011-06-13 12:52:48 -0700 |
|---|---|---|
| committer | Gilles Debunne <debunne@google.com> | 2011-06-13 16:16:28 -0700 |
| commit | c2ab0d665c9d1c332fbd726abf582a27cf7a6701 (patch) | |
| tree | c294ed20f5766a4e97fa6cbf2cd10f80f8a32e93 /core/java/android/widget/Switch.java | |
| parent | 0fe7b26aa2f87d5ba5611b6368cf7ec34cded108 (diff) | |
Switch is not affected by touch when disabled
Also unchanged at the end of a drag/fling if the switch has been
disabled in the mean time.
Change-Id: Ie471a7fcf57fa633ee8eeefdfaa2939883ccfef0
Diffstat (limited to 'core/java/android/widget/Switch.java')
| -rw-r--r-- | core/java/android/widget/Switch.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index 5c6a26f3fb10..b7565f3129d5 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -387,7 +387,7 @@ public class Switch extends CompoundButton { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); - if (hitThumb(x, y)) { + if (isEnabled() && hitThumb(x, y)) { mTouchMode = TOUCH_MODE_DOWN; mTouchX = x; mTouchY = y; @@ -460,7 +460,8 @@ public class Switch extends CompoundButton { */ private void stopDrag(MotionEvent ev) { mTouchMode = TOUCH_MODE_IDLE; - boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP; + // Up and not canceled, also checks the switch has not been disabled during the drag + boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled(); cancelSuperTouch(ev); |
