Add ripple to switches, radio buttons, check boxes, seek bars

BUG: 14231772
Change-Id: Ie40eac9f68815294460175965a999dd75f4144b5
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 3d23e4d..d013e7b 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -773,8 +773,6 @@
 
     @Override
     protected void onDraw(Canvas canvas) {
-        super.onDraw(canvas);
-
         final Rect tempRect = mTempRect;
         final Drawable trackDrawable = mTrackDrawable;
         final Drawable thumbDrawable = mThumbDrawable;
@@ -785,16 +783,12 @@
         final int switchRight = mSwitchRight;
         final int switchBottom = mSwitchBottom;
         trackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom);
-        trackDrawable.draw(canvas);
-
-        final int saveCount = canvas.save();
-
         trackDrawable.getPadding(tempRect);
+
         final int switchInnerLeft = switchLeft + tempRect.left;
         final int switchInnerTop = switchTop + tempRect.top;
         final int switchInnerRight = switchRight - tempRect.right;
         final int switchInnerBottom = switchBottom - tempRect.bottom;
-        canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom);
 
         // Relies on mTempRect, MUST be called first!
         final int thumbPos = getThumbOffset();
@@ -803,6 +797,18 @@
         int thumbLeft = switchInnerLeft - tempRect.left + thumbPos;
         int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + tempRect.right;
         thumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
+
+        final Drawable background = getBackground();
+        if (background.supportsHotspots()) {
+            background.setHotspotBounds(thumbLeft, switchTop, thumbRight, switchBottom);
+        }
+
+        super.onDraw(canvas);
+
+        trackDrawable.draw(canvas);
+
+        final int saveCount = canvas.save();
+        canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom);
         thumbDrawable.draw(canvas);
 
         final int drawableState[] = getDrawableState();