24 Commits

Author SHA1 Message Date
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
03cf027bc7 Deprecate Experimental annotation and remove from Shapes
PiperOrigin-RevId: 229200655
2019-01-18 14:10:16 -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
cketcham
7a2c2823ee Only recalculate the path if it has changed
PiperOrigin-RevId: 223826749
2018-12-06 11:47:06 -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
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
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
isabellekim
3bc3cc9cbf Stop modifying the DEFAULT_CORNER_TREATMENT in ShapeAppearanceModel.
PiperOrigin-RevId: 220688536
2018-11-16 11:06:53 -05:00
marianomartin
85bec581d7 Add a constructor that takesdefault cornersize in ShapeAppearanceModel
PiperOrigin-RevId: 219308037
2018-11-01 16:11:12 -07:00
marianomartin
e192fbe3e0 Use round rect when possible in MSD
PiperOrigin-RevId: 218559377
2018-10-28 19:12:46 -04:00
gauthams
17ffd91b6c Add cornerRadius setter to MaterialShapeDrawable.
PiperOrigin-RevId: 217643698
2018-10-28 18:28:07 -04:00
connieshi
aa88e62b30 Initialize all corner and edge treatment fields in the class declaration.
Do not call this() in ShapeAppearanceModel's overloaded constructor.

PiperOrigin-RevId: 215433426
2018-10-11 17:57:42 -04:00
connieshi
e7e6c6fbe0 Call the default ShapeAppearanceModel constructor from its overloaded constructor to ensure that all edge and corner treatments are initialized with a default value.
PiperOrigin-RevId: 215398454
2018-10-02 14:57:13 -04:00
cketcham
3de44ca7ac Add shapes theming infrastructure.
Add shapeAppearance and shapeAppearanceOverlay attributes. These attributes combine to support shapes theming. ShapeAppearance is modeled after TextAppearance. A shapeAppearance attribute contains a style reference that is meant to be defined at the theme level. Since changing anything defined in the shapeAppearance would clobber everything else in the ShapeAppearance, the shapeAppearanceOverlay attribute is provided for clients to modify the shapeAppearance.

PiperOrigin-RevId: 215273652
2018-10-02 14:53:40 -04:00
Material Design Team
a681567504 Automated g4 rollback of changelist 215242636
PiperOrigin-RevId: 215260729
2018-10-02 14:52:47 -04:00
cketcham
432b46cc83 Add shapes theming infrastructure.
Add shapeAppearance and shapeAppearanceOverlay attributes. These attributes combine to support shapes theming. ShapeAppearance is modeled after TextAppearance. A shapeAppearance attribute contains a style reference that is meant to be defined at the theme level. Since changing anything defined in the shapeAppearance would clobber everything else in the ShapeAppearance, the shapeAppearanceOverlay attribute is provided for clients to modify the shapeAppearance.

PiperOrigin-RevId: 215242636
2018-10-02 14:21:40 -04:00
cketcham
8bd94e9276 Rename ShapePathModel to ShapeAppearanceModel.
This commit renames ShapePathModel to ShapeAppearanceModel to align with the new shapeAppearance attributes that will be added for shape theming.

PiperOrigin-RevId: 214818189
2018-09-28 16:30:13 -04:00