44 Commits

Author SHA1 Message Date
pekingme
b9a2ce93c1 Automated g4 rollback of changelist 650718631
PiperOrigin-RevId: 651858394
2024-07-22 18:23:58 +00:00
pekingme
2799892b5e [Shape] Added state list support to shape appearance and corner size.
PiperOrigin-RevId: 650718631
2024-07-10 19:21:00 +00:00
pekingme
fb4761cc20 [ButtonToggleGroup] Added APIs to customize inside spacing and corner size between buttons.
PiperOrigin-RevId: 628469557
2024-04-29 19:03:54 +00:00
Material Design Team
44cc9b745c Add @CanIgnoreReturnValue to some APIs that return this.
PiperOrigin-RevId: 468721442
2022-08-22 15:22:27 -04:00
conradchen
3fa48d4cd5 [Shape] Workaround the issue that Context.obtainStyledAttributes() doesn't handle @macro properly
Somehow Context.obtainStyledAttributes() with a provided style resource crashes if some attributes in the style are resolved to be macros. Using ContextThemeWrapper to wrap the context with the style doesn't have this issue. Workarounds this by always wrapping the context to retrieve attributes.

PiperOrigin-RevId: 445451176
2022-04-29 14:50:17 -04:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
dniz
ab54c23e9b Fix MaterialShapeDrawable stroke corner bug
PiperOrigin-RevId: 272977992
2019-10-04 20:09:24 -04:00
ldjesper
294f12498d Rename setCornerRadius to setAllCornerSizes
PiperOrigin-RevId: 272959729
2019-10-04 20:08:43 -04:00
cketcham
a130a0c3e0 Add support for percentages to ShapeAppearanceModel
PiperOrigin-RevId: 272946740
2019-10-04 16:33:47 -04:00
cketcham
0547d2a06b Uncouple CornerSize from CornerTreatment
This allows for more easily updating the CornerSize independently from the CornerTreatment and makes it possible to create different types of CornerSizes such as percentage based corners. However, this means corner sizes can be different depending on the bounds of the shape, so the bounds need to be provided. MaterialShapeDrawable has bounds and the ShapeAppearanceModel, so there are new convenience methods there which return the current corner size for the current bounds of the drawable.

PiperOrigin-RevId: 272908508
2019-10-04 15:23:16 -04:00
cketcham
ab59d93064 Update corner size for builder to use floats
PiperOrigin-RevId: 271428842
2019-09-26 17:57:33 -04:00
cketcham
d993425201 Update ShapeAppearanceModel javadoc to correctly specify that an instance is returned, not the builder.
PiperOrigin-RevId: 269363772
2019-09-18 14:16:09 -04:00
cketcham
27b58f1611 Make ShapeAppearanceModel immutable
PiperOrigin-RevId: 266378228
2019-09-04 14:20:35 -04:00
cketcham
ca91442ba2 Add builder to ShapeAppearanceModel
PiperOrigin-RevId: 265806696
2019-08-29 12:21:55 -04:00
cketcham
1538729814 Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 265057078
2019-08-29 10:28:12 -04:00
afohrman
ab87dd51fb Add shaped selected item background to NavigationView and update the item background color.
PiperOrigin-RevId: 247490949
2019-05-16 12:38:14 -04:00
gauthams
163c0ed3f5 Update ExtendedFAB to support setting corner radius via shape appearance
PiperOrigin-RevId: 243677036
2019-04-19 21:07:37 -04:00
Material Design Team
a13ff980a5 Automated g4 rollback of changelist 241720142
PiperOrigin-RevId: 241804673
2019-04-05 15:48:38 -04:00
Material Design Team
264e816f56 * Add selected (Active) item default background to NavigationView - introducing seven itemShape* attributes for this purpose
PiperOrigin-RevId: 241720142
2019-04-05 15:43:56 -04:00
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
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