summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Grouchnikov <kirillg@google.com>2015-10-30 15:01:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-10-30 15:01:26 +0000
commit2af06780e2665a24fe7f2294f8519819fcd0a676 (patch)
tree4061caa1118836eed61ad62665ddb81ff2ab39fc
parentdc4682c24958b6721173555433abac879756e27f (diff)
parente4548b3ac721f2b85f7b030d7043c94b24288670 (diff)
downloadandroid_frameworks_support-2af06780e2665a24fe7f2294f8519819fcd0a676.tar.gz
android_frameworks_support-2af06780e2665a24fe7f2294f8519819fcd0a676.tar.bz2
android_frameworks_support-2af06780e2665a24fe7f2294f8519819fcd0a676.zip
Merge "Slight tweaks to the card view." into mnc-ub-dev
-rw-r--r--v7/cardview/eclair-mr1/android/support/v7/widget/RoundRectDrawableWithShadow.java13
-rw-r--r--v7/cardview/src/android/support/v7/widget/CardView.java90
2 files changed, 56 insertions, 47 deletions
diff --git a/v7/cardview/eclair-mr1/android/support/v7/widget/RoundRectDrawableWithShadow.java b/v7/cardview/eclair-mr1/android/support/v7/widget/RoundRectDrawableWithShadow.java
index 054ada804a..626b709967 100644
--- a/v7/cardview/eclair-mr1/android/support/v7/widget/RoundRectDrawableWithShadow.java
+++ b/v7/cardview/eclair-mr1/android/support/v7/widget/RoundRectDrawableWithShadow.java
@@ -131,8 +131,13 @@ class RoundRectDrawableWithShadow extends Drawable {
}
void setShadowSize(float shadowSize, float maxShadowSize) {
- if (shadowSize < 0 || maxShadowSize < 0) {
- throw new IllegalArgumentException("invalid shadow size");
+ if (shadowSize < 0f) {
+ throw new IllegalArgumentException("Invalid shadow size " + shadowSize +
+ ". Must be >= 0");
+ }
+ if (maxShadowSize < 0f) {
+ throw new IllegalArgumentException("Invalid max shadow size " + maxShadowSize +
+ ". Must be >= 0");
}
shadowSize = toEven(shadowSize);
maxShadowSize = toEven(maxShadowSize);
@@ -194,6 +199,10 @@ class RoundRectDrawableWithShadow extends Drawable {
}
void setCornerRadius(float radius) {
+ if (radius < 0f) {
+ throw new IllegalArgumentException("Invalid radius " + radius +
+ ". Must be >= 0");
+ }
radius = (int) (radius + .5f);
if (mCornerRadius == radius) {
return;
diff --git a/v7/cardview/src/android/support/v7/widget/CardView.java b/v7/cardview/src/android/support/v7/widget/CardView.java
index bc992b8758..eb181bcc55 100644
--- a/v7/cardview/src/android/support/v7/widget/CardView.java
+++ b/v7/cardview/src/android/support/v7/widget/CardView.java
@@ -27,33 +27,33 @@ import android.widget.FrameLayout;
/**
* A FrameLayout with a rounded corner background and shadow.
* <p>
- * CardView uses <code>elevation</code> property on L for shadows and falls back to a custom shadow
- * implementation on older platforms.
+ * CardView uses <code>elevation</code> property on Lollipop for shadows and falls back to a
+ * custom emulated shadow implementation on older platforms.
* <p>
- * Due to expensive nature of rounded corner clipping, on platforms before L, CardView does not
- * clip its children that intersect with rounded corners. Instead, it adds padding to avoid such
+ * Due to expensive nature of rounded corner clipping, on platforms before Lollipop, CardView does
+ * not clip its children that intersect with rounded corners. Instead, it adds padding to avoid such
* intersection (See {@link #setPreventCornerOverlap(boolean)} to change this behavior).
* <p>
- * Before L, CardView adds padding to its content and draws shadows to that area. This padding
- * amount is equal to <code>maxCardElevation + (1 - cos45) * cornerRadius</code> on the sides and
- * <code>maxCardElevation * 1.5 + (1 - cos45) * cornerRadius</code> on top and bottom.
+ * Before Lollipop, CardView adds padding to its content and draws shadows to that area. This
+ * padding amount is equal to <code>maxCardElevation + (1 - cos45) * cornerRadius</code> on the
+ * sides and <code>maxCardElevation * 1.5 + (1 - cos45) * cornerRadius</code> on top and bottom.
* <p>
* Since padding is used to offset content for shadows, you cannot set padding on CardView.
- * Instead,
- * you can use content padding attributes in XML or {@link #setContentPadding(int, int, int, int)}
- * in code to set the padding between the edges of the Card and children of CardView.
+ * Instead, you can use content padding attributes in XML or
+ * {@link #setContentPadding(int, int, int, int)} in code to set the padding between the edges of
+ * the CardView and children of CardView.
* <p>
* Note that, if you specify exact dimensions for the CardView, because of the shadows, its content
- * area will be different between platforms before L and after L. By using api version specific
- * resource values, you can avoid these changes. Alternatively, If you want CardView to add inner
- * padding on platforms L and after as well, you can set {@link #setUseCompatPadding(boolean)} to
- * <code>true</code>.
+ * area will be different between platforms before Lollipop and after Lollipop. By using api version
+ * specific resource values, you can avoid these changes. Alternatively, If you want CardView to add
+ * inner padding on platforms Lollipop and after as well, you can call
+ * {@link #setUseCompatPadding(boolean)} and pass <code>true</code>.
* <p>
* To change CardView's elevation in a backward compatible way, use
- * {@link #setCardElevation(float)}. CardView will use elevation API on L and before L, it will
- * change the shadow size. To avoid moving the View while shadow size is changing, shadow size is
- * clamped by {@link #getMaxCardElevation()}. If you want to change elevation dynamically, you
- * should call {@link #setMaxCardElevation(float)} when CardView is initialized.
+ * {@link #setCardElevation(float)}. CardView will use elevation API on Lollipop and before
+ * Lollipop, it will change the shadow size. To avoid moving the View while shadow size is changing,
+ * shadow size is clamped by {@link #getMaxCardElevation()}. If you want to change elevation
+ * dynamically, you should call {@link #setMaxCardElevation(float)} when CardView is initialized.
*
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardBackgroundColor
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardCornerRadius
@@ -116,10 +116,10 @@ public class CardView extends FrameLayout implements CardViewDelegate {
}
/**
- * Returns whether CardView will add inner padding on platforms L and after.
+ * Returns whether CardView will add inner padding on platforms Lollipop and after.
*
- * @return True CardView adds inner padding on platforms L and after to have same dimensions
- * with platforms before L.
+ * @return <code>true</code> if CardView adds inner padding on platforms Lollipop and after to
+ * have same dimensions with platforms before Lollipop.
*/
@Override
public boolean getUseCompatPadding() {
@@ -127,19 +127,19 @@ public class CardView extends FrameLayout implements CardViewDelegate {
}
/**
- * CardView adds additional padding to draw shadows on platforms before L.
+ * CardView adds additional padding to draw shadows on platforms before Lollipop.
* <p>
- * This may cause Cards to have different sizes between L and before L. If you need to align
- * CardView with other Views, you may need api version specific dimension resources to account
- * for the changes.
+ * This may cause Cards to have different sizes between Lollipop and before Lollipop. If you
+ * need to align CardView with other Views, you may need api version specific dimension
+ * resources to account for the changes.
* As an alternative, you can set this flag to <code>true</code> and CardView will add the same
- * padding values on platforms L and after.
+ * padding values on platforms Lollipop and after.
* <p>
* Since setting this flag to true adds unnecessary gaps in the UI, default value is
* <code>false</code>.
*
- * @param useCompatPadding True if CardView should add padding for the shadows on platforms L
- * and above.
+ * @param useCompatPadding <code>true></code> if CardView should add padding for the shadows on
+ * platforms Lollipop and above.
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardUseCompatPadding
*/
public void setUseCompatPadding(boolean useCompatPadding) {
@@ -306,13 +306,13 @@ public class CardView extends FrameLayout implements CardViewDelegate {
/**
* Updates the backward compatible elevation of the CardView.
*
- * @param radius The backward compatible elevation in pixels.
+ * @param elevation The backward compatible elevation in pixels.
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardElevation
* @see #getCardElevation()
* @see #setMaxCardElevation(float)
*/
- public void setCardElevation(float radius) {
- IMPL.setElevation(this, radius);
+ public void setCardElevation(float elevation) {
+ IMPL.setElevation(this, elevation);
}
/**
@@ -327,24 +327,24 @@ public class CardView extends FrameLayout implements CardViewDelegate {
}
/**
- * Updates the backward compatible elevation of the CardView.
+ * Updates the backward compatible maximum elevation of the CardView.
* <p>
- * Calling this method has no effect if device OS version is L or newer and
+ * Calling this method has no effect if device OS version is Lollipop or newer and
* {@link #getUseCompatPadding()} is <code>false</code>.
*
- * @param radius The backward compatible elevation in pixels.
- * @attr ref android.support.v7.cardview.R.styleable#CardView_cardElevation
+ * @param maxElevation The backward compatible maximum elevation in pixels.
+ * @attr ref android.support.v7.cardview.R.styleable#CardView_cardMaxElevation
* @see #setCardElevation(float)
* @see #getMaxCardElevation()
*/
- public void setMaxCardElevation(float radius) {
- IMPL.setMaxElevation(this, radius);
+ public void setMaxCardElevation(float maxElevation) {
+ IMPL.setMaxElevation(this, maxElevation);
}
/**
- * Returns the backward compatible elevation of the CardView.
+ * Returns the backward compatible maximum elevation of the CardView.
*
- * @return Elevation of the CardView
+ * @return Maximum elevation of the CardView
* @see #setMaxCardElevation(float)
* @see #getCardElevation()
*/
@@ -354,9 +354,9 @@ public class CardView extends FrameLayout implements CardViewDelegate {
/**
* Returns whether CardView should add extra padding to content to avoid overlaps with rounded
- * corners on API versions 20 and below.
+ * corners on pre-Lollipop platforms.
*
- * @return True if CardView prevents overlaps with rounded corners on platforms before L.
+ * @return True if CardView prevents overlaps with rounded corners on platforms before Lollipop.
* Default value is <code>true</code>.
*/
@Override
@@ -365,11 +365,11 @@ public class CardView extends FrameLayout implements CardViewDelegate {
}
/**
- * On API 20 and before, CardView does not clip the bounds of the Card for the rounded corners.
- * Instead, it adds padding to content so that it won't overlap with the rounded corners.
- * You can disable this behavior by setting this field to <code>false</code>.
+ * On pre-Lollipop platforms, CardView does not clip the bounds of the Card for the rounded
+ * corners. Instead, it adds padding to content so that it won't overlap with the rounded
+ * corners. You can disable this behavior by setting this field to <code>false</code>.
* <p>
- * Setting this value on API 21 and above does not have any effect unless you have enabled
+ * Setting this value on Lollipop and above does not have any effect unless you have enabled
* compatibility padding.
*
* @param preventCornerOverlap Whether CardView should add extra padding to content to avoid