summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-06-27 14:34:54 -0700
committerAlan Viverette <alanv@google.com>2014-06-27 14:34:54 -0700
commit7275abde37f0ad2df50e78de2fee1c0cfeb9cd92 (patch)
tree63e1f028110c0897739c9f9280b8b25bebc7423e /graphics
parentd42f49584992c421430e8614312c0136e49f54e9 (diff)
downloadframeworks_base-7275abde37f0ad2df50e78de2fee1c0cfeb9cd92.zip
frameworks_base-7275abde37f0ad2df50e78de2fee1c0cfeb9cd92.tar.gz
frameworks_base-7275abde37f0ad2df50e78de2fee1c0cfeb9cd92.tar.bz2
Require color in RippleDrawable constructor, fix documentation
Marks old constructor for removal and emits LOG_E when used. BUG: 15808263 Change-Id: Iae4f3237261541cb04f42343351b3fc0ac4929ac
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java40
1 files changed, 34 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index f2e75a5..9bf7c43 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -16,6 +16,8 @@
package android.graphics.drawable;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
@@ -52,7 +54,7 @@ import java.io.IOException;
* <code>&lt!-- A red ripple masked against an opaque rectangle. --/>
* &ltripple android:color="#ffff0000">
* &ltitem android:id="@android:id/mask"
- * android:drawable="#ffffffff" />
+ * android:drawable="@android:color/white" />
* &ltripple /></code>
* </pre>
* <p>
@@ -62,9 +64,9 @@ import java.io.IOException;
* If no mask layer is set, the ripple effect is masked against the composite
* of the child layers.
* <pre>
- * <code>&lt!-- A blue ripple drawn atop a green rectangle. --/>
+ * <code>&lt!-- A blue ripple drawn atop a black rectangle. --/>
* &ltripple android:color="#ff00ff00">
- * &ltitem android:drawable="#ff0000ff" />
+ * &ltitem android:drawable="@android:color/black" />
* &ltripple />
*
* &lt!-- A red ripple drawn atop a drawable resource. --/>
@@ -147,15 +149,40 @@ public class RippleDrawable extends LayerDrawable {
}
/**
- * Creates a new ripple drawable with the specified content and mask
- * drawables.
+ * @hide TO BE REMOVED FOR L-RELEASE
+ */
+ public RippleDrawable(Drawable content, Drawable mask) {
+ this(new RippleState(null, null, null), null, null);
+
+ if (content != null) {
+ addLayer(content, null, 0, 0, 0, 0, 0);
+ }
+
+ if (mask != null) {
+ addLayer(content, null, android.R.id.mask, 0, 0, 0, 0);
+ }
+
+ ensurePadding();
+
+ Log.e(LOG_TAG, "This constructor is being removed", new RuntimeException());
+ }
+
+ /**
+ * Creates a new ripple drawable with the specified ripple color and
+ * optional content and mask drawables.
*
+ * @param color The ripple color
* @param content The content drawable, may be {@code null}
* @param mask The mask drawable, may be {@code null}
*/
- public RippleDrawable(Drawable content, Drawable mask) {
+ public RippleDrawable(@NonNull ColorStateList color, @Nullable Drawable content,
+ @Nullable Drawable mask) {
this(new RippleState(null, null, null), null, null);
+ if (color == null) {
+ throw new IllegalArgumentException("RippleDrawable requires a non-null color");
+ }
+
if (content != null) {
addLayer(content, null, 0, 0, 0, 0, 0);
}
@@ -164,6 +191,7 @@ public class RippleDrawable extends LayerDrawable {
addLayer(content, null, android.R.id.mask, 0, 0, 0, 0);
}
+ setColor(color);
ensurePadding();
}