204 Commits

Author SHA1 Message Date
rightnao
633b3cecfa [TextInputLayout] Adding set/get methods to control minimum width and height for start/end icons
Resolves https://github.com/material-components/material-components-android/issues/2080

PiperOrigin-RevId: 461939723
2022-07-20 21:44:40 +00:00
pubiqq
15fa4db616 [TextInputLayout] Fix "android:enabled" attribute support
Resolves https://github.com/material-components/material-components-android/issues/2766
Resolves https://github.com/material-components/material-components-android/pull/2769

GIT_ORIGIN_REV_ID=9e60355679855b57ab63edf63944d3e23d2aec9a
PiperOrigin-RevId: 458516880
2022-07-06 05:03:16 -07:00
conradchen
051410b7ef [TextField] Stop saving/restoring TextInputLayout's themeable fields
Saving/restoring themeable fields will cause problems when the view is recreated, because those fields will be restored to the value resolved from the context before the recreation, instead of the current context. For example, when the device locale changes, those fields will still be restored to the previous locale instead of the new one.

It's a general practice in Android framework and AndroidX not to save/restore themeable fields. If clients need this, they should implement their own logic.

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

PiperOrigin-RevId: 454708278
2022-06-13 16:15:10 -07:00
rightnao
4ded01ed3f [TextInputLayout] Add a new custom length counter field and getters/setters to switch how text length is calculated for the counter.
Resolves https://github.com/material-components/material-components-android/issues/2418

PiperOrigin-RevId: 449842640
2022-05-23 10:21:23 -04:00
conradchen
73cb1b6e78 [TextField] Fix hint is not displayed when expanding space is limited
In CollapsingTextHelper we are checking both the expanded bound and the collapsed bound to be larger than 0 to decide if we are going to draw the collapsing text. However this can result in a situation that when there's no space to display expanded hint, the collapsed hint won't be drawn either, even if the hint is not expandable at all.

This CL fixes the issue in a more generic way - whenever draw() is called, we check if the current bound (should be calculated whenever the collapsing fraction is changed) is larger than 0 to decide if we need to draw the collapsing text.

This CL also adds the logic to ensure the cutout bound will never be larger than the collapsed bound.

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

PiperOrigin-RevId: 449597658
2022-05-18 21:14:13 -04:00
conradchen
d3ab6d7bf1 [CleanUp][TextField] Centralize accessibility event dispatching logic for drop-downs
This also fixes the bug that clients cannot use custom AccessibilityDelegate with drop-down mode.

PiperOrigin-RevId: 447748501
2022-05-10 15:04:34 -04:00
conradchen
1a42c743fe [CleanUp][TextField] Move drop-down background and ripple creation to TextInputLayout class
This CL also cleans up and fixes the edit text background setting logic - when the edit text is an autocomplete text view and provides its own background, we won't override the background by trying to add ripples to it.

Later they should be split again from the main class with other box-background-relevant logic.

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

PiperOrigin-RevId: 445486075
2022-05-02 09:19:04 -04:00
pubiqq
3ca41be8f0 [General] Fix typos
Resolves https://github.com/material-components/material-components-android/pull/2654

GIT_ORIGIN_REV_ID=b8f6728979875629f2c813ef90d2f671cf56b4eb
PiperOrigin-RevId: 442852630
2022-04-19 14:48:55 -04:00
leticiars
784f901135 [TextInputLayout] Fixed regression bug of prefix spacing being shown and making expanded label be in the wrong position when text field is not focused.
Resolves https://github.com/material-components/material-components-android/issues/2612

PiperOrigin-RevId: 437745108
2022-03-28 16:48:28 +00:00
leticiars
1c02b62eaf [ExposedDropdownMenu] Update background when setInputType is called so that ripple is or isn't present properly.
PiperOrigin-RevId: 437345929
2022-03-28 16:47:36 +00:00
conradchen
7c160c86fb [CleanUp][TextField] Create EndIconDelegates in an on-demand fashion
This should slightly improve the text field rendering performance.

PiperOrigin-RevId: 435411420
2022-03-18 18:50:15 +00:00
conradchen
6cdf7b5155 [CleanUp][TextField] Extract end components from TextInputLayout
PiperOrigin-RevId: 435390505
2022-03-17 18:51:39 +00:00
conradchen
9a46af2af2 [CleanUp][TextField] Extract start components from TextInputLayout
PiperOrigin-RevId: 432953110
2022-03-09 21:07:45 +00:00
afohrman
108558326d [TextInputLayout] Added class documentation to use TextInputLayout's context to construct the child TextInputEditText.
We already had class documentation that explains that TextInputEditText should be instantiated with the parent TextInputLayout's context for proper theming, but this  information is important enough to the basic usage of TextInputLayout and TextInputEditText that it's best to have it the class documentation, as well.

Added the guidance in both TextInputLayout and TextInputEditText because it's relevant to both classes.

PiperOrigin-RevId: 432244388
2022-03-04 13:03:37 -05:00
conradchen
9789f2e286 [CleanUp][TextField] Split icon tinting logic to a helper class
PiperOrigin-RevId: 431477762
2022-03-01 08:55:44 -08:00
leticiars
b6901275d9 [TextInputLayout][a11y] Fixed prefix/suffix not being properly announced when the text field is focused and they show up. Also improved their screen reader focus order to align with the visual order of the elements: navigating to the left will focus on the prefix and navigating to the right will focus on the suffix.
Resolves https://github.com/material-components/material-components-android/issues/2497

PiperOrigin-RevId: 430208388
2022-02-23 11:13:30 -08:00
leticiars
1b7e92d99c [TextInputLayout] Updated documentation to clarify end icon mode's expected usage and behaviors relating to the icon's drawable.
Resolves https://github.com/material-components/material-components-android/issues/2528

PiperOrigin-RevId: 427506995
2022-02-11 15:41:02 +00:00
leticiars
ae16efd5da [TextInputLayout] Fixed icons behaving unexpectedly when switching modes + bug of wrong icon tint state when setting an icon programmatically.
Resolves https://github.com/material-components/material-components-android/issues/503
Resolves https://github.com/material-components/material-components-android/issues/1849

PiperOrigin-RevId: 427268349
2022-02-09 15:58:45 +00:00
afohrman
2463946d24 [TextInputLayout] Add line mask expansion animation to filled box underline.
Add an expanding animation for the focused underline that's triggered when the edit text gains focus. The line mask animation is built to calculate its bounds based on the hint CollapsingTextHelper's expansion fraction, so it seamlessly follows that animation.

PiperOrigin-RevId: 424703815
2022-01-28 11:55:08 -08:00
pfthomas
7d46b95e9e [TextInputLayout] Add support for minEms and maxEms
Resolves https://github.com/material-components/material-components-android/issues/2269

PiperOrigin-RevId: 423118234
2022-01-24 14:48:13 -05:00
Vyacheslav
26d862bc54 [TextInputLayout] Speedup simple inflate.
Changes are mostly to keep start/end layouts and icon views hidden (visibility = gone) when they are not needed.

Resolves https://github.com/material-components/material-components-android/pull/2326

GIT_ORIGIN_REV_ID=0393ac65d562bc87d340ec7bb260ebba99a1ac3b
Co-authored-by: leticiarossi <9288695+leticiarossi@users.noreply.github.com>
PiperOrigin-RevId: 418038435
2021-12-28 08:54:28 -05:00
conradchen
88eb089021 [TextField] Apply edit text's letter spacing to expanded hints
Resolves https://github.com/material-components/material-components-android/issues/2202

PiperOrigin-RevId: 417863400
2021-12-23 13:54:06 -05:00
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
jeremymuhia
e8bde7546b [TextInputLayout] text field should comply with system level bold
PiperOrigin-RevId: 413194807
2021-11-30 20:48:48 +00:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
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