Fix switch & slider anim, make View drawable hotspot API public
BUG: 15287810
Change-Id: Ic7a9549dc1ba8afd07e9a196371ed349a54aaf2f
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 9156216..89c2f37 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -45,7 +45,6 @@
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Shader;
-import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManagerGlobal;
@@ -4822,20 +4821,7 @@
final float x = r.exactCenterX();
final float y = r.exactCenterY();
- setDrawableHotspot(x, y);
- }
-
- /**
- * Sets the hotspot position for this View's drawables.
- *
- * @param x hotspot x coordinate
- * @param y hotspot y coordinate
- * @hide
- */
- protected void setDrawableHotspot(float x, float y) {
- if (mBackground != null) {
- mBackground.setHotspot(x, y);
- }
+ drawableHotspotChanged(x, y);
}
/**
@@ -6798,7 +6784,7 @@
*/
private void setPressed(boolean pressed, float x, float y) {
if (pressed) {
- setDrawableHotspot(x, y);
+ drawableHotspotChanged(x, y);
}
setPressed(pressed);
@@ -9149,7 +9135,7 @@
break;
case MotionEvent.ACTION_MOVE:
- setDrawableHotspot(x, y);
+ drawableHotspotChanged(x, y);
// Be lenient about moving outside of buttons
if (!pointInView(x, y, mTouchSlop)) {
@@ -15531,6 +15517,20 @@
}
/**
+ * This function is called whenever the drawable hotspot changes.
+ * <p>
+ * Be sure to call through to the superclass when overriding this function.
+ *
+ * @param x hotspot x coordinate
+ * @param y hotspot y coordinate
+ */
+ public void drawableHotspotChanged(float x, float y) {
+ if (mBackground != null) {
+ mBackground.setHotspot(x, y);
+ }
+ }
+
+ /**
* Call this to force a view to update its drawable state. This will cause
* drawableStateChanged to be called on this view. Views that are interested
* in the new state should call getDrawableState.
diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java
index eb3f882..fbb131c 100644
--- a/core/java/android/widget/AbsSeekBar.java
+++ b/core/java/android/widget/AbsSeekBar.java
@@ -24,7 +24,6 @@
import android.graphics.Insets;
import android.graphics.PorterDuff;
import android.graphics.Rect;
-import android.graphics.PorterDuff.Mode;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -343,7 +342,10 @@
@Override
public void jumpDrawablesToCurrentState() {
super.jumpDrawablesToCurrentState();
- if (mThumb != null) mThumb.jumpToCurrentState();
+
+ if (mThumb != null) {
+ mThumb.jumpToCurrentState();
+ }
}
@Override
@@ -361,29 +363,12 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
- final Drawable progressDrawable = getProgressDrawable();
- if (progressDrawable != null) {
- progressDrawable.setHotspot(x, y);
- }
-
- final Drawable thumb = mThumb;
- if (thumb != null) {
- thumb.setHotspot(x, y);
- }
- }
-
- @Override
- public void invalidateDrawable(Drawable dr) {
- super.invalidateDrawable(dr);
-
- if (dr == mThumb) {
- // Handle changes to thumb width and height.
- requestLayout();
+ if (mThumb != null) {
+ mThumb.setHotspot(x, y);
}
}
@@ -479,7 +464,7 @@
final Drawable background = getBackground();
if (background != null) {
- final Rect bounds = mThumb.getBounds();
+ final Rect bounds = thumb.getBounds();
final int offsetX = mPaddingLeft - mThumbOffset;
final int offsetY = mPaddingTop;
background.setHotspotBounds(left + offsetX, bounds.top + offsetY,
@@ -505,8 +490,8 @@
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
-
drawThumb(canvas);
+
}
@Override
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java
index 7113793..4aa2300 100644
--- a/core/java/android/widget/CheckedTextView.java
+++ b/core/java/android/widget/CheckedTextView.java
@@ -307,10 +307,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mCheckMarkDrawable != null) {
mCheckMarkDrawable.setHotspot(x, y);
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 747d2b1..9ba0fe1 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -24,7 +24,6 @@
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
-import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
@@ -431,10 +430,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mButtonDrawable != null) {
mButtonDrawable.setHotspot(x, y);
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index 5a14929..34f333e 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -26,7 +26,6 @@
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Region;
-import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -223,10 +222,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mForeground != null) {
mForeground.setHotspot(x, y);
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 399e087..5d578ca 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -32,7 +32,6 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Xfermode;
-import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -1109,10 +1108,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mDrawable != null) {
mDrawable.setHotspot(x, y);
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 62a8bec..394b255 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -1623,10 +1623,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mProgressDrawable != null) {
mProgressDrawable.setHotspot(x, y);
diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java
index 14d782d..23fa402 100644
--- a/core/java/android/widget/QuickContactBadge.java
+++ b/core/java/android/widget/QuickContactBadge.java
@@ -112,10 +112,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mOverlay != null) {
mOverlay.setHotspot(x, y);
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 03193a2..cca29cf 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -962,10 +962,9 @@
invalidate();
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
if (mThumbDrawable != null) {
mThumbDrawable.setHotspot(x, y);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 0f51e8b..d470586 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3503,10 +3503,9 @@
}
}
- /** @hide */
@Override
- protected void setDrawableHotspot(float x, float y) {
- super.setDrawableHotspot(x, y);
+ public void drawableHotspotChanged(float x, float y) {
+ super.drawableHotspotChanged(x, y);
final Drawables dr = mDrawables;
if (dr != null) {