Merge "Add attribute for controlling ripple radius"
This commit is contained in:
committed by
Android (Google) Code Review
commit
93dcc45e3c
@@ -12071,7 +12071,10 @@ package android.graphics.drawable {
|
||||
|
||||
public class RippleDrawable extends android.graphics.drawable.LayerDrawable {
|
||||
ctor public RippleDrawable(android.content.res.ColorStateList, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
|
||||
method public int getRadius();
|
||||
method public void setColor(android.content.res.ColorStateList);
|
||||
method public void setRadius(int);
|
||||
field public static final int RADIUS_AUTO = -1; // 0xffffffff
|
||||
}
|
||||
|
||||
public class RotateDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {
|
||||
|
||||
@@ -12345,7 +12345,10 @@ package android.graphics.drawable {
|
||||
|
||||
public class RippleDrawable extends android.graphics.drawable.LayerDrawable {
|
||||
ctor public RippleDrawable(android.content.res.ColorStateList, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
|
||||
method public int getRadius();
|
||||
method public void setColor(android.content.res.ColorStateList);
|
||||
method public void setRadius(int);
|
||||
field public static final int RADIUS_AUTO = -1; // 0xffffffff
|
||||
}
|
||||
|
||||
public class RotateDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?attr/colorControlHighlight"
|
||||
android:radius="20dp" />
|
||||
@@ -15,4 +15,5 @@
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/control_highlight_material" />
|
||||
android:color="@color/control_highlight_material"
|
||||
android:radius="20dp" />
|
||||
|
||||
@@ -5291,6 +5291,9 @@
|
||||
<declare-styleable name="RippleDrawable">
|
||||
<!-- The color to use for ripple effects. This attribute is required. -->
|
||||
<attr name="color" />
|
||||
<!-- The radius of the ripple when fully expanded. By default, the
|
||||
radius is computed based on the size of the ripple's container. -->
|
||||
<attr name="radius" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ScaleDrawable">
|
||||
|
||||
@@ -327,7 +327,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="actionBarWidgetTheme">@null</item>
|
||||
<item name="actionBarPopupTheme">?attr/popupTheme</item>
|
||||
<item name="actionBarTheme">@style/ThemeOverlay.Material.ActionBar</item>
|
||||
<item name="actionBarItemBackground">?attr/selectableItemBackgroundBorderless</item>
|
||||
<item name="actionBarItemBackground">@drawable/action_bar_item_background_material</item>
|
||||
|
||||
<item name="actionModeCutDrawable">@drawable/ic_menu_cut_material</item>
|
||||
<item name="actionModeCopyDrawable">@drawable/ic_menu_copy_material</item>
|
||||
@@ -681,7 +681,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="actionModePopupWindowStyle">@style/Widget.Material.Light.PopupWindow.ActionMode</item>
|
||||
<item name="actionBarWidgetTheme">@null</item>
|
||||
<item name="actionBarTheme">@style/ThemeOverlay.Material.ActionBar</item>
|
||||
<item name="actionBarItemBackground">?attr/selectableItemBackgroundBorderless</item>
|
||||
<item name="actionBarItemBackground">@drawable/action_bar_item_background_material</item>
|
||||
|
||||
<item name="actionModeCutDrawable">@drawable/ic_menu_cut_material</item>
|
||||
<item name="actionModeCopyDrawable">@drawable/ic_menu_copy_material</item>
|
||||
|
||||
@@ -46,8 +46,7 @@ class Ripple {
|
||||
private static final long RIPPLE_ENTER_DELAY = 80;
|
||||
|
||||
// Hardware animators.
|
||||
private final ArrayList<RenderNodeAnimator> mRunningAnimations =
|
||||
new ArrayList<RenderNodeAnimator>();
|
||||
private final ArrayList<RenderNodeAnimator> mRunningAnimations = new ArrayList<>();
|
||||
|
||||
private final RippleDrawable mOwner;
|
||||
|
||||
@@ -117,8 +116,8 @@ class Ripple {
|
||||
mStartingY = startingY;
|
||||
}
|
||||
|
||||
public void setup(int maxRadius, float density) {
|
||||
if (maxRadius != RippleDrawable.RADIUS_AUTO) {
|
||||
public void setup(float maxRadius, float density) {
|
||||
if (maxRadius >= 0) {
|
||||
mHasMaxRadius = true;
|
||||
mOuterRadius = maxRadius;
|
||||
} else {
|
||||
|
||||
@@ -49,8 +49,7 @@ class RippleBackground {
|
||||
private static final int ENTER_DURATION_FAST = 100;
|
||||
|
||||
// Hardware animators.
|
||||
private final ArrayList<RenderNodeAnimator> mRunningAnimations =
|
||||
new ArrayList<RenderNodeAnimator>();
|
||||
private final ArrayList<RenderNodeAnimator> mRunningAnimations = new ArrayList<>();
|
||||
|
||||
private final RippleDrawable mOwner;
|
||||
|
||||
@@ -105,8 +104,8 @@ class RippleBackground {
|
||||
mBounds = bounds;
|
||||
}
|
||||
|
||||
public void setup(int maxRadius, float density) {
|
||||
if (maxRadius != RippleDrawable.RADIUS_AUTO) {
|
||||
public void setup(float maxRadius, float density) {
|
||||
if (maxRadius >= 0) {
|
||||
mHasMaxRadius = true;
|
||||
mOuterRadius = maxRadius;
|
||||
} else {
|
||||
|
||||
@@ -92,19 +92,17 @@ import java.util.Arrays;
|
||||
* @attr ref android.R.styleable#RippleDrawable_color
|
||||
*/
|
||||
public class RippleDrawable extends LayerDrawable {
|
||||
/**
|
||||
* Radius value that specifies the ripple radius should be computed based
|
||||
* on the size of the ripple's container.
|
||||
*/
|
||||
public static final int RADIUS_AUTO = -1;
|
||||
|
||||
private static final int MASK_UNKNOWN = -1;
|
||||
private static final int MASK_NONE = 0;
|
||||
private static final int MASK_CONTENT = 1;
|
||||
private static final int MASK_EXPLICIT = 2;
|
||||
|
||||
/**
|
||||
* Constant for automatically determining the maximum ripple radius.
|
||||
*
|
||||
* @see #setMaxRadius(int)
|
||||
* @hide
|
||||
*/
|
||||
public static final int RADIUS_AUTO = -1;
|
||||
|
||||
/** The maximum number of ripples supported. */
|
||||
private static final int MAX_RIPPLES = 10;
|
||||
|
||||
@@ -356,12 +354,36 @@ public class RippleDrawable extends LayerDrawable {
|
||||
* Sets the ripple color.
|
||||
*
|
||||
* @param color Ripple color as a color state list.
|
||||
*
|
||||
* @attr ref android.R.styleable#RippleDrawable_color
|
||||
*/
|
||||
public void setColor(ColorStateList color) {
|
||||
mState.mColor = color;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the radius in pixels of the fully expanded ripple.
|
||||
*
|
||||
* @param radius ripple radius in pixels, or {@link #RADIUS_AUTO} to
|
||||
* compute the radius based on the container size
|
||||
* @attr ref android.R.styleable#RippleDrawable_radius
|
||||
*/
|
||||
public void setRadius(int radius) {
|
||||
mState.mMaxRadius = radius;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the radius in pixels of the fully expanded ripple if an explicit
|
||||
* radius has been set, or {@link #RADIUS_AUTO} if the radius is
|
||||
* computed based on the container size
|
||||
* @attr ref android.R.styleable#RippleDrawable_radius
|
||||
*/
|
||||
public int getRadius() {
|
||||
return mState.mMaxRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
|
||||
throws XmlPullParserException, IOException {
|
||||
@@ -428,6 +450,9 @@ public class RippleDrawable extends LayerDrawable {
|
||||
mState.mColor = color;
|
||||
}
|
||||
|
||||
mState.mMaxRadius = a.getDimensionPixelSize(
|
||||
R.styleable.RippleDrawable_radius, mState.mMaxRadius);
|
||||
|
||||
verifyRequiredAttributes(a);
|
||||
}
|
||||
|
||||
@@ -959,36 +984,6 @@ public class RippleDrawable extends LayerDrawable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum ripple radius in pixels. The default value of
|
||||
* {@link #RADIUS_AUTO} defines the radius as the distance from the center
|
||||
* of the drawable bounds (or hotspot bounds, if specified) to a corner.
|
||||
*
|
||||
* @param maxRadius the maximum ripple radius in pixels or
|
||||
* {@link #RADIUS_AUTO} to automatically determine the maximum
|
||||
* radius based on the bounds
|
||||
* @see #getMaxRadius()
|
||||
* @see #setHotspotBounds(int, int, int, int)
|
||||
* @hide
|
||||
*/
|
||||
public void setMaxRadius(int maxRadius) {
|
||||
if (maxRadius != RADIUS_AUTO && maxRadius < 0) {
|
||||
throw new IllegalArgumentException("maxRadius must be RADIUS_AUTO or >= 0");
|
||||
}
|
||||
|
||||
mState.mMaxRadius = maxRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum ripple radius in pixels, or {@link #RADIUS_AUTO} if
|
||||
* the radius is determined automatically
|
||||
* @see #setMaxRadius(int)
|
||||
* @hide
|
||||
*/
|
||||
public int getMaxRadius() {
|
||||
return mState.mMaxRadius;
|
||||
}
|
||||
|
||||
private RippleDrawable(RippleState state, Resources res) {
|
||||
mState = new RippleState(state, this, res);
|
||||
mLayerState = mState;
|
||||
|
||||
Reference in New Issue
Block a user