82 Commits

Author SHA1 Message Date
afohrman
17195e41d1 Add documentation to public methods in ShapeAppearanceModel.
Some public methods were missing documentation.

Also remove unnecessary hyphenation from methods that used hyphenation to describe the corner treatment positioning (ex: top-left -> top left).

PiperOrigin-RevId: 239882358
2019-03-26 17:31:59 -04:00
marianomartin
fd01672af5 Fix nullness in FAB
PiperOrigin-RevId: 238990635
2019-03-22 16:21:40 -04:00
afohrman
ca07e5f616 Create OnChangedListener to respond to ShapeAppearanceModel changes and Shapeable interface, and implement it in Chip.
The OnChangedListener provides a callback that MaterialShapeDrawables can use to invalidate themselves when the associated ShapeAppearanceModel changes. This allows for modifying the ShapeAppearanceModel through the get/setShapeAppearance methods that the Shapeable interface exposes without having to update the client to redraw itself.

PiperOrigin-RevId: 238703600
2019-03-22 16:16:23 -04:00
dniz
6adba8f93b Fix MaterialShapeDrawable to work with ColorStateLists for fill and stroke tint
and paint

PiperOrigin-RevId: 238478987
2019-03-22 16:09:16 -04:00
dniz
7b594393c8 Dark Theme Elevation Overlay system
PiperOrigin-RevId: 237829773
2019-03-22 16:02:26 -04:00
marianomartin
01874ad4e9 Change setElevation in MSD to use default offset
PiperOrigin-RevId: 236858323
2019-03-08 09:58:58 -05:00
dniz
c0de00cdac Fix MaterialShapeDrawable bug that causes compat shadows to be drawn for round rects on lollipop+
PiperOrigin-RevId: 235786787
2019-02-27 18:00:21 -05:00
dniz
11df79f95c Clean up Gradle build shorthands for appcompat/androidx libraries
PiperOrigin-RevId: 229369959
2019-01-18 14:13:26 -05:00
dniz
03cf027bc7 Deprecate Experimental annotation and remove from Shapes
PiperOrigin-RevId: 229200655
2019-01-18 14:10:16 -05:00
marianomartin
2c1d3d99e0 Fix deprecated getEdgePath method
PiperOrigin-RevId: 229195616
2019-01-18 14:09:20 -05:00
dniz
a4964594a1 Add MaterialShapeDrawable setElevation(float) and deprecate setShadowElevation(int)
PiperOrigin-RevId: 228572421
2019-01-10 17:16:43 -05:00
gauthams
32db2e2af1 Update shape path edge length to prevent concave path
PiperOrigin-RevId: 228238196
2019-01-10 16:35:58 -05:00
marianomartin
c4f014b192 Add back getPathForSize(int int, Path) to MaterialShapeDrawable.
PiperOrigin-RevId: 227901559
2019-01-10 16:27:32 -05:00
marianomartin
7adbeac4b2 Add back getEdgePath method without interpolation
PiperOrigin-RevId: 227877153
2019-01-10 16:07:46 -05:00
afohrman
db4c951c0c Add annotations to hide protected MaterialShapeDrawable#drawShape() method.
MaterialShapeDrawable#drawShape() is protected, so it shouldn't be visible outside of the library group. This commit also adds documentation, since this method is protected.

PiperOrigin-RevId: 227696166
2019-01-10 16:01:24 -05:00
cketcham
dc72aaeed4 Migrate Gradle build and sources to androidx
PiperOrigin-RevId: 225551505
2018-12-21 11:07:45 -05:00
melaniegoetz
403973284e Automated g4 rollback of changelist 224522042
PiperOrigin-RevId: 225060461
2018-12-12 16:23:30 -05:00
melaniegoetz
73f7681101 Automated g4 rollback of changelist 224370498
PiperOrigin-RevId: 224522042
2018-12-10 14:15:46 -05:00
melaniegoetz
16822d6344 Shape Theming for BottomSheet
PiperOrigin-RevId: 224370498
2018-12-10 14:14:05 -05:00
marianomartin
cf69538c9c Refactor path logic out of MSD
PiperOrigin-RevId: 224182175
2018-12-06 12:05:06 -05:00
marianomartin
61f426afca Remove (get/set)PaintFlags from MSD
PiperOrigin-RevId: 224162294
2018-12-06 12:04:30 -05:00
cketcham
7a2c2823ee Only recalculate the path if it has changed
PiperOrigin-RevId: 223826749
2018-12-06 11:47:06 -05:00
marianomartin
d75fb6513c Fix constant state in MSD
PiperOrigin-RevId: 223802087
2018-12-06 11:46:29 -05:00
afohrman
cf5e35c624 Turn off theme enforcement for ShapeAppearanceModel.
ShapeAppearanceModel doesn't support theme attributes, so it doesn't make sense to check for our theme in the style reference when creating it.

PiperOrigin-RevId: 223796338
2018-12-06 11:46:00 -05:00
Material Design Team
f152b75e1a Automated g4 rollback of changelist 223558824
PiperOrigin-RevId: 223564801
2018-12-06 11:43:02 -05:00
marianomartin
c75482b473 Fix constant state in MSD
PiperOrigin-RevId: 223558824
2018-12-06 11:42:42 -05:00
marianomartin
bf024ebed9 Remove stroke shader from MSD
PiperOrigin-RevId: 223397575
2018-12-06 11:38:24 -05:00
marianomartin
3bf777db8a Implement Mutate in MaterialShapeDrawable
PiperOrigin-RevId: 223059565
2018-12-06 11:31:50 -05:00
isabellekim
71891af8df Add shape appearance attributes to MaterialCardView. This maintains current behavior of stroke width / content padding.
When content can be clipped to the shape (round rect, Lollipop+), the content will be clipped to the interior of the stroke.

When preventCornerOverlap is true, if the content cannot be clipped, extra padding is added such that the entirety of the content is inside the stroke. Any contentPadding is additional to this padding. In order to keep centered content centered, the same amount of padding is added in each direction when preventCornerOverlap is true.

PiperOrigin-RevId: 223045615
2018-12-06 11:25:27 -05:00
cketcham
95cf55f04b Remove option to use paint shadow
PiperOrigin-RevId: 223017988
2018-12-06 11:25:01 -05:00
isabellekim
ab48110097 Rolling back changes to support shape theming in MaterialCardView.
PiperOrigin-RevId: 222467563
2018-12-06 11:21:22 -05:00
isabellekim
46e18968d7 Add shape theme to MaterialCardView.
When content can be clipped to the shape (round rect, Lollipop+), the content will be clipped to the interior of the stroke.

When preventCornerOverlap is true, if the content cannot be clipped, extra padding is added such that the entirety of the content is inside the stroke. Any contentPadding is additional to this padding. In order to keep centered content centered, the same amount of padding is added in each direction when preventCornerOverlap is true.

PiperOrigin-RevId: 222456398
2018-12-06 11:20:48 -05:00
afohrman
c6b554555b Use deep copies for CornerTreatment and EdgeTreatment convenience methods in
ShapeAppearanceModel.

Prior to this change, ShapeAppearanceModel#setAllCorners() and
ShapeAppearanceModel#setAllEdges() set all four corners or edges to the same
CornerTreatment or EdgeTreatment. This change creates deep copies for each
corner/edge treatment to avoid bugs caused by silently reusing the mutable
object.

PiperOrigin-RevId: 222413898
2018-12-06 11:19:04 -05:00
afohrman
98d4b148d1 Create deep copies of CornerTreatments and EdgeTreatments in ShapeAppearanceModel's copy constructor.
Implement Cloneable and override Object#clone() to create deep copies of the corner and edge treatments. The Cloneable method is generally discouraged, but this solution appears to be the most effective solution for our use case because:

- CornerTreatment and EdgeTreatment don't contain mutable fields, so using the native Object#clone() should be fine. This allows us to avoid intervening in the clone() method, which is one of the main reasons to avoid using Obect#clone().
- Since we have to maintain binary compatibility with our 1.0.0 stable release, we have very little wiggle room with which to ensure that we have effective copy() methods in each subclass of CornerTreatment and EdgeTreatment.

PiperOrigin-RevId: 222311453
2018-12-06 11:17:48 -05:00
afohrman
a10070b6b3 Unify the creation of default CornerTreatments and EdgeTreatments.
Change the default CornerTreatment created in MaterialShapeUtils from CornerTreatment() to RoundedCornerTreatment(0). This matches the default previously created from ShapeAppearanceModel constructors.

This change unifies the defaults created in ShapeAppearanceModel's constructors with the default created by MaterialShapeUtils, by converging the two default corner and edge treatment creation methods into one method in MaterialShapeUtils. That method is then called from MaterialShapeUtils#createCornerTreatment#createCornerTreatment() and ShapeAppearanceModel's constructors.

This change also renames getDefaultCornerTreatment() to createDefaultCornerTreatment() to convey that the method instantiates an object.

PiperOrigin-RevId: 222269551
2018-12-06 11:15:10 -05:00
cketcham
ab61f4c50a Restrict access to setting the vertical offset for the shadow.
I think we may want to remove these methods in the future and just handle this automatically.

PiperOrigin-RevId: 220944239
2018-11-16 11:19:10 -05:00
isabellekim
3bc3cc9cbf Stop modifying the DEFAULT_CORNER_TREATMENT in ShapeAppearanceModel.
PiperOrigin-RevId: 220688536
2018-11-16 11:06:53 -05:00
isabellekim
2997b6995f Add shadow compat support for cut corners and triangle edge treatments, updating ShapePath to add extra shadow arcs when needed:
+ Updates LineShadowOperation to call drawEdgeShadow with a horizontal edge
+ ShapePath has a start & end shadow angle and will add shadow arcs to fill in gaps between shadow operations

PiperOrigin-RevId: 219686107
2018-11-01 16:22:14 -07:00
cketcham
3d8e2b408c Stop expanding the clip rect on versions of android that have native shadow support
PiperOrigin-RevId: 219478262
2018-11-01 16:17:19 -07:00
isabellekim
e9a8d48f60 Fixes MaterialShadowDrawable shadow to respect bounds that don't start at (0,0)
PiperOrigin-RevId: 219367777
2018-11-01 16:15:40 -07:00
cketcham
22cd4dba4f Prevent invalidating MaterialShapeDrawable if parameters haven't changed
PiperOrigin-RevId: 219319784
2018-11-01 16:13:36 -07:00
afohrman
a25e13ca39 Update isStateful() method in MaterialShapeDrawable.
isStateful() should include the statefulness of the fill and stroke colors.

PiperOrigin-RevId: 219310584
2018-11-01 16:11:35 -07:00
marianomartin
85bec581d7 Add a constructor that takesdefault cornersize in ShapeAppearanceModel
PiperOrigin-RevId: 219308037
2018-11-01 16:11:12 -07:00
afohrman
ed37888efe Remove MaterialShapeDrawable hairline inset from fill bounds.
PiperOrigin-RevId: 219303758
2018-11-01 16:09:21 -07:00
connieshi
d9d9b6e1ef Change scope of #getFillBounds to protected so children can override it.
PiperOrigin-RevId: 219227988
2018-11-01 16:08:38 -07:00
connieshi
0f764e9a15 Change scope of #getBoundsAsRectF and #drawShape to be protected so the children of MSD could call them.
PiperOrigin-RevId: 219189920
2018-11-01 16:08:10 -07:00
afohrman
38ef896da2 Adjust corners of MaterialShapeDrawable's stroke to draw the stroke perfectly over the fill.
To draw the stroke with the correct corner radius, MaterialShapeDrawable now calculates what the corner radius should be and adjusts the stroke accordingly.

Before this change, the corner radius was calculated such that the stroke didn't fully reach the edges of the shape. This change tweaks the corner radius calculation so that the stroke's path matches the fill's path and is overlaid directly on top of the fill's shape.

PiperOrigin-RevId: 219139586
2018-11-01 16:04:35 -07:00
cketcham
3bc7afd292 Disable native shadows when compat shadows are always drawn.
PiperOrigin-RevId: 219134990
2018-11-01 16:04:08 -07:00
afohrman
52eb143e99 Optimize stroke inset bounds method.
Use RectF#inset() instead of manually insetting the stroke by half of the stroke width.

PiperOrigin-RevId: 218887035
2018-10-28 21:47:13 -04:00
cketcham
560c982284 Enable shadows for BottomAppBar
PiperOrigin-RevId: 218868156
2018-10-28 21:44:27 -04:00