diff options
author | Alan Viverette <alanv@google.com> | 2014-06-18 18:05:15 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-06-18 18:05:15 -0700 |
commit | 8de1494557cf1d00c1c3fce439138a28de7fbd61 (patch) | |
tree | 32da38b42bddb9e47060e1fefed6430e528ffee3 | |
parent | e48df005750549b5531a916368f168189e370acc (diff) | |
download | frameworks_base-8de1494557cf1d00c1c3fce439138a28de7fbd61.zip frameworks_base-8de1494557cf1d00c1c3fce439138a28de7fbd61.tar.gz frameworks_base-8de1494557cf1d00c1c3fce439138a28de7fbd61.tar.bz2 |
Fix switch & slider anim, make View drawable hotspot API public
BUG: 15287810
Change-Id: Ic7a9549dc1ba8afd07e9a196371ed349a54aaf2f
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/view/View.java | 34 | ||||
-rw-r--r-- | core/java/android/widget/AbsSeekBar.java | 35 | ||||
-rw-r--r-- | core/java/android/widget/CheckedTextView.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/CompoundButton.java | 6 | ||||
-rw-r--r-- | core/java/android/widget/FrameLayout.java | 6 | ||||
-rw-r--r-- | core/java/android/widget/ImageView.java | 6 | ||||
-rw-r--r-- | core/java/android/widget/ProgressBar.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/QuickContactBadge.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/Switch.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 5 | ||||
-rw-r--r-- | graphics/java/android/graphics/drawable/DrawableContainer.java | 16 |
12 files changed, 48 insertions, 81 deletions
diff --git a/api/current.txt b/api/current.txt index 931ab3b..a02cd5e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -32562,6 +32562,7 @@ package android.view { method public void dispatchWindowSystemUiVisiblityChanged(int); method public void dispatchWindowVisibilityChanged(int); method public void draw(android.graphics.Canvas); + method public void drawableHotspotChanged(float, float); method protected void drawableStateChanged(); method public android.view.View findFocus(); method public final android.view.View findViewById(int); 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.Rect; 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 @@ public class View implements Drawable.Callback, KeyEvent.Callback, 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 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private void setPressed(boolean pressed, float x, float y) { if (pressed) { - setDrawableHotspot(x, y); + drawableHotspotChanged(x, y); } setPressed(pressed); @@ -9149,7 +9135,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, 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 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** + * 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.Canvas; 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 @@ public abstract class AbsSeekBar extends ProgressBar { @Override public void jumpDrawablesToCurrentState() { super.jumpDrawablesToCurrentState(); - if (mThumb != null) mThumb.jumpToCurrentState(); + + if (mThumb != null) { + mThumb.jumpToCurrentState(); + } } @Override @@ -361,29 +363,12 @@ public abstract class AbsSeekBar extends ProgressBar { } } - /** @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 @@ public abstract class AbsSeekBar extends ProgressBar { 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 @@ public abstract class AbsSeekBar extends ProgressBar { @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 @@ public class CheckedTextView extends TextView implements Checkable { } } - /** @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.Context; 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 @@ public abstract class CompoundButton extends Button implements Checkable { } } - /** @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.Canvas; 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 @@ public class FrameLayout extends ViewGroup { } } - /** @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.PorterDuffColorFilter; 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 @@ public class ImageView extends View { } } - /** @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 @@ public class ProgressBar extends View { } } - /** @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 @@ public class QuickContactBadge extends ImageView implements OnClickListener { } } - /** @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 @@ public class Switch extends CompoundButton { 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 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } - /** @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) { diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 8be6eb7..38b8aaf 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -65,8 +65,6 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { private long mExitAnimationEnd; private Drawable mLastDrawable; - private Insets mInsets = Insets.NONE; - // overrides from Drawable @Override @@ -118,7 +116,10 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { */ @Override public Insets getOpticalInsets() { - return mInsets; + if (mCurrDrawable != null) { + return mCurrDrawable.getOpticalInsets(); + } + return Insets.NONE; } @Override @@ -203,9 +204,6 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } if (mCurrDrawable != null) { mCurrDrawable.setBounds(bounds); - - // Must obtain optical insets after setting bounds. - mInsets = mCurrDrawable.getOpticalInsets(); } } @@ -422,15 +420,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { d.setBounds(getBounds()); d.setLayoutDirection(getLayoutDirection()); d.setAutoMirrored(mDrawableContainerState.mAutoMirrored); - - // Must obtain optical insets after setting bounds. - mInsets = d.getOpticalInsets(); - } else { - mInsets = Insets.NONE; } } else { mCurrDrawable = null; - mInsets = Insets.NONE; mCurIndex = -1; } |