83 Commits

Author SHA1 Message Date
rightnao
e3b255b3a0 [Docs] Crosslink github docs in javadocs
PiperOrigin-RevId: 546393704
2023-07-11 19:37:37 +00:00
dsn5ft
2b5c75f966 [Resource Inspection] Set up Android Studio resource inspection annotation and annotation processor, and add @Attribute annotation to MaterialButton#getIconPadding
PiperOrigin-RevId: 536411748
2023-05-30 15:46:52 +00:00
pfthomas
8656683639 [MaterialButtonToggleGroup][a11y] Update accessibility class name
PiperOrigin-RevId: 504557810
2023-01-26 17:09:27 +00:00
Material Design Team
3b333ee834 [Buttons] Use Layout to measure text width.
This corrects icon placement when used with Spanned text.

PiperOrigin-RevId: 483047554
2022-10-25 05:42:10 -07:00
rightnao
a601107868 [MaterialButton] Add methods to not toggle checked state on buttons on click
Resolves https://github.com/material-components/material-components-android/issues/2291

PiperOrigin-RevId: 453569861
2022-06-07 18:53:01 -07:00
conradchen
b6b895a1e4 [Button] Fix icon textStart/End alignment with multiline text
When calculating text width to decide the icon position with textStart/End alignment, we missed accounting for multiline text. Fixes this by calculating each line's width separately and take the widest one to decide the icon position.

Resolves https://github.com/material-components/material-components-android/issues/2007

PiperOrigin-RevId: 440982189
2022-04-11 17:13:57 -04:00
conradchen
19d05000bc [Button] Fix icon position with multiline text
When the icon gravity is textTop, we are using the smaller one of the calculated height from text paint and the text layout height to decide the icon position. This is wrong when there are multiple lines of text since the text paint is always single line and always shorter than the actual height.

Fixes this by returning the actual layout height whenever there are multiple lines of text to fix the issue.

Resolves https://github.com/material-components/material-components-android/issues/2619

PiperOrigin-RevId: 440923733
2022-04-11 15:12:33 -04:00
conradchen
b0f37007aa [Button] Fix icon position not being updated when size is not changed
If a button has a WRAP_CONTENT width and after its text is updated but its size does not change, the icon position won't be updated because at the moment when onTextChanged() is called, getLayout() will return null and a new layout to display text will only be recreated in the next onMeasure() call.

To fix this issue, the change moves updateIconPosition() from onSizeChanged() to onLayout(), which will always be called after onMeasure() or onSizeChanged() is called, and thus covers both of the cases after the text is updated (the button changes its size or not.)

Note: we still need to keep the updateIconPosition() call in onTextChanged(), to cover the case that the button has a fixed width, in which updating text won't trigger remeasuring of the button.

Resolves https://github.com/material-components/material-components-android/issues/2553

PiperOrigin-RevId: 427215840
2022-02-09 15:56:11 +00:00
conradchen
6c41f070e8 [Button] Support icon gravity with text alignments other than centered
Resolves https://github.com/material-components/material-components-android/issues/1371

PiperOrigin-RevId: 421605261
2022-01-18 12:02:02 -05:00
conradchen
3db25be3b6 [ButtonGroup] Simplify MaterialButtonToggleGroup's checking logic
1. Consolidates single selected ID and multiple selected IDs to a single selected
   ID set.
2. Separates View states and internal checked states so we can focus and enforce
   policies much easier on only internal states.

PiperOrigin-RevId: 420087718
2022-01-06 15:44:19 -05:00
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
dsn5ft
9ae56ceedd [Javadocs] Remove all broken attr links from Javadocs
PiperOrigin-RevId: 404246710
2021-10-20 19:06:18 +00:00
serniebanders
5844d3c134 [Button] Update icon state on Drawable state change.
Resolves: https://github.com/material-components/material-components-android/issues/2322

Follows pattern in View.drawableStateChanged() where drawable properties have states manually set.

PiperOrigin-RevId: 400754477
2021-10-05 09:04:56 -04:00
conradchen
456f135627 [Button] Fix progress indicator is not shown when set as the icon
MaterialButton is using TextViewCompat.setCompoundDrawablesRelative() under the hood to implement setIcon() operation. TextViewCompat won't call its compound drawables' setVisible() method, on which we rely to start progress indicator drawables automatically.

Calls setVisible() explicitly to start progressing.

Also adds a demo to catalog.

Resolves https://github.com/material-components/material-components-android/issues/2095

PiperOrigin-RevId: 383483364
2021-07-08 15:58:13 +00:00
dniz
25bf03ea2a [Docs] Remove broken @link from MaterialButton Javadoc
PiperOrigin-RevId: 356506184
2021-02-17 06:40:30 -08:00
hunterstich
fe58a4c81e [Button] Updated custom background warning message to be more informative.
Resolves https://github.com/material-components/material-components-android/issues/1803

PiperOrigin-RevId: 337894750
2020-10-19 11:47:05 -07:00
marianomartin
f837cb76ab [MaterialButton] Support setting vertical insets programatically
Resolves https://github.com/material-components/material-components-android/issues/526

PiperOrigin-RevId: 323450357
2020-07-28 10:28:38 -04:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
Rafael Wolf de Goes
b39845a452 Automated g4 rollback of changelist 314782767
PiperOrigin-RevId: 316867631
2020-06-17 18:40:38 -07:00
Rafael Wolf de Goes
1171418c2b Automated g4 rollback of changelist 314715132
PiperOrigin-RevId: 314782767
2020-06-05 14:49:43 -04:00
Rafael Wolf de Goes
a284edd719 [MaterialButton] Align icon on top
Resolves https://github.com/material-components/material-components-android/pull/1129

GIT_ORIGIN_REV_ID=8d663b1ca7f7bf62e1e5aa8cfc887a33bdbaf9a2
PiperOrigin-RevId: 314715132
2020-06-05 14:46:34 -04:00
Material Design Team
76ffe35fef Cleanup
PiperOrigin-RevId: 313865830
2020-06-01 16:52:06 -04:00
Material Design Team
7cfc63ed35 Fix MaterialButton$SavedState ClassNotFoundException
PiperOrigin-RevId: 313512256
2020-05-29 15:51:33 -04:00
Rafael Wolf de Goes
6455e69ba7 Automated g4 rollback of changelist 312323243
PiperOrigin-RevId: 312420120
2020-05-20 17:03:52 -04:00
Rafael Wolf de Goes
cbc46e9c8d [MaterialButton] Align icon on top
Resolves https://github.com/material-components/material-components-android/pull/1129

GIT_ORIGIN_REV_ID=8d663b1ca7f7bf62e1e5aa8cfc887a33bdbaf9a2
PiperOrigin-RevId: 312323243
2020-05-19 18:35:01 -04:00
Audrius Karosevicius
df84e91819 Automated g4 rollback of changelist 304625391
PiperOrigin-RevId: 305727309
2020-04-13 09:47:05 -07:00
Audrius Karosevicius
b7d46c4ba9 Automated g4 rollback of changelist 304610560
PiperOrigin-RevId: 304625391
2020-04-03 10:11:25 -07:00
Audrius Karosevicius
a6c0c4c53a [MaterialButton] Save state
Resolves https://github.com/material-components/material-components-android/pull/1123

GIT_ORIGIN_REV_ID=56600d14c8bab0932f3b3569c94d548d1c1523f2
PiperOrigin-RevId: 304610560
2020-04-03 10:06:26 -07:00
isabellekim
309d71860f Respect android:background attribute for MaterialButton.
PiperOrigin-RevId: 303732939
2020-03-30 15:52:26 -04:00
marianomartin
115313c0c0 Expose a class for themeoverlay in style
This moves functionality from ThemeEnforcement into a stand alone class.

Resolves https://github.com/material-components/material-components-android/issues/665

PiperOrigin-RevId: 275481343
2019-10-21 10:24:19 -04:00
Sam
a610215b77 [MaterialButton] Fixed issue 531 by removing unnecessary calls to set compound drawables
Resolves https://github.com/material-components/material-components-android/pull/589

GIT_ORIGIN_REV_ID=3f167e1a3f5a369fc3bfda152f28b80c3cb25181
PiperOrigin-RevId: 270331104
2019-09-24 12:17:58 -04:00
marianomartin
215a839598 Internal cleanup
PiperOrigin-RevId: 267504117
2019-09-12 13:48:16 -04:00
Connie
9ed90216a3 Revert "Fixed issue 531 by removing unnecessary calls to set compound drawables"
This reverts commit faf60b15bea73588e8c76fc348ace50dd430cf55.
2019-08-29 15:55:46 -04:00
Connie
b814e8ef74 Revert "Changed naming"
This reverts commit b467b494d9f87581c20009706bce4dc9a7cb8c44.
2019-08-29 15:55:46 -04:00
Sam
b467b494d9 Changed naming 2019-08-29 15:53:24 -04:00
Sam
faf60b15be Fixed issue 531 by removing unnecessary calls to set compound drawables 2019-08-29 15:53:24 -04:00
cketcham
7bb525ff59 Update usages of ShapeAppearanceModel to use Builder pattern
PiperOrigin-RevId: 266144471
2019-08-29 15:39:51 -04:00
marianomartin
0d4515cb46 Internal cleanup
PiperOrigin-RevId: 265971745
2019-08-29 14:59:20 -04:00
cketcham
1068e1029d Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 264899198
2019-08-26 14:40:54 -04:00
marianomartin
164bf0fabd Internal cleanup
PiperOrigin-RevId: 255609320
2019-07-03 14:02:53 -04:00
dniz
5df3bebd63 Update elevation overlays to be based absolute elevation, factoring in the elevation of all parent views
Will follow-up with TabLayout absolute elevation separately

Resolves https://github.com/material-components/material-components-android/issues/381

PiperOrigin-RevId: 255404830
2019-07-03 13:55:49 -04:00
gauthams
dbbf2c6eec Add additional info to Javadoc for MaterialButton's setShapeAppearanceModel method
PiperOrigin-RevId: 249091100
2019-05-21 12:12:52 -04:00
Material Design Team
32a28f5acf Annotate arg MaterialButton.setIcon(@Nullable)
PiperOrigin-RevId: 245728195
2019-04-29 15:59:08 -07:00
gauthams
71048025ef Update MaterialButton documentation to clarify usage of '.Icon' styles
PiperOrigin-RevId: 245317272
2019-04-29 15:52:46 -07:00
cketcham
e081f9d005 Use platform widget classes for the a11y class name
PiperOrigin-RevId: 245300502
2019-04-29 15:44:22 -07:00
gauthams
c42eb1e239 Add support for end-aligned iconGravity in MaterialButton
PiperOrigin-RevId: 244431572
2019-04-19 22:07:04 -04:00
gauthams
d5bbc9cf43 Implement Shapeable interface in MaterialButton
PiperOrigin-RevId: 242559479
2019-04-19 13:00:59 -04:00
gauthams
3f2d205344 Log a warning rather than an info when setting background on a MaterialButton.
PiperOrigin-RevId: 239880506
2019-03-26 17:29:07 -04:00
dniz
833258417d Add @RequiresApi(VERSION_CODES.LOLLIPOP) to overriden setElevation() methods
that call super.setElevation()

PiperOrigin-RevId: 239171863
2019-03-22 16:50:21 -04:00