diff --git a/api/current.txt b/api/current.txt
index d1b6ba0df5003..e2bd0da861019 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -12069,7 +12069,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 {
diff --git a/api/system-current.txt b/api/system-current.txt
index fd6e2c8f1432b..b333f955d39e2 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -12343,7 +12343,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 {
diff --git a/core/res/res/drawable/action_bar_item_background_material.xml b/core/res/res/drawable/action_bar_item_background_material.xml
new file mode 100644
index 0000000000000..8228e3f583253
--- /dev/null
+++ b/core/res/res/drawable/action_bar_item_background_material.xml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/core/res/res/drawable/control_background_material.xml b/core/res/res/drawable/control_background_material.xml
index ae3181a786f53..7b78349b2b9af 100644
--- a/core/res/res/drawable/control_background_material.xml
+++ b/core/res/res/drawable/control_background_material.xml
@@ -15,4 +15,5 @@
-->
+ android:color="@color/control_highlight_material"
+ android:radius="20dp" />
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index b90ac65547b87..bc20378f7bc6e 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5291,6 +5291,9 @@
+
+
diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml
index 57041fdd51b7c..f9c4da7a7428c 100644
--- a/core/res/res/values/themes_material.xml
+++ b/core/res/res/values/themes_material.xml
@@ -327,7 +327,7 @@ please see themes_device_defaults.xml.
- @null
- ?attr/popupTheme
- @style/ThemeOverlay.Material.ActionBar
- - ?attr/selectableItemBackgroundBorderless
+ - @drawable/action_bar_item_background_material
- @drawable/ic_menu_cut_material
- @drawable/ic_menu_copy_material
@@ -681,7 +681,7 @@ please see themes_device_defaults.xml.
- @style/Widget.Material.Light.PopupWindow.ActionMode
- @null
- @style/ThemeOverlay.Material.ActionBar
- - ?attr/selectableItemBackgroundBorderless
+ - @drawable/action_bar_item_background_material
- @drawable/ic_menu_cut_material
- @drawable/ic_menu_copy_material
diff --git a/graphics/java/android/graphics/drawable/Ripple.java b/graphics/java/android/graphics/drawable/Ripple.java
index bb1d3cb4e6eea..138d73a8a4a33 100644
--- a/graphics/java/android/graphics/drawable/Ripple.java
+++ b/graphics/java/android/graphics/drawable/Ripple.java
@@ -46,8 +46,7 @@ class Ripple {
private static final long RIPPLE_ENTER_DELAY = 80;
// Hardware animators.
- private final ArrayList mRunningAnimations =
- new ArrayList();
+ private final ArrayList 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 {
diff --git a/graphics/java/android/graphics/drawable/RippleBackground.java b/graphics/java/android/graphics/drawable/RippleBackground.java
index fae4902d1d3d3..ef352890e4246 100644
--- a/graphics/java/android/graphics/drawable/RippleBackground.java
+++ b/graphics/java/android/graphics/drawable/RippleBackground.java
@@ -49,8 +49,7 @@ class RippleBackground {
private static final int ENTER_DURATION_FAST = 100;
// Hardware animators.
- private final ArrayList mRunningAnimations =
- new ArrayList();
+ private final ArrayList 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 {
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index ca9f714dd42da..556c59f61fa5a 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -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;