diff options
21 files changed, 124 insertions, 583 deletions
diff --git a/api/current.txt b/api/current.txt index 29ca03d..ebd3605 100644 --- a/api/current.txt +++ b/api/current.txt @@ -10908,7 +10908,6 @@ package android.graphics.drawable { method public void applyTheme(android.content.res.Resources.Theme); method public boolean canApplyTheme(); method public void clearColorFilter(); - method public void clearHotspots(); method public final void copyBounds(android.graphics.Rect); method public final android.graphics.Rect copyBounds(); method public static android.graphics.drawable.Drawable createFromPath(java.lang.String); @@ -10951,7 +10950,6 @@ package android.graphics.drawable { method protected void onBoundsChange(android.graphics.Rect); method protected boolean onLevelChange(int); method protected boolean onStateChange(int[]); - method public void removeHotspot(int); method public static int resolveOpacity(int, int); method public void scheduleSelf(java.lang.Runnable, long); method public abstract void setAlpha(int); @@ -10964,11 +10962,11 @@ package android.graphics.drawable { method public void setColorFilter(int, android.graphics.PorterDuff.Mode); method public void setDither(boolean); method public void setFilterBitmap(boolean); - method public void setHotspot(int, float, float); + method public void setHotspot(float, float); + method public void setHotspotBounds(int, int, int, int); method public final boolean setLevel(int); method public boolean setState(int[]); method public boolean setVisible(boolean, boolean); - method public boolean supportsHotspots(); method public void unscheduleSelf(java.lang.Runnable); } @@ -11027,30 +11025,6 @@ package android.graphics.drawable { method public final void setVariablePadding(boolean); } - public class DrawableWrapper extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { - ctor public DrawableWrapper(); - method public void draw(android.graphics.Canvas); - method public android.graphics.Rect getDirtyBounds(); - method protected final android.graphics.drawable.Drawable getDrawable(); - method public int getOpacity(); - method public final int[] getState(); - method public void invalidateDrawable(android.graphics.drawable.Drawable); - method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); - method public void setAlpha(int); - method public final void setBounds(int, int, int, int); - method public final void setBounds(android.graphics.Rect); - method public void setColorFilter(android.graphics.ColorFilter); - method protected void setConstantState(android.graphics.drawable.DrawableWrapper.WrapperState, android.content.res.Resources); - method protected final void setDrawable(android.graphics.drawable.Drawable, android.content.res.Resources); - method public final boolean setState(int[]); - method public void setXfermode(android.graphics.Xfermode); - method public void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable); - } - - public static abstract class DrawableWrapper.WrapperState extends android.graphics.drawable.Drawable.ConstantState { - method public int getChangingConfigurations(); - } - public class GradientDrawable extends android.graphics.drawable.Drawable { ctor public GradientDrawable(); ctor public GradientDrawable(android.graphics.drawable.GradientDrawable.Orientation, int[]); @@ -11174,6 +11148,13 @@ package android.graphics.drawable { method public void setPicture(android.graphics.Picture); } + public class RippleDrawable extends android.graphics.drawable.LayerDrawable { + method public android.graphics.Rect getDirtyBounds(); + method public android.content.res.ColorStateList getTint(); + method public void setTint(android.content.res.ColorStateList); + method public void setTintMode(android.graphics.PorterDuff.Mode); + } + public class RotateDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { ctor public RotateDrawable(); method public void draw(android.graphics.Canvas); @@ -11243,13 +11224,6 @@ package android.graphics.drawable { method public void addState(int[], android.graphics.drawable.Drawable); } - public class TouchFeedbackDrawable extends android.graphics.drawable.LayerDrawable { - method public android.graphics.Rect getDirtyBounds(); - method public android.content.res.ColorStateList getTint(); - method public void setTint(android.content.res.ColorStateList); - method public void setTintMode(android.graphics.PorterDuff.Mode); - } - public class TransitionDrawable extends android.graphics.drawable.LayerDrawable implements android.graphics.drawable.Drawable.Callback { ctor public TransitionDrawable(android.graphics.drawable.Drawable[]); method public boolean isCrossFadeEnabled(); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index fb7d57d..6dc7286 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4789,25 +4789,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @param v previous or the next focus holder, or null if none */ private void manageFocusHotspot(boolean focused, View v) { - if (mBackground != null && mBackground.supportsHotspots()) { - final Rect r = new Rect(); - if (!focused && v != null) { - v.getBoundsOnScreen(r); - final int[] location = new int[2]; - getLocationOnScreen(location); - r.offset(-location[0], -location[1]); - } else { - r.set(0, 0, mRight - mLeft, mBottom - mTop); - } - - final float x = r.exactCenterX(); - final float y = r.exactCenterY(); - mBackground.setHotspot(R.attr.state_focused, x, y); + if (mBackground == null) { + return; + } - if (!focused) { - mBackground.removeHotspot(R.attr.state_focused); - } + final Rect r = new Rect(); + if (!focused && v != null) { + v.getBoundsOnScreen(r); + final int[] location = new int[2]; + getLocationOnScreen(location); + r.offset(-location[0], -location[1]); + } else { + r.set(0, 0, mRight - mLeft, mBottom - mTop); } + + final float x = r.exactCenterX(); + final float y = r.exactCenterY(); + mBackground.setHotspot(x, y); } /** @@ -6763,7 +6761,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private void setPressed(boolean pressed, float x, float y) { if (pressed) { - setHotspot(R.attr.state_pressed, x, y); + setHotspot(x, y); } setPressed(pressed); @@ -6787,10 +6785,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPrivateFlags &= ~PFLAG_PRESSED; } - if (!pressed) { - clearHotspot(R.attr.state_pressed); - } - if (needsRefresh) { refreshDrawableState(); } @@ -9106,21 +9100,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback, postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout()); } else { // Not inside a scrolling container, so show the feedback right away - setHotspot(R.attr.state_pressed, x, y); + setHotspot(x, y); setPressed(true); checkForLongClick(0); } break; case MotionEvent.ACTION_CANCEL: - clearHotspot(R.attr.state_pressed); setPressed(false); removeTapCallback(); removeLongPressCallback(); break; case MotionEvent.ACTION_MOVE: - setHotspot(R.attr.state_pressed, x, y); + setHotspot(x, y); // Be lenient about moving outside of buttons if (!pointInView(x, y, mTouchSlop)) { @@ -9142,17 +9135,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } - private void setHotspot(int id, float x, float y) { - final Drawable bg = mBackground; - if (bg != null && bg.supportsHotspots()) { - bg.setHotspot(id, x, y); - } - } - - private void clearHotspot(int id) { - final Drawable bg = mBackground; - if (bg != null && bg.supportsHotspots()) { - bg.removeHotspot(id); + private void setHotspot(float x, float y) { + if (mBackground != null) { + mBackground.setHotspot(x, y); } } @@ -12903,10 +12888,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPrivateFlags &= ~PFLAG_CANCEL_NEXT_UP_EVENT; mPrivateFlags3 &= ~PFLAG3_IS_LAID_OUT; - if (mBackground != null) { - mBackground.clearHotspots(); - } - removeUnsetPressCallback(); removeLongPressCallback(); removePerformClickCallback(); diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index f91ef1a..c9eb130 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2502,22 +2502,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te positionSelector(position, sel); final Drawable selector = mSelector; - if (selector != null && selector.supportsHotspots() && position != INVALID_POSITION) { + if (selector != null && position != INVALID_POSITION) { final Rect bounds = mSelectorRect; final float x = bounds.exactCenterX(); final float y = bounds.exactCenterY(); - selector.setHotspot(R.attr.state_focused, x, y); + selector.setHotspot(x, y); } } void positionSelector(int position, View sel) { if (position != INVALID_POSITION) { - if (mSelectorPosition != position) { - final Drawable selector = mSelector; - if (selector != null && selector.supportsHotspots()) { - selector.clearHotspots(); - } - } mSelectorPosition = position; } @@ -3245,9 +3239,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te ((TransitionDrawable) d).resetTransition(); } } - if (d.supportsHotspots()) { - d.setHotspot(R.attr.state_pressed, x, y); - } + d.setHotspot(x, y); } if (longClickable) { @@ -3783,9 +3775,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te if (d != null && d instanceof TransitionDrawable) { ((TransitionDrawable) d).resetTransition(); } - if (mSelector.supportsHotspots()) { - mSelector.setHotspot(R.attr.state_pressed, x, ev.getY()); - } + mSelector.setHotspot(x, ev.getY()); } if (mTouchModeReset != null) { removeCallbacks(mTouchModeReset); @@ -3797,9 +3787,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mTouchMode = TOUCH_MODE_REST; child.setPressed(false); setPressed(false); - if (mSelector != null && mSelector.supportsHotspots()) { - mSelector.removeHotspot(R.attr.state_pressed); - } if (!mDataChanged && !mIsDetaching && isAttachedToWindow()) { performClick.run(); } diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 4f2d9c6..1152e17 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -31,8 +31,6 @@ import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; -import com.android.internal.R; - public abstract class AbsSeekBar extends ProgressBar { private final Rect mTempRect = new Rect(); @@ -348,7 +346,7 @@ public abstract class AbsSeekBar extends ProgressBar { final int right = left + thumbWidth; final Drawable background = getBackground(); - if (background != null && background.supportsHotspots()) { + if (background != null) { final Rect bounds = mThumb.getBounds(); final int offsetX = mPaddingLeft - mThumbOffset; final int offsetY = mPaddingTop; @@ -499,17 +497,10 @@ public abstract class AbsSeekBar extends ProgressBar { return true; } - private void setHotspot(int id, float x, float y) { - final Drawable bg = getBackground(); - if (bg != null && bg.supportsHotspots()) { - bg.setHotspot(id, x, y); - } - } - - private void clearHotspot(int id) { + private void setHotspot(float x, float y) { final Drawable bg = getBackground(); - if (bg != null && bg.supportsHotspots()) { - bg.removeHotspot(id); + if (bg != null) { + bg.setHotspot(x, y); } } @@ -541,7 +532,7 @@ public abstract class AbsSeekBar extends ProgressBar { final int max = getMax(); progress += scale * max; - setHotspot(R.attr.state_pressed, x, (int) event.getY()); + setHotspot(x, (int) event.getY()); setProgress((int) progress, true); } @@ -567,7 +558,6 @@ public abstract class AbsSeekBar extends ProgressBar { * canceled. */ void onStopTrackingTouch() { - clearHotspot(R.attr.state_pressed); mIsDragging = false; } diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 9e17cca..6aff4f4 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -285,7 +285,7 @@ public abstract class CompoundButton extends Button implements Checkable { buttonDrawable.setBounds(left, top, right, bottom); final Drawable background = getBackground(); - if (background != null && background.supportsHotspots()) { + if (background != null) { background.setHotspotBounds(left, top, right, bottom); } } diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index 74a3eec..ad1a023 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -828,7 +828,7 @@ public class Switch extends CompoundButton { thumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); final Drawable background = getBackground(); - if (background != null && background.supportsHotspots()) { + if (background != null) { background.setHotspotBounds(thumbLeft, switchTop, thumbRight, switchBottom); } diff --git a/core/res/res/drawable/btn_borderless_quantum.xml b/core/res/res/drawable/btn_borderless_quantum.xml index 2e3c515..eaf2550 100644 --- a/core/res/res/drawable/btn_borderless_quantum.xml +++ b/core/res/res/drawable/btn_borderless_quantum.xml @@ -14,8 +14,8 @@ limitations under the License. --> -<touch-feedback xmlns:android="http://schemas.android.com/apk/res/android" +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="?attr/colorButtonPressed"> <item android:id="@id/mask" android:drawable="@drawable/btn_qntm_alpha" /> -</touch-feedback> +</ripple> diff --git a/core/res/res/drawable/btn_default_quantum.xml b/core/res/res/drawable/btn_default_quantum.xml index c6a3a33..d8ab667 100644 --- a/core/res/res/drawable/btn_default_quantum.xml +++ b/core/res/res/drawable/btn_default_quantum.xml @@ -14,7 +14,7 @@ limitations under the License. --> -<touch-feedback xmlns:android="http://schemas.android.com/apk/res/android" +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="?attr/colorButtonPressed"> <item> <selector> @@ -31,4 +31,4 @@ </item> </selector> </item> -</touch-feedback> +</ripple> diff --git a/core/res/res/drawable/edit_text_quantum.xml b/core/res/res/drawable/edit_text_quantum.xml index c42c7b7..67339e8 100644 --- a/core/res/res/drawable/edit_text_quantum.xml +++ b/core/res/res/drawable/edit_text_quantum.xml @@ -14,7 +14,7 @@ limitations under the License. --> -<touch-feedback xmlns:android="http://schemas.android.com/apk/res/android" +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="?attr/colorControlActivated"> <item> <selector> @@ -36,4 +36,4 @@ </item> </selector> </item> -</touch-feedback> +</ripple> diff --git a/core/res/res/drawable/item_background_quantum.xml b/core/res/res/drawable/item_background_quantum.xml index 11e1f67..631d3e4 100644 --- a/core/res/res/drawable/item_background_quantum.xml +++ b/core/res/res/drawable/item_background_quantum.xml @@ -14,6 +14,6 @@ limitations under the License. --> -<touch-feedback xmlns:android="http://schemas.android.com/apk/res/android" +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="?attr/colorButtonPressed" android:pinned="true" /> diff --git a/core/res/res/drawable/list_selector_quantum.xml b/core/res/res/drawable/list_selector_quantum.xml index c007117..0e185aa 100644 --- a/core/res/res/drawable/list_selector_quantum.xml +++ b/core/res/res/drawable/list_selector_quantum.xml @@ -14,9 +14,9 @@ limitations under the License. --> -<touch-feedback xmlns:android="http://schemas.android.com/apk/res/android" +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="?attr/colorButtonPressed"> <item android:id="@id/mask"> <color android:color="@color/white" /> </item> -</touch-feedback> +</ripple> diff --git a/core/res/res/drawable/notification_bg_dim.xml b/core/res/res/drawable/notification_bg_dim.xml index ec20368..ae03d82 100644 --- a/core/res/res/drawable/notification_bg_dim.xml +++ b/core/res/res/drawable/notification_bg_dim.xml @@ -15,9 +15,9 @@ ~ limitations under the License --> -<touch-feedback +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="#ff444444" > <item android:drawable="@drawable/notification_bg_normal" /> -</touch-feedback>
\ No newline at end of file +</ripple>
\ No newline at end of file diff --git a/core/res/res/drawable/notification_quantum_bg_dim.xml b/core/res/res/drawable/notification_quantum_bg_dim.xml index ab0e049..eb9a4ab 100644 --- a/core/res/res/drawable/notification_quantum_bg_dim.xml +++ b/core/res/res/drawable/notification_quantum_bg_dim.xml @@ -15,7 +15,7 @@ ~ limitations under the License --> -<touch-feedback +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:tint="#ffffffff" android:tintMode="src_over" @@ -26,4 +26,4 @@ <corners android:radius="@dimen/notification_quantum_rounded_rect_radius" /> </shape> </item> -</touch-feedback>
\ No newline at end of file +</ripple>
\ No newline at end of file diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 51dff74..8dac084 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -4647,7 +4647,7 @@ </declare-styleable> <!-- Drawable used to show animated touch feedback. --> - <declare-styleable name="TouchFeedbackDrawable"> + <declare-styleable name="RippleDrawable"> <!-- The tint to use for feedback ripples. This attribute is required. --> <attr name="tint" /> <!-- Specifies the Porter-Duff blending mode used to apply the tint. The default vlaue is src_atop, which draws over the opaque parts of the drawable. --> diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index b939636..c78096a 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -484,55 +484,28 @@ public abstract class Drawable { } /** - * Indicates whether the drawable supports hotspots. Hotspots are uniquely - * identifiable coordinates the may be added, updated and removed within a - * drawable. + * Specifies the hotspot's location within the drawable. * - * @return true if hotspots are supported - * @see #setHotspot(int, float, float) - * @see #removeHotspot(int) - * @see #clearHotspots() - */ - public boolean supportsHotspots() { - return false; - } - - /** - * Specifies a hotspot's location within the drawable. - * <p> - * The specified key should be an id declared in the resources of the - * application to ensure it is unique (see the <a - * href={@docRoot}guide/topics/resources/more-resources.html#Id">ID resource type</a>). - * - * @param key The key identifying the hotspot * @param x The X coordinate of the center of the hotspot * @param y The Y coordinate of the center of the hotspot */ - public void setHotspot(int key, float x, float y) {} + public void setHotspot(float x, float y) {} /** - * Removes the hotspot with the specified key from the drawable. - * - * @param key The key identifying the hotspot - */ - public void removeHotspot(int key) {} - - /** - * Immediately removes all hotspots from the drawable. - */ - public void clearHotspots() {} - - /** - * Sets the bounds to which hotspots are constrained. - * - * @hide until we finalize these APIs + * Sets the bounds to which the hotspot is constrained, if they should be + * different from the drawable bounds. + * + * @param left + * @param top + * @param right + * @param bottom */ public void setHotspotBounds(int left, int top, int right, int bottom) {} /** * Whether this drawable requests projection. * - * @hide until we finalize these APIs + * @hide magic! */ public boolean isProjected() { return false; @@ -1047,8 +1020,8 @@ public abstract class Drawable { drawable = new LayerDrawable(); } else if (name.equals("transition")) { drawable = new TransitionDrawable(); - } else if (name.equals("touch-feedback")) { - drawable = new TouchFeedbackDrawable(); + } else if (name.equals("ripple")) { + drawable = new RippleDrawable(); } else if (name.equals("color")) { drawable = new ColorDrawable(); } else if (name.equals("shape")) { diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 08fc99d..ec5c6c6 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -238,35 +238,13 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } @Override - public void setHotspot(int key, float x, float y) { + public void setHotspot(float x, float y) { if (mCurrDrawable != null) { - mCurrDrawable.setHotspot(key, x, y); + mCurrDrawable.setHotspot(x, y); } } @Override - public void removeHotspot(int key) { - if (mCurrDrawable != null) { - mCurrDrawable.removeHotspot(key); - } - } - - @Override - public void clearHotspots() { - if (mCurrDrawable != null) { - mCurrDrawable.clearHotspots(); - } - } - - @Override - public boolean supportsHotspots() { - if (mCurrDrawable != null) { - return mCurrDrawable.supportsHotspots(); - } - return false; - } - - @Override protected boolean onStateChange(int[] state) { if (mLastDrawable != null) { return mLastDrawable.setState(state); diff --git a/graphics/java/android/graphics/drawable/DrawableWrapper.java b/graphics/java/android/graphics/drawable/DrawableWrapper.java deleted file mode 100644 index 6ab33f8..0000000 --- a/graphics/java/android/graphics/drawable/DrawableWrapper.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.graphics.drawable; - -import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.Rect; -import android.graphics.Xfermode; - -/** - * A Drawable that wraps another Drawable. - */ -public class DrawableWrapper extends Drawable implements Drawable.Callback { - private WrapperState mWrapperState; - - /** Local drawable backed by its own constant state. */ - private Drawable mWrappedDrawable; - - private boolean mMutated; - - /** @hide */ - @Override - public boolean isProjected() { - return mWrappedDrawable.isProjected(); - } - - @Override - public void setAutoMirrored(boolean mirrored) { - mWrappedDrawable.setAutoMirrored(mirrored); - } - - @Override - public boolean isAutoMirrored() { - return mWrappedDrawable.isAutoMirrored(); - } - - @Override - public int getMinimumWidth() { - return mWrappedDrawable.getMinimumWidth(); - } - - @Override - public int getMinimumHeight() { - return mWrappedDrawable.getMinimumHeight(); - } - - @Override - public int getIntrinsicWidth() { - return mWrappedDrawable.getIntrinsicWidth(); - } - - @Override - public int getIntrinsicHeight() { - return mWrappedDrawable.getIntrinsicHeight(); - } - - @Override - public Drawable getCurrent() { - return mWrappedDrawable.getCurrent(); - } - - @Override - public void invalidateDrawable(Drawable who) { - final Callback callback = getCallback(); - if (callback != null) { - callback.invalidateDrawable(this); - } - } - - @Override - public void scheduleDrawable(Drawable who, Runnable what, long when) { - final Callback callback = getCallback(); - if (callback != null) { - callback.scheduleDrawable(this, what, when); - } - } - - @Override - public void unscheduleDrawable(Drawable who, Runnable what) { - final Callback callback = getCallback(); - if (callback != null) { - callback.unscheduleDrawable(this, what); - } - } - - @Override - public void draw(Canvas canvas) { - mWrappedDrawable.draw(canvas); - } - - @Override - public int getChangingConfigurations() { - return mWrappedDrawable.getChangingConfigurations(); - } - - @Override - public boolean getPadding(Rect padding) { - return mWrappedDrawable.getPadding(padding); - } - - @Override - public Rect getDirtyBounds() { - return mWrappedDrawable.getDirtyBounds(); - } - - @Override - public boolean supportsHotspots() { - return mWrappedDrawable.supportsHotspots(); - } - - @Override - public void setHotspot(int id, float x, float y) { - mWrappedDrawable.setHotspot(id, x, y); - } - - @Override - public void removeHotspot(int id) { - mWrappedDrawable.removeHotspot(id); - } - - @Override - public void clearHotspots() { - mWrappedDrawable.clearHotspots(); - } - - @Override - public boolean setVisible(boolean visible, boolean restart) { - // Must call through to super(). - super.setVisible(visible, restart); - return mWrappedDrawable.setVisible(visible, restart); - } - - @Override - public void setAlpha(int alpha) { - mWrappedDrawable.setAlpha(alpha); - } - - @Override - public int getAlpha() { - return mWrappedDrawable.getAlpha(); - } - - /** {@hide} */ - @Override - public void setLayoutDirection(int layoutDirection) { - mWrappedDrawable.setLayoutDirection(layoutDirection); - } - - /** {@hide} */ - @Override - public int getLayoutDirection() { - return mWrappedDrawable.getLayoutDirection(); - } - - @Override - public void setColorFilter(ColorFilter cf) { - mWrappedDrawable.setColorFilter(cf); - } - - @Override - public ColorFilter getColorFilter() { - return mWrappedDrawable.getColorFilter(); - } - - @Override - public void setFilterBitmap(boolean filter) { - mWrappedDrawable.setFilterBitmap(filter); - } - - @Override - public void setXfermode(Xfermode mode) { - mWrappedDrawable.setXfermode(mode); - } - - @Override - public int getOpacity() { - return mWrappedDrawable.getOpacity(); - } - - @Override - public boolean isStateful() { - return mWrappedDrawable.isStateful(); - } - - @Override - public final boolean setState(int[] stateSet) { - return super.setState(stateSet); - } - - @Override - public final int[] getState() { - return super.getState(); - } - - @Override - protected boolean onStateChange(int[] state) { - // Don't override setState(), getState(). - return mWrappedDrawable.setState(state); - } - - @Override - protected boolean onLevelChange(int level) { - // Don't override setLevel(), getLevel(). - return mWrappedDrawable.setLevel(level); - } - - @Override - public final void setBounds(int left, int top, int right, int bottom) { - super.setBounds(left, top, right, bottom); - } - - @Override - public final void setBounds(Rect bounds) { - super.setBounds(bounds); - } - - @Override - protected void onBoundsChange(Rect bounds) { - // Don't override setBounds(), getBounds(). - mWrappedDrawable.setBounds(bounds); - } - - protected void setConstantState(WrapperState wrapperState, Resources res) { - mWrapperState = wrapperState; - - // Load a new drawable from the constant state. - if (wrapperState == null || wrapperState.mWrappedConstantState == null) { - mWrappedDrawable = null; - } else if (res != null) { - mWrappedDrawable = wrapperState.mWrappedConstantState.newDrawable(res); - } else { - mWrappedDrawable = wrapperState.mWrappedConstantState.newDrawable(); - } - } - - @Override - public ConstantState getConstantState() { - return mWrapperState; - } - - @Override - public Drawable mutate() { - if (!mMutated) { - mWrappedDrawable = mWrappedDrawable.mutate(); - mMutated = true; - } - return this; - } - - /** - * Sets the wrapped drawable and update the constant state. - * - * @param drawable - * @param res - */ - protected final void setDrawable(Drawable drawable, Resources res) { - if (mWrappedDrawable != null) { - mWrappedDrawable.setCallback(null); - } - - mWrappedDrawable = drawable; - - if (drawable != null) { - drawable.setCallback(this); - - mWrapperState.mWrappedConstantState = drawable.getConstantState(); - } else { - mWrapperState.mWrappedConstantState = null; - } - } - - protected final Drawable getDrawable() { - return mWrappedDrawable; - } - - public static abstract class WrapperState extends ConstantState { - ConstantState mWrappedConstantState; - - WrapperState(WrapperState orig) { - if (orig != null) { - mWrappedConstantState = orig.mWrappedConstantState; - } - } - - @Override - public int getChangingConfigurations() { - return mWrappedConstantState.getChangingConfigurations(); - } - } -} diff --git a/graphics/java/android/graphics/drawable/InsetDrawable.java b/graphics/java/android/graphics/drawable/InsetDrawable.java index 9384caf..3749339 100644 --- a/graphics/java/android/graphics/drawable/InsetDrawable.java +++ b/graphics/java/android/graphics/drawable/InsetDrawable.java @@ -131,6 +131,7 @@ public class InsetDrawable extends Drawable implements Drawable.Callback // overrides from Drawable.Callback + @Override public void invalidateDrawable(Drawable who) { final Callback callback = getCallback(); if (callback != null) { @@ -138,6 +139,7 @@ public class InsetDrawable extends Drawable implements Drawable.Callback } } + @Override public void scheduleDrawable(Drawable who, Runnable what, long when) { final Callback callback = getCallback(); if (callback != null) { @@ -145,6 +147,7 @@ public class InsetDrawable extends Drawable implements Drawable.Callback } } + @Override public void unscheduleDrawable(Drawable who, Runnable what) { final Callback callback = getCallback(); if (callback != null) { @@ -184,23 +187,8 @@ public class InsetDrawable extends Drawable implements Drawable.Callback } @Override - public boolean supportsHotspots() { - return mInsetState.mDrawable.supportsHotspots(); - } - - @Override - public void setHotspot(int id, float x, float y) { - mInsetState.mDrawable.setHotspot(id, x, y); - } - - @Override - public void removeHotspot(int id) { - mInsetState.mDrawable.removeHotspot(id); - } - - @Override - public void clearHotspots() { - mInsetState.mDrawable.clearHotspots(); + public void setHotspot(float x, float y) { + mInsetState.mDrawable.setHotspot(x, y); } @Override diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java index 7847aad..373d894 100644 --- a/graphics/java/android/graphics/drawable/LayerDrawable.java +++ b/graphics/java/android/graphics/drawable/LayerDrawable.java @@ -569,42 +569,11 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } @Override - public boolean supportsHotspots() { + public void setHotspot(float x, float y) { final ChildDrawable[] array = mLayerState.mChildren; final int N = mLayerState.mNum; for (int i = 0; i < N; i++) { - if (array[i].mDrawable.supportsHotspots()) { - return true; - } - } - - return false; - } - - @Override - public void setHotspot(int id, float x, float y) { - final ChildDrawable[] array = mLayerState.mChildren; - final int N = mLayerState.mNum; - for (int i = 0; i < N; i++) { - array[i].mDrawable.setHotspot(id, x, y); - } - } - - @Override - public void removeHotspot(int id) { - final ChildDrawable[] array = mLayerState.mChildren; - final int N = mLayerState.mNum; - for (int i = 0; i < N; i++) { - array[i].mDrawable.removeHotspot(id); - } - } - - @Override - public void clearHotspots() { - final ChildDrawable[] array = mLayerState.mChildren; - final int N = mLayerState.mNum; - for (int i = 0; i < N; i++) { - array[i].mDrawable.clearHotspots(); + array[i].mDrawable.setHotspot(x, y); } } diff --git a/graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index a55a4b2..6776e66 100644 --- a/graphics/java/android/graphics/drawable/TouchFeedbackDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -22,6 +22,7 @@ import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.PointF; @@ -44,7 +45,7 @@ import java.io.IOException; /** * Drawable that shows a ripple effect in response to state changes. The * anchoring position of the ripple for a given state may be specified by - * calling {@link #setHotspot(int, float, float)} with the corresponding state + * calling {@link #setHotspot(float, float)} with the corresponding state * attribute identifier. * <p> * A touch feedback drawable may contain multiple child layers, including a @@ -56,19 +57,19 @@ import java.io.IOException; * <p> * If no mask layer is set, the ripple effect is simply blended onto the * composite of the child layers using the specified - * {@link android.R.styleable#TouchFeedbackDrawable_tintMode}. + * {@link android.R.styleable#RippleDrawable_tintMode}. * <p> * If no child layers or mask is specified and the ripple is set as a View * background, the ripple will be blended onto the first available parent * background within the View's hierarchy using the specified - * {@link android.R.styleable#TouchFeedbackDrawable_tintMode}. In this case, the + * {@link android.R.styleable#RippleDrawable_tintMode}. In this case, the * drawing region may extend outside of the Drawable bounds. * * @attr ref android.R.styleable#DrawableStates_state_focused * @attr ref android.R.styleable#DrawableStates_state_pressed */ -public class TouchFeedbackDrawable extends LayerDrawable { - private static final String LOG_TAG = TouchFeedbackDrawable.class.getSimpleName(); +public class RippleDrawable extends LayerDrawable { + private static final String LOG_TAG = RippleDrawable.class.getSimpleName(); private static final PorterDuffXfermode DST_IN = new PorterDuffXfermode(Mode.DST_IN); private static final PorterDuffXfermode DST_ATOP = new PorterDuffXfermode(Mode.DST_ATOP); private static final PorterDuffXfermode SRC_ATOP = new PorterDuffXfermode(Mode.SRC_ATOP); @@ -88,17 +89,17 @@ public class TouchFeedbackDrawable extends LayerDrawable { /** Current dirty bounds, union of current and previous drawing bounds. */ private final Rect mDirtyBounds = new Rect(); - private final TouchFeedbackState mState; + private final RippleState mState; /** * Lazily-created map of pending hotspot locations. These may be modified by - * calls to {@link #setHotspot(int, float, float)}. + * calls to {@link #setHotspot(float, float)}. */ private SparseArray<PointF> mPendingHotspots; /** * Lazily-created map of active hotspot locations. These may be modified by - * calls to {@link #setHotspot(int, float, float)}. + * calls to {@link #setHotspot(float, float)}. */ private SparseArray<Ripple> mActiveHotspots; @@ -121,8 +122,18 @@ public class TouchFeedbackDrawable extends LayerDrawable { /** Whether bounds are being overridden. */ private boolean mOverrideBounds; - TouchFeedbackDrawable() { - this(new TouchFeedbackState(null, null, null), null, null); + RippleDrawable() { + this(new RippleState(null, null, null), null, null); + } + + @Override + public void setAlpha(int alpha) { + + } + + @Override + public void setColorFilter(ColorFilter cf) { + } @Override @@ -233,7 +244,7 @@ public class TouchFeedbackDrawable extends LayerDrawable { public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { final TypedArray a = obtainAttributes( - r, theme, attrs, R.styleable.TouchFeedbackDrawable); + r, theme, attrs, R.styleable.RippleDrawable); updateStateFromTypedArray(a); a.recycle(); @@ -267,22 +278,22 @@ public class TouchFeedbackDrawable extends LayerDrawable { * Initializes the constant state from the values in the typed array. */ private void updateStateFromTypedArray(TypedArray a) { - final TouchFeedbackState state = mState; + final RippleState state = mState; // Extract the theme attributes, if any. state.mTouchThemeAttrs = a.extractThemeAttrs(); - final ColorStateList tint = a.getColorStateList(R.styleable.TouchFeedbackDrawable_tint); + final ColorStateList tint = a.getColorStateList(R.styleable.RippleDrawable_tint); if (tint != null) { mState.mTint = tint; } - final int tintMode = a.getInt(R.styleable.TouchFeedbackDrawable_tintMode, -1); + final int tintMode = a.getInt(R.styleable.RippleDrawable_tintMode, -1); if (tintMode != -1) { mState.setTintMode(Drawable.parseTintMode(tintMode, Mode.SRC_ATOP)); } - mState.mPinned = a.getBoolean(R.styleable.TouchFeedbackDrawable_pinned, mState.mPinned); + mState.mPinned = a.getBoolean(R.styleable.RippleDrawable_pinned, mState.mPinned); } /** @@ -301,13 +312,13 @@ public class TouchFeedbackDrawable extends LayerDrawable { public void applyTheme(Theme t) { super.applyTheme(t); - final TouchFeedbackState state = mState; + final RippleState state = mState; if (state == null || state.mTouchThemeAttrs == null) { return; } final TypedArray a = t.resolveAttributes(state.mTouchThemeAttrs, - R.styleable.TouchFeedbackDrawable); + R.styleable.RippleDrawable); updateStateFromTypedArray(a); a.recycle(); } @@ -318,17 +329,14 @@ public class TouchFeedbackDrawable extends LayerDrawable { } @Override - public boolean supportsHotspots() { - return true; - } - - @Override - public void setHotspot(int id, float x, float y) { + public void setHotspot(float x, float y) { if (mState.mPinned && !circleContains(mHotspotBounds, x, y)) { x = mHotspotBounds.exactCenterX(); y = mHotspotBounds.exactCenterY(); } + // TODO: We should only have a single pending/active hotspot. + final int id = R.attr.state_pressed; final int[] stateSet = getState(); if (!Arrays.contains(stateSet, id)) { // The hotspot is not active, so just modify the pending location. @@ -423,8 +431,7 @@ public class TouchFeedbackDrawable extends LayerDrawable { mActiveHotspots.put(id, newRipple); } - @Override - public void removeHotspot(int id) { + private void removeHotspot(int id) { if (mActiveHotspots == null) { return; } @@ -437,8 +444,7 @@ public class TouchFeedbackDrawable extends LayerDrawable { } } - @Override - public void clearHotspots() { + private void clearHotspots() { if (mActiveHotspots != null) { mActiveHotspots.clear(); } @@ -632,7 +638,7 @@ public class TouchFeedbackDrawable extends LayerDrawable { return mState; } - static class TouchFeedbackState extends LayerState { + static class RippleState extends LayerState { int[] mTouchThemeAttrs; ColorStateList mTint = null; PorterDuffXfermode mTintXfermode = SRC_ATOP; @@ -640,8 +646,8 @@ public class TouchFeedbackDrawable extends LayerDrawable { Drawable mMask; boolean mPinned = false; - public TouchFeedbackState( - TouchFeedbackState orig, TouchFeedbackDrawable owner, Resources res) { + public RippleState( + RippleState orig, RippleDrawable owner, Resources res) { super(orig, owner, res); if (orig != null) { @@ -655,7 +661,7 @@ public class TouchFeedbackDrawable extends LayerDrawable { } public void setTintMode(Mode mode) { - final Mode invertedMode = TouchFeedbackState.invertPorterDuffMode(mode); + final Mode invertedMode = RippleState.invertPorterDuffMode(mode); mTintXfermodeInverse = new PorterDuffXfermode(invertedMode); mTintXfermode = new PorterDuffXfermode(mode); } @@ -675,17 +681,17 @@ public class TouchFeedbackDrawable extends LayerDrawable { @Override public Drawable newDrawable() { - return new TouchFeedbackDrawable(this, null, null); + return new RippleDrawable(this, null, null); } @Override public Drawable newDrawable(Resources res) { - return new TouchFeedbackDrawable(this, res, null); + return new RippleDrawable(this, res, null); } @Override public Drawable newDrawable(Resources res, Theme theme) { - return new TouchFeedbackDrawable(this, res, theme); + return new RippleDrawable(this, res, theme); } /** @@ -716,20 +722,20 @@ public class TouchFeedbackDrawable extends LayerDrawable { } } - private TouchFeedbackDrawable(TouchFeedbackState state, Resources res, Theme theme) { + private RippleDrawable(RippleState state, Resources res, Theme theme) { boolean needsTheme = false; - final TouchFeedbackState ns; + final RippleState ns; if (theme != null && state != null && state.canApplyTheme()) { - ns = new TouchFeedbackState(state, this, res); + ns = new RippleState(state, this, res); needsTheme = true; } else if (state == null) { - ns = new TouchFeedbackState(null, this, res); + ns = new RippleState(null, this, res); } else { // We always need a new state since child drawables contain local // state but live within the parent's constant state. // TODO: Move child drawables into local state. - ns = new TouchFeedbackState(state, this, res); + ns = new RippleState(state, this, res); } if (res != null) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskInfoView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskInfoView.java index f1c362a..7b6572b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskInfoView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskInfoView.java @@ -25,7 +25,7 @@ import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Point; import android.graphics.Rect; -import android.graphics.drawable.TouchFeedbackDrawable; +import android.graphics.drawable.RippleDrawable; import android.util.AttributeSet; import android.widget.Button; import android.widget.FrameLayout; @@ -156,8 +156,8 @@ class TaskInfoView extends FrameLayout { // Workaround: The button currently doesn't support setting a custom background tint // not defined in the theme. Just lower the alpha on the button to make it blend more // into the background. - if (mAppInfoButton.getBackground() instanceof TouchFeedbackDrawable) { - TouchFeedbackDrawable d = (TouchFeedbackDrawable) mAppInfoButton.getBackground(); + if (mAppInfoButton.getBackground() instanceof RippleDrawable) { + RippleDrawable d = (RippleDrawable) mAppInfoButton.getBackground(); if (d != null) { d.setAlpha(96); } |