179 Commits

Author SHA1 Message Date
leticiars
c7c5c7c625 [TextInputLayout] Fixed calculateLabelMarginTop() value for filled text field style, which caused getBaseline() to return a wrong offset.
PiperOrigin-RevId: 408655451
2021-11-10 16:06:08 -05:00
leticiars
dca7fc0701 [TextInputLayout][a11y] Fixed RTL support for setting corner radius on TextInputLayout.
PiperOrigin-RevId: 408621523
2021-11-10 16:03:01 -05:00
Material Design Team
aaac96d724 [TextField] Fix helper text label for usage
The setLabelFor calls were made in the call to populate the accessibility node but they were made after calling super (one of them was actually nested inside of a getter!), this is too late, the accessibility node is populated with the label for by the super class

PiperOrigin-RevId: 407178334
2021-11-04 10:52:21 -04:00
leticiars
9d2f864f0a [TextInputLayout] Fixed getBoxCornerRadiusBottomEnd and getBoxCornerRadiusBottomStart returning wrong values.
PiperOrigin-RevId: 406360531
2021-10-29 18:48:29 +00:00
leticiars
3ca3b71bb2 [TextInputLayout] Don't add placeholder view to text field's input frame if placeholder is null.
PiperOrigin-RevId: 406129696
2021-10-28 18:50:16 +00:00
leticiars
20c3ad0413 [a11y][TextInputLayout] Removed TextInputLayout's placeholder text duplicated announcement.
Before, when swiping with TalkBack on, the placeholder text would be mistakenly announced. This change makes it so it's only announced when it appears, for API >= 16. It's still announced as part of the description announcement when the text field is selected, as before, so it's still accessible for APIs < 16.

PiperOrigin-RevId: 405668594
2021-10-27 18:54:35 +00:00
Material Design Team
8bf3bdeb8a Automated g4 rollback of changelist 404871534
PiperOrigin-RevId: 404899483
2021-10-25 16:08:53 +00:00
leticiars
2701161bbd [a11y][TextInputLayout] Removed TextInputLayout's placeholder text duplicated announcement, and fixed edge case where placeholder text was being enabled and added to the input frame while it was set to null.
Before, when swiping with TalkBack on, the placeholder text would be mistakenly announced. This change makes it so it's only announced when it appears, for API >= 16. It's still announced as part of the description announcement when the text field is selected, as before, so it's still accessible for APIs < 16.

PiperOrigin-RevId: 404871534
2021-10-25 16:07:47 +00:00
Material Design Team
01c1fc723d Automated g4 rollback of changelist 404266249
PiperOrigin-RevId: 404294350
2021-10-20 19:11:30 +00:00
conradchen
d10c75b357 [TextField] Fix collapsed hint cutout is not correctly applied
The box background of text fields are applied to EditTexts instead of the TextInputLayout. So when there are paddings in TextInputLayout, we will need to adjust cutout bounds, which is calculated based on TextInputLayout's coordinates, according to the paddings.

PiperOrigin-RevId: 404281248
2021-10-20 19:09:50 +00:00
leticiars
aa58657042 [a11y][TextInputLayout] Removed TextInputLayout's placeholder text duplicated announcement.
Before, when swiping with TalkBack on, the placeholder text would be mistakenly announced. This change makes it so it's only announced when it appears, for API >= 16. It's still announced as part of the description announcement when the text field is selected, as before, so it's still accessible for APIs < 16.

PiperOrigin-RevId: 404266249
2021-10-20 19:07:29 +00:00
conradchen
79ae9b1351 [TextInputLayout] Create label cutout only on borders
When a collapsed label is showing, we cutout part of the border of an outlined text input box according to the exact stroke width. However when using rounded corners, there can be slight offsets from where the border is really drawn. Also, if the corner size is large, the part of border we need to cutout might not just be a straight line but contains part of the corner.

However, with the existing cutout logic, we cannot just cutout the whole label area, which will cause the area inside the border also gets cutout, if it has color. This CL changes the cutout drawing logic to only apply the cutout on stroke drawing to fix the issue.

This CL also fixes the bug that when the label is too long, we didn't take the ellipsized text length into account. Creates a variable to store the calculated collapsed text width to fix the issue.

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

PiperOrigin-RevId: 402316057
2021-10-12 11:26:21 -04:00
Natalia Kuznetsova
cdeeb824cb [TextInputLayout] Adding getter and setter for boxCollapsedPaddingTop
Resolves https://github.com/material-components/material-components-android/pull/2289

GIT_ORIGIN_REV_ID=50ec191fbca0e2223ac322adb3f36035186b4bca
PiperOrigin-RevId: 391122971
2021-08-16 13:49:38 -07:00
jeremymuhia
10edc29b4f [TextInputLayout] fix counterTextColor java docs
PiperOrigin-RevId: 390602431
2021-08-16 13:43:10 -07:00
pfthomas
47868d884e [DatePicker] Date selector hint incorrectly localized
PiperOrigin-RevId: 387066584
2021-07-29 14:28:10 -04:00
conradchen
4044183f46 [TextInputLayout] Apply tint when setting start icons
If startIconTint is a plain color, refreshStartIconDrawableState() won't update the tint to the new drawable. To solve the issue and make the logic be consistent, calls applyStartIconTint() when a new icon is set.

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

PiperOrigin-RevId: 383632467
2021-07-08 15:59:37 +00:00
conradchen
717774ec7f [TextField] Do not load default drawable if custom end icon is being used
Resolves https://github.com/material-components/material-components-android/issues/2085

PiperOrigin-RevId: 382785324
2021-07-07 19:21:28 +00:00
afohrman
c92e6934d5 [TextInputLayout] Added a fade transition to placeholder TextView's appear and disappear.
The placeholder TextView previously appeared and disappeared with no fade, which led to a jarring effect and an overlap between the hint text and the placeholder text.

PiperOrigin-RevId: 373713144
2021-05-14 15:29:49 -04:00
leticiars
87b50c6aee [TextInputLayout] Fixed cutout padding so text field outline doesn't overlap collapsed hint.
Resolves https://github.com/material-components/material-components-android/issues/2127

PiperOrigin-RevId: 372563674
2021-05-07 12:27:01 -04:00
leticiars
73bf653ef2 Automated g4 rollback of changelist 372177002
PiperOrigin-RevId: 372384266
2021-05-07 12:16:55 -04:00
leticiars
66b0c98a27 [TextInputLayout] Fixed cutout padding so text field outline doesn't overlap collapsed hint.
Resolves https://github.com/material-components/material-components-android/issues/2127

PiperOrigin-RevId: 372177002
2021-05-05 15:41:30 -04:00
leticiars
f97560d8a8 [TextInputLayout][Large Screens] Adding setMinWidth and setMaxWidth methods on the TextInputLayout so it works as expected.
PiperOrigin-RevId: 366041873
2021-03-31 11:57:04 -04:00
leticiars
6015a4e901 [TextInputLayout] Adjusted background of collapsed hint to not overlap with edit text's background.
Resolves https://github.com/material-components/material-components-android/pull/1660
Resolves https://github.com/material-components/material-components-android/issues/1319

PiperOrigin-RevId: 353645196
2021-01-25 09:25:00 -08:00
leticiars
40e33a772c [TextInputLayout][a11y] Fixed placeholder text not being properly announced.
PiperOrigin-RevId: 346578367
2020-12-09 15:00:22 -05:00
leticiars
c8197e3a26 [Text fields] Updated text fields measurements to match spec.
- updated top and bottom padding (updating the heights) except of dense outlined
- updated start and end paddings of layout and helper/error/counter view area
- updated label position of filled
- added padding between prefix/suffix and text input

PiperOrigin-RevId: 334955916
2020-10-08 15:43:54 +00:00
leticiars
22973ff103 [TextFields] Added expandedHintEnabled attribute (true by default). If set to false it allows for the hint to always be in its collapsed state.
If false it also allows for the placeholder text and prefix/suffix to be displayed when the text field is empty.

Resolves https://github.com/material-components/material-components-android/issues/1459
Resolves https://github.com/material-components/material-components-android/issues/1644
Resolves https://github.com/material-components/material-components-android/pull/1645
Resolves https://github.com/material-components/material-components-android/pull/1163

PiperOrigin-RevId: 331181181
2020-09-11 14:52:40 -04:00
Gabriele Mariotti
b48b445fb8 [TextInputLayout] Fixed wrong hint position when an error is shown and field is empty and unfocused
Resolves https://github.com/material-components/material-components-android/pull/1661

GIT_ORIGIN_REV_ID=8eccce1bee2f331b1441540985435cefe4e40b67
PiperOrigin-RevId: 330956944
2020-09-11 14:24:34 -04:00
Material Design Team
fc1208f4a4 [TextInputLayout] Allow hint text set in TextInputLayout to be passed on to the Autofill service
Resolves https://github.com/material-components/material-components-android/issues/1412

PiperOrigin-RevId: 330780010
2020-09-10 11:13:38 -04:00
Gabriele Mariotti
076ff69343 [TextInputLayout] Added hintText, helperText, placeholderText to restoreInstanceState
Resolves https://github.com/material-components/material-components-android/pull/1629
Resolves https://github.com/material-components/material-components-android/issues/1384

GIT_ORIGIN_REV_ID=3c3ac47f054e7c1f8ae7b7459337f094bfdbe56a
PiperOrigin-RevId: 329741165
2020-09-09 11:21:42 -04:00
momt99
ee93fc15c4 [TextInputLayout] Added id for errorIconView
Resolves https://github.com/material-components/material-components-android/pull/1624
Resolves https://github.com/material-components/material-components-android/issues/1623

GIT_ORIGIN_REV_ID=acf854dc995d734383ed25689b8efd7606f75537
PiperOrigin-RevId: 327673226
2020-08-20 16:48:23 -04:00
leticiars
bc4c6e47ae [TextFields] Adjusted label position and edit text padding of filled text field for large font support. Also removed margin of icons when font is large.
PiperOrigin-RevId: 326486771
2020-08-13 16:50:06 -04:00
Gabriele Mariotti
fcea6e8ab2 [TextInputLayout] Added method to set hint with a String resource
Resolves https://github.com/material-components/material-components-android/issues/959
Resolves https://github.com/material-components/material-components-android/pull/1598

GIT_ORIGIN_REV_ID=c156ad372ca4055f70a7021db89d91b915db8b4c
PiperOrigin-RevId: 326249688
2020-08-12 14:19:57 -04:00
leticiars
7b5aea2ca3 [TextInputLayout] Fixed padding for prefix/suffix and label in RTL being wrong.
PiperOrigin-RevId: 319873647
2020-07-07 10:57:16 -04:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
leticiars
b274a4aa32 [TextInputLayout][a11y] Changing hint announcement.
* To make announcements clearer, removed helper text from hint announcement.
* Calling setLabelFor on helper text view so it's clear it refers to the edit text visually above it.
* Calling setError is enough to let the screen reader decide how to announce the error.

PiperOrigin-RevId: 317651946
2020-06-26 13:59:00 -04:00
Material Design Team
342ea9ad25 Internal cleanup
PiperOrigin-RevId: 317147378
2020-06-19 13:42:35 -04:00
Material Design Team
073382034a Migrate android.support.v4.content.ContextCompat to androidx
Android X migration

PiperOrigin-RevId: 315791679
2020-06-11 17:27:51 -07:00
leticiars
9b0a8d90e6 [TextInputLayout] Fixed clear icon and placeholder text being displayed when the text field is initialized with input text.
Resolves https://github.com/material-components/material-components-android/issues/1379

PiperOrigin-RevId: 315317199
2020-06-08 16:28:34 -04:00
leticiars
855602bb4f [TextInputLayout] Fixed icon tint not being applied properly when calling set*IconDrawable
Resolves https://github.com/material-components/material-components-android/issues/1142

PiperOrigin-RevId: 314965854
2020-06-05 14:58:39 -04:00
Material Design Team
76ffe35fef Cleanup
PiperOrigin-RevId: 313865830
2020-06-01 16:52:06 -04:00
leticiars
8a5c95c7b9 [TextInputLayout] Fixing crash when calling setBoxCornerRadii when edit text hasn't been added yet.
Resolves https://github.com/material-components/material-components-android/issues/1192

PiperOrigin-RevId: 312517954
2020-05-20 17:13:45 -04:00
leticiars
e315754617 [TextInputLayout] Fixing end icon having unexpected behaviors when it's switched from another end icon mode.
Resolves https://github.com/material-components/material-components-android/issues/503

PiperOrigin-RevId: 312129467
2020-05-19 10:06:36 -04:00
Rafael Wolf de Goes
33700b0cd3 [TextInputLayout] Fix: merge icon and view state when setting icon color.
Resolves https://github.com/material-components/material-components-android/pull/1237
Resolves https://github.com/material-components/material-components-android/issues/1235
Resolves https://github.com/material-components/material-components-android/issues/879

GIT_ORIGIN_REV_ID=186c8f0786b57c406694501389ba31c91bc128e2
PiperOrigin-RevId: 310460890
2020-05-08 15:19:02 -04:00
leticiars
e5a85a227a [TextInputLayout] Adding setBoxBackgroundColorStateList method and fixing setBoxBackgroundColor method not changing focused and hovered states color like it did originally.
Resolves https://github.com/material-components/material-components-android/issues/1191

PiperOrigin-RevId: 308275897
2020-04-24 21:51:34 -04:00
leticiars
167020a596 [TextInputLayout] Adding setters and getters for boxStrokeWidth and boxStrokeWidthFocused attrs.
PiperOrigin-RevId: 308059511
2020-04-23 20:10:31 -04:00
Kirill Olenyov
1b124afa02 [TextInputLayout] Add click listener for error icon
Resolves https://github.com/material-components/material-components-android/pull/1215

GIT_ORIGIN_REV_ID=f2ae41512162b09c4e37fa727b465970eb83f2b1
PiperOrigin-RevId: 307624385
2020-04-22 15:06:21 -04:00
leticiars
2df71d156b [TextInputLayout] Fixing counter RTL not working for all languages.
PiperOrigin-RevId: 305286488
2020-04-09 05:19:45 -07:00
leticiars
a3d356fdb4 [TextInputLayout] Fixing placeholder not respecting edit text's gravity.
Resolves: https://github.com/material-components/material-components-android/issues/1139
PiperOrigin-RevId: 304037224
2020-04-03 08:53:49 -07:00
leticiars
c86a61c3ba Updating javadocs for TextInputLayout
PiperOrigin-RevId: 300414100
2020-03-13 10:50:34 -04:00
leticiars
a040af5bd3 [TextInputLayout] Fixing vertical gravity set on edit text being ignored for the expanded hint.
Resolves https://github.com/material-components/material-components-android/issues/933

PiperOrigin-RevId: 292015744
2020-01-29 16:12:04 -05:00